21 #include <RAJA/RAJA.hpp> 36 template<
bool B_IS_ONE >
46 template<
typename A,
typename B >
65 template<
typename A,
typename B >
76 template<
int SIZE,
typename T >
78 std::enable_if_t< (SIZE == 1), T >
80 {
return values[ 0 ]; }
88 template<
int SIZE,
typename T >
90 std::enable_if_t< (SIZE > 1), T >
92 {
return values[ 0 ] *
multiplyAll< SIZE - 1 >( values + 1 ); }
104 template<
int USD,
typename INDEX_TYPE,
typename INDEX >
106 INDEX_TYPE
getLinearIndex( INDEX_TYPE
const *
const LVARRAY_RESTRICT strides, INDEX
const index )
121 template<
int USD,
typename INDEX_TYPE,
typename INDEX,
typename ... REMAINING_INDICES >
123 INDEX_TYPE
getLinearIndex( INDEX_TYPE
const *
const LVARRAY_RESTRICT strides, INDEX
const index, REMAINING_INDICES
const ... indices )
126 getLinearIndex< USD - 1, INDEX_TYPE, REMAINING_INDICES... >( strides + 1, indices ... );
141 template<
typename INDEX,
typename ... REMAINING_INDICES >
144 std::ostringstream oss;
146 oss <<
"{ " << index;
147 using expander =
int[];
148 (void) expander{ 0, ( void (oss <<
", " << indices ), 0 )... };
161 template<
typename INDEX_TYPE,
typename ... INDICES >
164 constexpr
int NDIM =
sizeof ... (INDICES);
165 std::ostringstream oss;
166 oss <<
"dimensions = { " << dims[ 0 ];
167 for(
int i = 1; i < NDIM; ++i )
169 oss <<
", " << dims[ i ];
184 template<
typename INDEX_TYPE,
typename ... INDICES >
186 bool invalidIndices( INDEX_TYPE
const *
const LVARRAY_RESTRICT dims, INDICES
const ... indices )
189 bool invalid =
false;
192 invalid = invalid || ( index < 0 ) || ( index >= dims[ curDim ] );
206 template<
typename INDEX_TYPE,
typename ... INDICES >
208 void checkIndices( INDEX_TYPE
const *
const LVARRAY_RESTRICT dims, INDICES
const ... indices )
constexpr INDEX_TYPE getLinearIndex(INDEX_TYPE const *const LVARRAY_RESTRICT strides, INDEX const index)
Get the index into a one dimensional space.
std::string getIndexString()
constexpr bool invalidIndices(INDEX_TYPE const *const LVARRAY_RESTRICT dims, INDICES const ... indices)
#define LVARRAY_ERROR_IF(EXP, MSG)
Abort execution if EXP is true.
Contains templates useful for type manipulation.
void checkIndices(INDEX_TYPE const *const LVARRAY_RESTRICT dims, INDICES const ... indices)
Check that the indices are with dims , if not the program is aborted.
Contains portable access to std::numeric_limits and functions for converting between integral types...
static constexpr auto multiply(A const a, B const b)
A helper struct to multiply two numbers.
static constexpr A multiply(A const a, B const &)
std::string printDimsAndIndices(INDEX_TYPE const *const LVARRAY_RESTRICT dims, INDICES const ... indices)
Contains a bunch of macro definitions.
std::string string
String type.
constexpr void forEachArg(F &&f)
The recursive base case where no argument is provided.
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
constexpr std::enable_if_t<(SIZE==1), T > multiplyAll(T const *const LVARRAY_RESTRICT values)