Skip to content

Commit dbc92d2

Browse files
authored
Feature/boomer amg for elasticity (#213)
* changes for changes to index types * add some getters for the CRSMatrix * add CHAI_CUDA_FLAGS cmake option. Add device capable print function for CRSMatrix * remove erroneous check in SparsityPatternView * update TPL path for LC * make print statement a macro to accommodate different format labels for index types
1 parent 4149781 commit dbc92d2

File tree

8 files changed

+139
-5
lines changed

8 files changed

+139
-5
lines changed

host-configs/LLNL/lassen-base.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Set up the tpls
22
set(GEOSX_TPL_ROOT_DIR /usr/gapps/GEOSX/thirdPartyLibs CACHE PATH "")
3-
set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2021-01-19/install-${CONFIG_NAME}-release CACHE PATH "")
3+
set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2021-03-01/install-${CONFIG_NAME}-release CACHE PATH "")
44

55
set(RAJA_DIR ${GEOSX_TPL_DIR}/raja CACHE PATH "")
66

@@ -27,6 +27,8 @@ set(CMAKE_CUDA_FLAGS_RELEASE "-O3 -DNDEBUG -Xcompiler -DNDEBUG -Xcompiler -O3 -X
2727
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-g -lineinfo ${CMAKE_CUDA_FLAGS_RELEASE}" CACHE STRING "")
2828
set(CMAKE_CUDA_FLAGS_DEBUG "-g -G -O0 -Xcompiler -O0" CACHE STRING "")
2929

30+
set(CHAI_CUDA_FLAGS "-arch ${CUDA_ARCH}" CACHE STRING "" FORCE)
31+
3032
# Uncomment this line to make nvcc output register usage for each kernel.
3133
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --resource-usage" CACHE STRING "" FORCE)
3234

host-configs/LLNL/quartz-base.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
set(ENABLE_FORTRAN OFF CACHE BOOL "")
22

33
set(GEOSX_TPL_ROOT_DIR /usr/gapps/GEOSX/thirdPartyLibs CACHE PATH "")
4-
set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2021-01-19/install-${CONFIG_NAME}-release CACHE PATH "")
4+
set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2021-03-01/install-${CONFIG_NAME}-release CACHE PATH "")
55

66
set(RAJA_DIR ${GEOSX_TPL_DIR}/raja CACHE PATH "")
77

@@ -18,6 +18,7 @@ set(CALIPER_DIR ${GEOSX_TPL_DIR}/caliper CACHE PATH "")
1818
# set(PYTHON_DIR /usr/tce/packages/python/python-3.7.2 CACHE PATH "")
1919

2020
set(SPHINX_EXECUTABLE /collab/usr/gapps/python/build/spack-toss3.2/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/python-2.7.14-7rci3jkmuht2uiwp433afigveuf4ocnu/bin/sphinx-build CACHE PATH "")
21+
2122
set(DOXYGEN_EXECUTABLE ${GEOSX_TPL_DIR}/doxygen/bin/doxygen CACHE PATH "")
2223

2324
set(ENABLE_GTEST_DEATH_TESTS ON CACHE BOOL "")

src/ArrayOfArraysView.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,37 @@ class ArrayOfArraysView
332332
return m_sizes[ i ];
333333
}
334334

335+
/**
336+
* @return Return a pointer to the sizes of each outer array.
337+
*/
338+
LVARRAY_HOST_DEVICE constexpr inline
339+
SIZE_TYPE const * getSizes() const
340+
{
341+
return m_sizes.data();
342+
}
343+
344+
345+
/**
346+
* @return Return a pointer to the value array offsets for each outer array
347+
* with an entry for the end of the values.
348+
*/
349+
LVARRAY_HOST_DEVICE constexpr inline
350+
INDEX_TYPE const * getOffsets() const
351+
{
352+
return m_offsets.data();
353+
}
354+
355+
/**
356+
* @return Return a pointer to the values data.
357+
*/
358+
LVARRAY_HOST_DEVICE constexpr inline
359+
T const * getValues() const
360+
{
361+
return m_values.data();
362+
}
363+
364+
365+
335366
/**
336367
* @return Return the number of (zero length) arrays that can be stored before reallocation.
337368
*/
@@ -558,6 +589,7 @@ class ArrayOfArraysView
558589
m_offsets.move( space, touch );
559590
}
560591

592+
561593
///@}
562594

563595
protected:

src/ArrayOfSetsView.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ class ArrayOfSetsView : protected ArrayOfArraysView< T, INDEX_TYPE, std::is_cons
322322

323323
///@}
324324

325+
326+
using ParentClass::getSizes;
327+
using ParentClass::getOffsets;
328+
using ParentClass::getValues;
329+
325330
protected:
326331

327332
/**

src/CRSMatrixView.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,18 @@ class CRSMatrixView : protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFE
244244
nullptr );
245245
}
246246

247+
/**
248+
* @return A pointer to the values of m_entires(data) of the matrix.
249+
*/
250+
LVARRAY_HOST_DEVICE inline
251+
T const * getEntries() const
252+
{
253+
return m_entries.data();
254+
}
255+
247256
using ParentClass::getColumns;
248257
using ParentClass::getOffsets;
258+
using ParentClass::getSizes;
249259

250260
///@}
251261

