24 #include <RAJA/RAJA.hpp> 30 #if defined( LVARRAY_USE_CUDA ) 31 #include <cuda_fp16.h> 48 template<
typename T,
int NDIM,
int USD,
typename INDEX_TYPE >
54 if( slice.
size( 0 ) > 0 )
59 for( INDEX_TYPE i = 1; i < slice.
size( 0 ); ++i )
61 stream <<
", " << slice[ i ];
85 template<
typename >
class BUFFER_TYPE >
98 template<
typename T,
typename INDEX_TYPE,
template<
typename >
class BUFFER_TYPE >
102 if( view.
size() == 0 )
110 if( view.
size() > 0 )
115 for( INDEX_TYPE i = 1; i < view.
size(); ++i )
117 stream <<
", " << view[ i ];
132 template<
typename T,
typename INDEX_TYPE,
template<
typename >
class BUFFER_TYPE >
145 template<
typename T,
typename INDEX_TYPE,
template<
typename >
class BUFFER_TYPE >
149 stream <<
"{" << std::endl;
151 for( INDEX_TYPE i = 0; i < view.
size(); ++i )
153 stream << i <<
"\t{";
154 for( INDEX_TYPE j = 0; j < view.
sizeOfArray( i ); ++j )
156 stream << view( i, j ) <<
", ";
159 stream <<
"}" << std::endl;
162 stream <<
"}" << std::endl;
174 template<
typename T,
typename INDEX_TYPE,
template<
typename >
class BUFFER_TYPE >
187 template<
typename T,
typename COL_TYPE,
typename INDEX_TYPE,
template<
typename >
class BUFFER_TYPE >
188 std::ostream & operator<< ( std::ostream & stream, CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE >
const & view )
190 stream <<
"{" << std::endl;
192 for( INDEX_TYPE row = 0; row < view.numRows(); ++row )
194 stream <<
"row " << row << std::endl;
195 stream <<
"\tcolumns: " << view.getColumns( row ) << std::endl;
196 stream <<
"\tvalues: " << view.getEntries( row ) << std::endl;
199 stream <<
"}" << std::endl;
213 template<
typename POLICY,
typename T,
typename COL_TYPE,
typename INDEX_TYPE,
template<
typename >
class BUFFER_TYPE >
216 INDEX_TYPE
const numRows = view.
numRows();
218 printf(
"numRows = %4lld \n", integerConversion< long long >( numRows ) );
219 RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, 1 ), [=]
LVARRAY_HOST_DEVICE ( INDEX_TYPE
const )
221 INDEX_TYPE
const *
const ncols = view.
getSizes();
222 INDEX_TYPE
const *
const row_indexes = view.
getOffsets();
223 COL_TYPE
const *
const cols = view.
getColumns();
226 printf(
"ncols = { " );
227 for( INDEX_TYPE i = 0; i < numRows; ++i )
229 printf(
"%4lld, ", integerConversion< long long >( ncols[ i ] ) );
233 printf(
"row_indexes = { " );
234 for( INDEX_TYPE i = 0; i < numRows + 1; ++i )
236 printf(
"%4lld, ", integerConversion< long long >( row_indexes[ i ] ) );
240 printf(
"row col value \n" );
241 printf(
"---- --------- --------- \n" );
242 for( INDEX_TYPE i = 0; i < numRows; ++i )
244 printf(
"%4lld\n", integerConversion< long long >( ncols[ i ] ) );
245 for( INDEX_TYPE j = 0; j < ncols[ i ]; ++j )
247 printf(
"%4lld %9lld %9.2g\n",
248 integerConversion< long long >( i ),
249 integerConversion< long long >( cols[ row_indexes[ i ] + j ] ),
250 double( values[ row_indexes[ i ] + j ] ) );
255 std::cout << std::endl;
266 template<
typename T,
int N >
267 std::enable_if_t< !std::is_same< T, char >::value, std::ostream & >
268 operator<< ( std::ostream & stream, T
const ( &array )[ N ] )
270 stream <<
"{ " << array[ 0 ];
271 for(
int i = 1; i < N; ++i )
273 stream <<
", " << array[ i ];
288 template<
typename T,
int M,
int N >
289 std::ostream &
operator<< ( std::ostream & stream, T
const ( &array )[ M ][ N ] )
291 stream <<
"{ " << array[ 0 ];
292 for(
int i = 1; i < M; ++i )
294 stream <<
", " << array[ i ];
302 #if defined( LVARRAY_USE_CUDA ) 310 inline std::ostream &
operator<<( std::ostream & stream, __half
const x )
311 {
return stream << float( x ); }
319 inline std::ostream &
operator<<( std::ostream & stream, __half2
const x )
321 float2
const c = __half22float2( x );
322 return stream << c.x <<
", " << c.y;
LVARRAY_HOST_DEVICE constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > toSliceConst() const &noexcept
Definition: ArrayView.hpp:327
Contains the implementation of LvArray::ArrayOfArrays.
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
Definition: ArraySlice.hpp:89
This class provides an interface similar to an std::set.
Definition: SortedArray.hpp:35
void print(CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > const &view)
Print a CRSMatrixView in a format that can be easily xxdiff'ed on the console.
Definition: output.hpp:214
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE size() const noexcept
Definition: ArraySlice.hpp:170
Contains portable access to std::numeric_limits and functions for converting between integral types...
This class implements an array of arrays like object with contiguous storage.
Definition: ArrayOfArrays.hpp:33
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:68
Contains the implementation of LvArray::Array.
This class provides a view into an array of arrays like object.
Definition: ArrayOfArraysView.hpp:170
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE_NC const numRows() const
Definition: SparsityPatternView.hpp:197
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE_NC sizeOfArray(INDEX_TYPE const i) const
Definition: ArrayOfArraysView.hpp:332
Contains the implementation of LvArray::SortedArray.
Contains the implementation of LvArray::CRSMatrix.
The top level namespace.
Definition: Array.hpp:24
LVARRAY_HOST_DEVICE SortedArrayView< T const, INDEX_TYPE, BUFFER_TYPE > toViewConst() const &
Definition: SortedArray.hpp:155
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE const * getOffsets() const
Definition: SparsityPatternView.hpp:289
Contains a bunch of macro definitions.
std::ostream & operator<<(std::ostream &os, MemorySpace const space)
Output a Platform enum to a stream.
Definition: bufferManipulation.hpp:39
LVARRAY_HOST_DEVICE constexpr ArraySlice< COL_TYPE const, 1, 0, INDEX_TYPE_NC > getColumns(INDEX_TYPE const row) const
Definition: SparsityPatternView.hpp:282
LVARRAY_HOST_DEVICE ArraySlice< T, 1, 0, INDEX_TYPE_NC > getEntries(INDEX_TYPE const row) const
Definition: CRSMatrixView.hpp:244
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE_NC size() const
Definition: ArrayOfArraysView.hpp:324
LVARRAY_HOST_DEVICE constexpr SIZE_TYPE const * getSizes() const
Definition: ArrayOfArraysView.hpp:342
This class provides a view into a SortedArray.
Definition: SortedArrayView.hpp:58
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
Definition: Macros.hpp:600
LVARRAY_HOST_DEVICE constexpr INDEX_TYPE size() const
Definition: SortedArrayView.hpp:188
This class provides a view into a compressed row storage matrix.
Definition: CRSMatrixView.hpp:75
constexpr ArrayOfArraysView< T const, INDEX_TYPE const, true, BUFFER_TYPE > toViewConst() const &
Definition: ArrayOfArrays.hpp:142