Go to the documentation of this file.
   29   template <
class T, 
int rank, 
unsigned D0, 
unsigned D1=1, 
unsigned D2=1, 
unsigned D3=1>
 
   33     static unsigned constexpr OFF0 = D3*D2*D1;
 
   35     static unsigned constexpr OFF1 = D3*D2;
 
   37     static unsigned constexpr OFF2 = D3;
 
   39     static unsigned constexpr OFF3 = 1;
 
   41     T 
mutable myData[D0*D1*D2*D3];
 
   46     typedef typename std::remove_cv<T>::type       
type;
 
   63       static_assert(rank==1,
"ERROR: Improper number of dimensions specified in operator()");
 
   65           if constexpr (rank >= 1) { 
if (i0>D0-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i0 out of bounds (i0: %d; lb0: %d; ub0: %d)\n",i0,0,D0-1); ) } }
 
   66           if constexpr (rank >= 1) { 
if (i0>D0-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
   74       static_assert(rank==2,
"ERROR: Improper number of dimensions specified in operator()");
 
   76         if constexpr (rank >= 1) { 
if (i0>D0-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i0 out of bounds (i0: %d; lb0: %d; ub0: %d)\n",i0,0,D0-1); ) } }
 
   77         if constexpr (rank >= 2) { 
if (i1>D1-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i1 out of bounds (i1: %d; lb1: %d; ub1: %d)\n",i1,0,D1-1); ) } }
 
   78         if constexpr (rank >= 1) { 
if (i0>D0-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
   79         if constexpr (rank >= 2) { 
if (i1>D1-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
   81       return myData[i0*OFF0 + i1];
 
   87       static_assert(rank==3,
"ERROR: Improper number of dimensions specified in operator()");
 
   89         if constexpr (rank >= 1) { 
if (i0>D0-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i0 out of bounds (i0: %d; lb0: %d; ub0: %d)\n",i0,0,D0-1); ) } }
 
   90         if constexpr (rank >= 2) { 
if (i1>D1-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i1 out of bounds (i1: %d; lb1: %d; ub1: %d)\n",i1,0,D1-1); ) } }
 
   91         if constexpr (rank >= 3) { 
if (i2>D2-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i2 out of bounds (i2: %d; lb2: %d; ub2: %d)\n",i2,0,D2-1); ) } }
 
   92         if constexpr (rank >= 1) { 
if (i0>D0-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
   93         if constexpr (rank >= 2) { 
if (i1>D1-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
   94         if constexpr (rank >= 3) { 
if (i2>D2-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
   96       return myData[i0*OFF0 + i1*OFF1 + i2];
 
  102       static_assert(rank==4,
"ERROR: Improper number of dimensions specified in operator()");
 
  104         if constexpr (rank >= 1) { 
if (i0>D0-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i0 out of bounds (i0: %d; lb0: %d; ub0: %d)\n",i0,0,D0-1); ) } }
 
  105         if constexpr (rank >= 2) { 
if (i1>D1-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i1 out of bounds (i1: %d; lb1: %d; ub1: %d)\n",i1,0,D1-1); ) } }
 
  106         if constexpr (rank >= 3) { 
if (i2>D2-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i2 out of bounds (i2: %d; lb2: %d; ub2: %d)\n",i2,0,D2-1); ) } }
 
  107         if constexpr (rank >= 4) { 
if (i3>D3-1) { 
YAKL_EXECUTE_ON_HOST_ONLY( printf(
"CSArray i3 out of bounds (i3: %d; lb3: %d; ub3: %d)\n",i3,0,D3-1); ) } }
 
  108         if constexpr (rank >= 1) { 
if (i0>D0-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
  109         if constexpr (rank >= 2) { 
if (i1>D1-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
  110         if constexpr (rank >= 3) { 
if (i2>D2-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
  111         if constexpr (rank >= 4) { 
if (i3>D3-1) { 
yakl_throw(
"ERROR: CSArray index out of bounds"); } }
 
  113       return myData[i0*OFF0 + i1*OFF1 + i2*OFF2 + i3];
 
  118     template <class TLOC , typename std::enable_if<std::is_arithmetic<TLOC>::value,
int>
::type = 0 >
 
  131     static unsigned constexpr 
totElems      () { 
return D3*D2*D1*D0; }
 
  135     static unsigned constexpr 
size          () { 
return D3*D2*D1*D0; }
 
  139     static unsigned constexpr 
get_rank      () { 
return rank; }
 
  148       for (
uint i=0; i<
totElems(); i++) { os << std::setw(12) << v.myData[i] << 
"\n"; }
 
  159       if constexpr (rank >= 1) ret(0) = D0;
 
  160       if constexpr (rank >= 2) ret(1) = D1;
 
  161       if constexpr (rank >= 3) ret(2) = D2;
 
  162       if constexpr (rank >= 4) ret(3) = D3;
 
  170       if constexpr (rank >= 1) ret(0) = 0;
 
  171       if constexpr (rank >= 2) ret(1) = 0;
 
  172       if constexpr (rank >= 3) ret(2) = 0;
 
  173       if constexpr (rank >= 4) ret(3) = 0;
 
  181       if constexpr (rank >= 1) ret(0) = D0-1;
 
  182       if constexpr (rank >= 2) ret(1) = D1-1;
 
  183       if constexpr (rank >= 3) ret(2) = D2-1;
 
  184       if constexpr (rank >= 4) ret(3) = D3-1;
 
  193   template <
class T, 
int rank, 
unsigned D0, 
unsigned D1=1, 
unsigned D2=1, 
unsigned D3=1>
 
  
friend std::ostream & operator<<(std::ostream &os, CSArray< T, rank, D0, D1, D2, D3 > const &v)
Print out the contents of this array. This should be called only from the host.
Definition: YAKL_CSArray.h:147
 
std::remove_const< type >::type non_const_value_type
This is the type T with const removed from it (if the original type has volatile, then so will this t...
Definition: YAKL_CSArray.h:52
 
static constexpr unsigned size()
Get the total number of array elements.
Definition: YAKL_CSArray.h:135
 
YAKL_INLINE T * end() const
Returns pointer to end of the data.
Definition: YAKL_CSArray.h:129
 
unsigned int uint
Definition: YAKL.h:32
 
#define __YAKL_NAMESPACE_WRAPPER_END__
Definition: YAKL.h:20
 
#define __YAKL_NAMESPACE_WRAPPER_BEGIN__
Definition: YAKL.h:19
 
static constexpr bool span_is_contiguous()
Always true. All YAKL arrays are contiguous with no padding.
Definition: YAKL_CSArray.h:141
 
#define YAKL_INLINE
Used to decorate functions called from kernels (parallel_for and parallel_outer) or from CPU function...
Definition: YAKL_defines.h:140
 
T value_type
This is the type T exactly as it was defined upon array object creation.
Definition: YAKL_CSArray.h:48
 
static constexpr unsigned get_rank()
Get the number of dimensions.
Definition: YAKL_CSArray.h:139
 
YAKL_INLINE T & operator()(uint const i0, uint const i1, uint const i2, uint const i3) const
Returns a reference to the indexed element (4-D).
Definition: YAKL_CSArray.h:101
 
#define YAKL_EXECUTE_ON_HOST_ONLY(...)
[NOT COMMONLY USED] Macro function used to determine if the current code is compiling for the host.
Definition: YAKL_defines.h:153
 
YAKL_INLINE void yakl_throw(const char *msg)
Throw an error message. Works from the host or device.
Definition: YAKL_error.h:17
 
YAKL_INLINE T & operator()(uint const i0) const
Returns a reference to the indexed element (1-D).
Definition: YAKL_CSArray.h:62
 
std::remove_cv< T >::type type
This is the type T without const and volatile modifiers.
Definition: YAKL_CSArray.h:46
 
C-style array on the stack similar in nature to, e.g., float arr[ny][nx];
Definition: YAKL_CSArray.h:30
 
static constexpr unsigned get_totElems()
Get the total number of array elements.
Definition: YAKL_CSArray.h:133
 
std::add_const< type >::type const_value_type
This is the type T with const added to it (if the original type has volatile, then so will this type)...
Definition: YAKL_CSArray.h:50
 
YAKL_INLINE CSArray< uint, 1, rank > get_lbounds() const
Returns the lower bound of each dimension of this array as a yakl::SArray object.
Definition: YAKL_CSArray.h:168
 
YAKL_INLINE CSArray(T init_fill)
No constructor arguments allowed.
Definition: YAKL_CSArray.h:55
 
static constexpr unsigned get_elem_count()
Get the total number of array elements.
Definition: YAKL_CSArray.h:137
 
YAKL_INLINE CSArray< uint, 1, rank > get_dimensions() const
Returns the dimensions of this array as a yakl::SArray object.
Definition: YAKL_CSArray.h:157
 
static constexpr unsigned totElems()
Get the total number of array elements.
Definition: YAKL_CSArray.h:131
 
YAKL_INLINE T * begin() const
Returns pointer to beginning of the data.
Definition: YAKL_CSArray.h:127
 
YAKL_INLINE CSArray< uint, 1, rank > get_ubounds() const
Returns the upper bound of each dimension of this array as a yakl::SArray object.
Definition: YAKL_CSArray.h:179
 
YAKL_INLINE T * get_data() const
Get the underlying raw data pointer.
Definition: YAKL_CSArray.h:125
 
YAKL_INLINE T & operator()(uint const i0, uint const i1, uint const i2) const
Returns a reference to the indexed element (3-D).
Definition: YAKL_CSArray.h:86
 
YAKL_INLINE void operator=(TLOC val)
Assign a single arithmetic value to the entire array.
Definition: YAKL_CSArray.h:119
 
YAKL_INLINE T & operator()(uint const i0, uint const i1) const
Returns a reference to the indexed element (2-D).
Definition: YAKL_CSArray.h:73
 
YAKL_INLINE T * data() const
Get the underlying raw data pointer.
Definition: YAKL_CSArray.h:123
 
static constexpr bool initialized()
Always true. yakl::SArray objects are by default always initialized / allocated.
Definition: YAKL_CSArray.h:143