src/SparsityPatternView.hpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ class SparsityPatternView : protected ArrayOfSetsView< COL_TYPE, INDEX_TYPE, BUF
7272
public:
7373
static_assert( std::is_integral< COL_TYPE >::value, "COL_TYPE must be integral." );
7474
static_assert( std::is_integral< INDEX_TYPE >::value, "INDEX_TYPE must be integral." );
75-
static_assert( std::numeric_limits< INDEX_TYPE >::max() >= std::numeric_limits< COL_TYPE >::max(),
76-
"INDEX_TYPE must be able to hold values at least as large as COL_TYPE." );
7775

7876
/// The integer type used to enumerate the columns.
7977
using ColType = COL_TYPE;
@@ -288,6 +286,18 @@ class SparsityPatternView : protected ArrayOfSetsView< COL_TYPE, INDEX_TYPE, BUF
288286
INDEX_TYPE const * getOffsets() const
289287
{ return this->m_offsets.data(); }
290288

289+
/**
290+
* @return Return a pointer to the array of values, this array has length numRows().
291+
*/
292+
LVARRAY_HOST_DEVICE constexpr inline
293+
COL_TYPE const * getColumns() const
294+
{
295+
return this->getValues();
296+
}
297+
298+
using ParentClass::getSizes;
299+
300+
291301
///@}
292302

293303
/**

src/limits.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ integerConversion( INPUT input )
117117
static_assert( std::is_integral< INPUT >::value, "INPUT must be an integral type." );
118118
static_assert( std::is_integral< OUTPUT >::value, "OUTPUT must be an integral type." );
119119

120-
return OUTPUT{ input };
120+
// return OUTPUT{ input };
121+
return static_cast< OUTPUT >(input);
121122
}
122123

123124
/**

src/output.hpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include "SortedArray.hpp"
1818
#include "ArrayOfArrays.hpp"
1919
#include "CRSMatrix.hpp"
20+
#include "Macros.hpp"
21+
22+
23+
// TPL includes
24+
#include <RAJA/RAJA.hpp>
2025

2126
// System includes
2227
#include <string>
@@ -191,6 +196,74 @@ std::ostream & operator<< ( std::ostream & stream, CRSMatrixView< T const, COL_T
191196
return stream;
192197
}
193198

199+
200+
/**
201+
* @brief Macro to generate function to output a CRSMatrixView
202+
* @param COL_TYPE The type of index used to specify the column of the matrix.
203+
* @param INDEX_TYPE The type of index used to specify the row of the matrix.
204+
* @param LITOKEN A string literal to give the printf token for the row index type.
205+
* @param GITOKEN A string literal to give the printf token for the column index type.
206+
*/
207+
#define MAKE_PRINT_MATVIEW( COL_TYPE, INDEX_TYPE, LITOKEN, GITOKEN ) \
208+
/** @brief Print a CRSMatrixView in a format that can be easily xxdiff'ed on */ \
209+
/** the console. */ \
210+
/** @tparam POLICY The policy for dummy kernel launch. */ \
211+
/** @tparam T The type of the values in @p view. */ \
212+
/** @tparam BUFFER_TYPE The type of buffer used by @p view. */ \
213+
/** @param view The matrix view object to print. */ \
214+
template< typename POLICY, \
215+
typename T, \
216+
template< typename > class BUFFER_TYPE > \
217+
void print( CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > const & view ) \
218+
{ \
219+
INDEX_TYPE const numRows = view.numRows(); \
220+
\
221+
\
222+
printf( "numRows = %4" LITOKEN " \n", numRows ); \
223+
RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, 1 ), [=] LVARRAY_HOST_DEVICE ( INDEX_TYPE const ) \
224+
{ \
225+
INDEX_TYPE const * const ncols = view.getSizes(); \
226+
INDEX_TYPE const * const row_indexes = view.getOffsets(); \
227+
COL_TYPE const * const cols = view.getColumns(); \
228+
T const * const values = view.getEntries(); \
229+
\
230+
printf( "ncols = { " ); for( INDEX_TYPE i=0; i<numRows; ++i ) \
231+
{ \
232+
printf( "%4" LITOKEN ", ", ncols[i] ); \
233+
} \
234+
printf( " }\n" ); \
235+
printf( "row_indexes = { " ); for( INDEX_TYPE i=0; i<numRows+1; ++i ) \
236+
{ \
237+
printf( "%4" GITOKEN ", ", row_indexes[i] ); \
238+
} \
239+
printf( " }\n" ); \
240+
\
241+
\
242+
printf( "row col value \n" ); \
243+
printf( "---- --------- --------- \n" ); \
244+
\
245+
for( INDEX_TYPE i=0; i<numRows; ++i ) \
246+
{ \
247+
printf( "%4" LITOKEN "\n", ncols[i] ); \
248+
for( INDEX_TYPE j=0; j<ncols[i]; ++j ) \
249+
{ \
250+
printf( "%4" LITOKEN " %9" GITOKEN " %9.2g\n", \
251+
i, \
252+
cols[row_indexes[i] + j], \
253+
values[row_indexes[i] + j] ); \
254+
} \
255+
} \
256+
\
257+
} ); \
258+
std::cout<<std::endl; \
259+
}
260+
261+
MAKE_PRINT_MATVIEW( int, int, "d", "d" )
262+
MAKE_PRINT_MATVIEW( int, long long int, "d", "lld" )
263+
MAKE_PRINT_MATVIEW( long int, long long int, "ld", "lld" )
264+
MAKE_PRINT_MATVIEW( long long int, long long int, "lld", "lld" )
265+
266+
194267
/**
195268
* @brief Output a c-array to a stream.
196269
* @tparam T The type contained in the array.

0 commit comments

Comments
 (0)