Go to the documentation of this file.
54 template <
class T,
int rank,
int myMem>
59 typedef typename std::remove_cv<T>::type
type;
73 this->myData =
nullptr;
74 this->refCount =
nullptr;
75 for (
int i=0; i < rank; i++) { this->dimension[i] = 0; }
77 this->myname=
"Uninitialized";
120 static_assert( rank == 1 ,
"ERROR: Calling constructor with 1 bound on non-rank-1 array" );
126 static_assert( rank == 2 ,
"ERROR: Calling constructor with 2 bound on non-rank-2 array" );
133 static_assert( rank == 3 ,
"ERROR: Calling constructor with 3 bound on non-rank-3 array" );
141 static_assert( rank == 4 ,
"ERROR: Calling constructor with 4 bound on non-rank-4 array" );
150 static_assert( rank == 5 ,
"ERROR: Calling constructor with 5 bound on non-rank-5 array" );
160 static_assert( rank == 6 ,
"ERROR: Calling constructor with 6 bound on non-rank-6 array" );
171 static_assert( rank == 7 ,
"ERROR: Calling constructor with 7 bound on non-rank-7 array" );
183 static_assert( rank == 8 ,
"ERROR: Calling constructor with 8 bound on non-rank-8 array" );
188 static_assert( rank >= 1 && rank <= 8 ,
"ERROR: Creating Array with a rank < 1 or > 8" );
191 if (dims.
size() != rank)
yakl_throw(
"ERROR: Number of constructor dimensions does not match the Array rank");
195 this->myname = label;
197 for (
int i=0; i < rank; i++) { this->dimension[i] = dims[i]; }
232 static_assert( rank == 1 ,
"ERROR: Calling constructor with 1 bound on non-rank-1 array" );
238 static_assert( rank == 2 ,
"ERROR: Calling constructor with 2 bound on non-rank-2 array" );
245 static_assert( rank == 3 ,
"ERROR: Calling constructor with 3 bound on non-rank-3 array" );
253 static_assert( rank == 4 ,
"ERROR: Calling constructor with 4 bound on non-rank-4 array" );
262 static_assert( rank == 5 ,
"ERROR: Calling constructor with 5 bound on non-rank-5 array" );
272 static_assert( rank == 6 ,
"ERROR: Calling constructor with 6 bound on non-rank-6 array" );
283 static_assert( rank == 7 ,
"ERROR: Calling constructor with 7 bound on non-rank-7 array" );
295 static_assert( rank == 8 ,
"ERROR: Calling constructor with 8 bound on non-rank-8 array" );
300 static_assert( rank >= 1 && rank <= 8 ,
"ERROR: Creating Array with a rank < 1 or > 8" );
304 if (data ==
nullptr)
yakl_throw(
"ERROR: wrapping nullptr with a YAKL Array object");
305 this->myname = label;
307 for (
int i=0; i < rank; i++) { this->dimension[i] = dims[i]; }
309 this->refCount =
nullptr;
321 copy_constructor_common(rhs);
325 static_assert( std::is_const<T>::value ,
326 "ERROR: Cannot create non-const Array using const Array" );
329 copy_constructor_common(rhs);
335 if constexpr (! std::is_const<T>::value) {
336 if (
this == &rhs) {
return *
this; }
339 copy_constructor_common(rhs);
344 static_assert( std::is_const<T>::value ,
345 "ERROR: Cannot create non-const Array using const Array" );
346 if constexpr (std::is_const<T>::value) {
347 if (
this == &rhs) {
return *
this; }
350 copy_constructor_common(rhs);
355 template <
class TLOC>
357 for (
int i=0; i<rank; i++) {
358 this->dimension[i] = rhs.dimension[i];
361 this->myname = rhs.myname;
363 this->myData = rhs.myData;
365 this->refCount = rhs.refCount;
366 if (this->refCount !=
nullptr) {
383 for (
int i=0; i<rank; i++) {
384 this->dimension[i] = rhs.dimension[i];
387 this->myname = rhs.myname;
389 this->myData = rhs.myData;
390 rhs.myData =
nullptr;
392 this->refCount = rhs.refCount;
393 rhs.refCount =
nullptr;
399 if (
this == &rhs) {
return *
this; }
401 for (
int i=0; i<rank; i++) {
402 this->dimension[i] = rhs.dimension[i];
405 this->myname = rhs.myname;
407 this->myData = rhs.myData;
408 rhs.myData =
nullptr;
410 this->refCount = rhs.refCount;
411 rhs.refCount =
nullptr;
432 this->myData = ir.
data();
434 this->myname = ir.
label();
436 for (
int i=0; i < rank; i++) { this->dimension[i] = ir.
extent(i); }
441 template <
class TLOC = T>
443 std::array<size_t,rank> dimensions;
444 for (
int i=0; i < rank; i++) { dimensions[i] = this->dimension[i]; }
448 #ifdef YAKL_MANAGED_MEMORY
472 static_assert( rank == 1 ,
"ERROR: Indexing non-rank-1 array with 1 index" );
477 return this->myData[ind];
482 static_assert( rank == 2 ,
"ERROR: Indexing non-rank-2 array with 2 indices" );
486 index_t ind = i0*this->dimension[1] + i1;
487 return this->myData[ind];
492 static_assert( rank == 3 ,
"ERROR: Indexing non-rank-3 array with 3 indices" );
496 index_t ind = (i0*this->dimension[1] + i1)*
497 this->dimension[2] + i2;
498 return this->myData[ind];
503 static_assert( rank == 4 ,
"ERROR: Indexing non-rank-4 array with 4 indices" );
507 index_t ind = ((i0*this->dimension[1] + i1)*
508 this->dimension[2] + i2)*
509 this->dimension[3] + i3;
510 return this->myData[ind];
515 static_assert( rank == 5 ,
"ERROR: Indexing non-rank-5 array with 5 indices" );
517 check(i0,i1,i2,i3,i4);
519 index_t ind = (((i0*this->dimension[1] + i1)*
520 this->dimension[2] + i2)*
521 this->dimension[3] + i3)*
522 this->dimension[4] + i4;
523 return this->myData[ind];
528 static_assert( rank == 6 ,
"ERROR: Indexing non-rank-6 array with 6 indices" );
530 check(i0,i1,i2,i3,i4,i5);
532 index_t ind = ((((i0*this->dimension[1] + i1)*
533 this->dimension[2] + i2)*
534 this->dimension[3] + i3)*
535 this->dimension[4] + i4)*
536 this->dimension[5] + i5;
537 return this->myData[ind];
542 static_assert( rank == 7 ,
"ERROR: Indexing non-rank-7 array with 7 indices" );
544 check(i0,i1,i2,i3,i4,i5,i6);
546 index_t ind = (((((i0*this->dimension[1] + i1)*
547 this->dimension[2] + i2)*
548 this->dimension[3] + i3)*
549 this->dimension[4] + i4)*
550 this->dimension[5] + i5)*
551 this->dimension[6] + i6;
552 return this->myData[ind];
558 static_assert( rank == 8 ,
"ERROR: Indexing non-rank-8 array with 8 indices" );
560 check(i0,i1,i2,i3,i4,i5,i6,i7);
562 index_t ind = ((((((i0*this->dimension[1] + i1)*
563 this->dimension[2] + i2)*
564 this->dimension[3] + i3)*
565 this->dimension[4] + i4)*
566 this->dimension[5] + i5)*
567 this->dimension[6] + i6)*
568 this->dimension[7] + i7;
569 return this->myData[ind];
577 if (! this->initialized()) {
yakl_throw(
"Error: Using operator() on an Array that isn't allocated"); }
578 if constexpr (rank >= 1) {
if (i0 >= this->dimension[0]) ind_out_bounds<0>(i0); }
579 if constexpr (rank >= 2) {
if (i1 >= this->dimension[1]) ind_out_bounds<1>(i1); }
580 if constexpr (rank >= 3) {
if (i2 >= this->dimension[2]) ind_out_bounds<2>(i2); }
581 if constexpr (rank >= 4) {
if (i3 >= this->dimension[3]) ind_out_bounds<3>(i3); }
582 if constexpr (rank >= 5) {
if (i4 >= this->dimension[4]) ind_out_bounds<4>(i4); }
583 if constexpr (rank >= 6) {
if (i5 >= this->dimension[5]) ind_out_bounds<5>(i5); }
584 if constexpr (rank >= 7) {
if (i6 >= this->dimension[6]) ind_out_bounds<6>(i6); }
585 if constexpr (rank >= 8) {
if (i7 >= this->dimension[7]) ind_out_bounds<7>(i7); }
586 #if defined(YAKL_SEPARATE_MEMORY_SPACE)
588 #
if !defined(YAKL_MANAGED_MEMORY)
591 std::cerr <<
"ERROR: For Array labeled: " << this->myname <<
":" << std::endl;
592 yakl_throw(
"Device array being accessed on the host without managed memory turned on");
607 std::cerr <<
"ERROR: For Array labeled: " << this->myname <<
":" << std::endl;
608 std::cerr <<
"Index " << I+1 <<
" of " << rank <<
" is out of bounds. Provided index: " << ind
609 <<
". Upper Bound: " << this->dimension[I]-1 << std::endl;
617 template <class TLOC, typename std::enable_if<std::is_arithmetic<TLOC>::value,
bool>::type =
false>
625 template <
class TLOC>
626 void memset_loc(TLOC rhs)
const {
628 #ifdef YAKL_ENABLE_STREAMS
632 #ifdef YAKL_ENABLE_STREAMS
636 for (
int i=0; i < this->totElems(); i++) { this->myData[i] = rhs; }
649 if (! this->initialized()) {
yakl_throw(
"ERROR: Trying to subset_slowest_dimension an Array that hasn't been initialized"); }
650 if (l < 0) {
yakl_throw(
"ERROR: subset_slowest_dimension lower bound < 0"); }
651 if (u < 0) {
yakl_throw(
"ERROR: subset_slowest_dimension upper bound < 0"); }
652 if (l > u) {
yakl_throw(
"ERROR: subset_slowest_dimension lower bound > upper bounds"); }
653 if (u > this->dimension[0]-1) {
yakl_throw(
"ERROR: subset_slowest_dimension upper bound out of bounds"); }
656 auto &d = this->dimension;
657 if constexpr (rank == 1) ret.myData += l;
658 if constexpr (rank == 2) ret.myData += l*d[1];
659 if constexpr (rank == 3) ret.myData += l*d[1]*d[2];
660 if constexpr (rank == 4) ret.myData += l*d[1]*d[2]*d[3];
661 if constexpr (rank == 5) ret.myData += l*d[1]*d[2]*d[3]*d[4];
662 if constexpr (rank == 6) ret.myData += l*d[1]*d[2]*d[3]*d[4]*d[5];
663 if constexpr (rank == 7) ret.myData += l*d[1]*d[2]*d[3]*d[4]*d[5]*d[6];
664 if constexpr (rank == 8) ret.myData += l*d[1]*d[2]*d[3]*d[4]*d[5]*d[6]*d[7];
665 ret.dimension[0] = u-l+1;
697 if (rank != dims.
size()) {
699 yakl_throw(
"ERROR: slice rank must be equal to dims.size()");
701 for (
int i = rank-1-N; i >= 0; i--) {
702 if (dims.data[i] >= this->dimension[i]) {
704 yakl_throw(
"ERROR: One of the slicing dimension dimensions is out of bounds");
707 if (! this->initialized()) {
709 yakl_throw(
"ERROR: calling slice() on an Array that hasn't been allocated");
714 for (
int i = rank-1; i > rank-1-N; i--) {
715 ret.dimension[i-(rank-N)] = this->dimension[i];
716 offset *= this->dimension[i];
719 for (
int i = rank-1-N; i >= 0; i--) {
720 retOff += dims.data[i]*offset;
721 offset *= this->dimension[i];
723 ret.myData = &(this->myData[retOff]);
726 ret.refCount = this->refCount;
727 if (this->refCount !=
nullptr) {
728 (*(this->refCount))++;
737 static_assert( rank == 1 ,
"ERROR: Calling slice() with 1 index on a non-rank-1 array" );
738 static_assert( N <= rank ,
"ERROR: Calling slice() with more dimenions than this array's rank" );
739 return slice<N>(
Dims(i0) );
744 static_assert( rank == 2 ,
"ERROR: Calling slice() with 2 index on a non-rank-2 array" );
745 static_assert( N <= rank ,
"ERROR: Calling slice() with more dimenions than this array's rank" );
746 return slice<N>(
Dims(i0,i1) );
751 static_assert( rank == 3 ,
"ERROR: Calling slice() with 3 index on a non-rank-3 array" );
752 static_assert( N <= rank ,
"ERROR: Calling slice() with more dimenions than this array's rank" );
753 return slice<N>(
Dims(i0,i1,i2) );
758 static_assert( rank == 4 ,
"ERROR: Calling slice() with 4 index on a non-rank-4 array" );
759 static_assert( N <= rank ,
"ERROR: Calling slice() with more dimenions than this array's rank" );
760 return slice<N>(
Dims(i0,i1,i2,i3) );
765 static_assert( rank == 5 ,
"ERROR: Calling slice() with 5 index on a non-rank-5 array" );
766 static_assert( N <= rank ,
"ERROR: Calling slice() with more dimenions than this array's rank" );
767 return slice<N>(
Dims(i0,i1,i2,i3,i4) );
772 static_assert( rank == 6 ,
"ERROR: Calling slice() with 6 index on a non-rank-6 array" );
773 static_assert( N <= rank ,
"ERROR: Calling slice() with more dimenions than this array's rank" );
774 return slice<N>(
Dims(i0,i1,i2,i3,i4,i5) );
780 static_assert( rank == 7 ,
"ERROR: Calling slice() with 7 index on a non-rank-7 array" );
781 static_assert( N <= rank ,
"ERROR: Calling slice() with more dimenions than this array's rank" );
782 return slice<N>(
Dims(i0,i1,i2,i3,i4,i5,i6) );
786 template <
int N>
YAKL_INLINE Array<T,N,myMem,styleC> slice(
int i0,
int i1,
int i2,
int i3,
int i4,
int i5,
int i6,
788 static_assert( rank == 8 ,
"ERROR: Calling slice() with 8 index on a non-rank-8 array" );
789 static_assert( N <= rank ,
"ERROR: Calling slice() with more dimenions than this array's rank" );
790 return slice<N>(
Dims(i0,i1,i2,i3,i4,i5,i6,i7) );
822 if (! this->initialized()) {
yakl_throw(
"ERROR: Trying to reshape an Array that hasn't been initialized"); }
823 if (dims.
size() != N) {
yakl_throw(
"ERROR: new number of reshaped array dimensions does not match the templated rank"); }
825 for (
int i=0; i < N; i++) { totelems *= dims.data[i]; }
826 if (totelems != this->totElems()) {
yakl_throw(
"ERROR: Total number of reshaped array elements is not consistent with this array"); }
829 for (
int i=0; i < N; i++) {
830 ret.dimension[i] = dims.data[i];
833 ret.myname = this->myname;
835 ret.myData = this->myData;
838 ret.refCount = this->refCount;
839 if (this->refCount !=
nullptr) {
840 (*(this->refCount))++;
860 YAKL_INLINE Array<T,5,myMem,styleC> reshape(
index_t i0,
index_t i1,
index_t i2,
index_t i3,
index_t i4 )
const {
return reshape<5>(
Dims(i0,i1,i2,i3,i4) ); }
863 YAKL_INLINE Array<T,6,myMem,styleC> reshape(
index_t i0,
index_t i1,
index_t i2,
index_t i3,
index_t i4,
index_t i5 )
const {
return reshape<6>(
Dims(i0,i1,i2,i3,i4,i5) ); }
866 YAKL_INLINE Array<T,7,myMem,styleC> reshape(
index_t i0,
index_t i1,
index_t i2,
index_t i3,
index_t i4,
index_t i5,
index_t i6 )
const {
return reshape<7>(
Dims(i0,i1,i2,i3,i4,i5,i6) ); }
869 YAKL_INLINE Array<T,8,myMem,styleC> reshape(
index_t i0,
index_t i1,
index_t i2,
index_t i3,
index_t i4,
index_t i5,
index_t i6,
index_t i7)
const {
return reshape<8>(
Dims(i0,i1,i2,i3,i4,i5,i6,i7) ); }
886 if (! this->initialized()) {
yakl_throw(
"ERROR: Trying to collapse an Array that hasn't been initialized"); }
889 ret.dimension[0] = this->totElems();
891 ret.myname = this->myname;
893 ret.myData = this->myData;
896 ret.refCount = this->refCount;
897 if (this->refCount !=
nullptr) {
898 (*(this->refCount))++;
919 template <
class TLOC=T>
921 auto ret = createHostObject();
922 this->copy_inform(ret);
925 if (stream.is_default_stream()) {
fence(); }
926 else { stream.fence(); }
938 template <class TLOC=typename std::remove_cv<T>::type>
941 if (! this->initialized()) {
943 yakl_throw(
"Error: createHostObject() called on an Array that hasn't been allocated");
948 for (
int i=0; i<rank; i++) { ret.dimension[i] = this->dimension[i]; }
950 ret.myname = this->myname;
970 template <
class TLOC=T>
972 auto ret = createDeviceObject();
973 this->copy_inform(ret);
976 if (stream.is_default_stream()) {
fence(); }
977 else { stream.fence(); }
989 template <class TLOC=typename std::remove_cv<T>::type>
992 if (! this->initialized()) {
994 yakl_throw(
"Error: createDeviceObject() called on an Array that hasn't been allocated.");
999 for (
int i=0; i<rank; i++) { ret.dimension[i] = this->dimension[i]; }
1001 ret.myname = this->myname;
1014 for (
int i=0; i<rank; i++) { ret(i) = this->dimension[i]; }
1022 for (
int i=0; i<rank; i++) { ret(i) = 0; }
1030 for (
int i=0; i<rank; i++) { ret(i) = this->dimension[i]-1; }
1038 if (dim < 0 || dim > rank-1)
yakl_throw(
"ERROR: calling extent() with an out of bounds index");
1040 return this->dimension[dim];
YAKL_INLINE Array(char const *label, index_t d1, index_t d2)
2-D owned constructor
Definition: YAKL_CArray.h:124
YAKL_INLINE T & operator()(index_t i0, index_t i1, index_t i2, index_t i3, index_t i4, index_t i5, index_t i6, index_t i7) const
Return reference to element at the requested indices (8-D)
Definition: YAKL_CArray.h:556
YAKL_INLINE SArray< index_t, 1, rank > get_dimensions() const
Returns the dimensions of this array as a yakl::SArray object.
Definition: YAKL_CArray.h:1012
#define YAKL_EXECUTE_ON_DEVICE_ONLY(...)
[NOT COMMONLY USED] Macro function used to determine if the current code is compiling for the device.
Definition: YAKL_defines.h:158
constexpr int memDevice
Specifies a device memory address space for a yakl::Array object.
Definition: YAKL_memory_spaces.h:13
std::add_const< type >::type const_value_type
This is the type T with const added to it.
Definition: YAKL_CArray.h:64
YAKL_INLINE T & operator()(index_t i0) const
Return reference to element at the requested index (1-D)
Definition: YAKL_CArray.h:471
constexpr int MEMORY_SHARED
Declares that the data pointer is defined in both host and device memory.
Definition: ArrayIR.h:18
YAKL_INLINE Array(char const *label, T *data, index_t const d1, index_t const d2, index_t const d3, index_t const d4, index_t const d5, index_t const d6)
6-D non-owned constructor
Definition: YAKL_CArray.h:266
YAKL_INLINE Array< T, N, myMem, styleC > slice(int i0, int i1, int i2, int i3) const
Array slice of 4-D array.
Definition: YAKL_CArray.h:757
This implements the yakl:Array class with yakl::styleC behavior.
Definition: YAKL_CArray.h:55
YAKL_INLINE Array(char const *label, index_t d1, index_t d2, index_t d3, index_t d4, index_t d5)
5-D owned constructor
Definition: YAKL_CArray.h:145
YAKL_INLINE Array< T, 3, myMem, styleC > reshape(index_t i0, index_t i1, index_t i2) const
Reshape array into a 3-D array.
Definition: YAKL_CArray.h:854
Implements the functionality of a stream for parallel kernel execution. If the Stream::create() metho...
Definition: YAKL_streams_events.h:394
YAKL_INLINE Array< T, 1, myMem, styleC > reshape(index_t i0) const
Reshape array into a 1-D array.
Definition: YAKL_CArray.h:848
YAKL_INLINE Array & operator=(Array< non_const_value_type, rank, myMem, styleC > const &rhs)
Copy metadata, share data pointer; if owned, increment reference counter. No deep copy.
Definition: YAKL_CArray.h:334
YAKL_INLINE T & operator()(index_t i0, index_t i1, index_t i2, index_t i3) const
Return reference to element at the requested indices (4-D)
Definition: YAKL_CArray.h:502
YAKL_INLINE Array()
Create an empty, unallocated object.
Definition: YAKL_CArray.h:85
YAKL_INLINE T & operator()(index_t i0, index_t i1, index_t i2, index_t i3, index_t i4, index_t i5) const
Return reference to element at the requested indices (6-D)
Definition: YAKL_CArray.h:527
std::remove_const< type >::type non_const_value_type
This is the type T with const removed from it.
Definition: YAKL_CArray.h:67
YAKL_INLINE ~Array()
If owned, decrement reference counter, and deallocate data when it reaches zero. If non-owned,...
Definition: YAKL_CArray.h:422
std::remove_cv< T >::type type
This is the type T without const and volatile modifiers.
Definition: YAKL_CArray.h:59
Array< typename std::remove_cv< TLOC >::type, rank, memDevice, styleC > createDeviceObject() const
Create and allocate a yakl::memDevice array object of the same type, rank, dimensions,...
Definition: YAKL_CArray.h:990
YAKL_INLINE Array< T, N, myMem, styleC > slice(int i0, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const
Array slice of 8-D array.
Definition: YAKL_CArray.h:786
Array operator=(TLOC const &rhs) const
[ASYNCHRONOUS] Assign a scalar arithmetic value to all entries in this array object
Definition: YAKL_CArray.h:618
YAKL_INLINE Array(char const *label, T *data, index_t const d1, index_t const d2, index_t const d3, index_t const d4, index_t const d5, index_t const d6, index_t const d7, index_t const d8)
8-D non-owned constructor
Definition: YAKL_CArray.h:287
YAKL_INLINE SArray< index_t, 1, rank > get_ubounds() const
Returns the upper bound of each dimension of this array as a yakl::SArray object.
Definition: YAKL_CArray.h:1028
YAKL_INLINE Array(char const *label, Dims const dims)
Generic initializer-list or std::vector based owned constructor.
Definition: YAKL_CArray.h:187
Array< TLOC, rank, memDevice, styleC > createDeviceCopy(Stream stream=Stream()) const
[DEEP_COPY] Create a copy of this array in yakl::memDevice space
Definition: YAKL_CArray.h:971
YAKL_INLINE T & operator()(index_t i0, index_t i1) const
Return reference to element at the requested indices (2-D)
Definition: YAKL_CArray.h:481
#define __YAKL_NAMESPACE_WRAPPER_END__
Definition: YAKL.h:20
constexpr int MEMORY_HOST
Declares that the data pointer is defined only in host memory.
Definition: ArrayIR.h:14
void memcpy_host_to_device(T1 *dst, T2 *src, index_t elems, Stream stream=Stream())
[USE AT YOUR OWN RISK]: memcpy the specified number of elements from host to device
Definition: YAKL_mem_transfers.h:85
YAKL_INLINE Array(char const *label, index_t d1, index_t d2, index_t d3, index_t d4)
4-D owned constructor
Definition: YAKL_CArray.h:137
YAKL_INLINE Array(char const *label, T *data, index_t const d1, index_t const d2, index_t const d3, index_t const d4)
4-D non-owned constructor
Definition: YAKL_CArray.h:249
YAKL_INLINE T & operator()(index_t i0, index_t i1, index_t i2, index_t i3, index_t i4, index_t i5, index_t i6) const
Return reference to element at the requested indices (7-D)
Definition: YAKL_CArray.h:541
YAKL_INLINE Array< T, N, myMem, styleC > slice(int i0, int i1, int i2, int i3, int i4, int i5) const
Array slice of 6-D array.
Definition: YAKL_CArray.h:771
YAKL_INLINE Array(char const *label, T *data, index_t const d1, index_t const d2, index_t const d3, index_t const d4, index_t const d5, index_t const d6, index_t const d7)
7-D non-owned constructor
Definition: YAKL_CArray.h:276
YAKL_INLINE Array< T, N, myMem, styleC > slice(int i0) const
Array slice of 1-D array.
Definition: YAKL_CArray.h:736
constexpr int MEMORY_DEVICE
Declares that the data pointer is defined only in device memory.
Definition: ArrayIR.h:16
YAKL_INLINE SArray< index_t, 1, rank > get_lbounds() const
Returns the lower bound of each dimension of this array (which are always all zero) as a yakl::SArray...
Definition: YAKL_CArray.h:1020
YAKL_INLINE T & operator()(index_t i0, index_t i1, index_t i2) const
Return reference to element at the requested indices (3-D)
Definition: YAKL_CArray.h:491
YAKL_INLINE Array & operator=(Array< const_value_type, rank, myMem, styleC > const &rhs)
Copy metadata, share data pointer; if owned, increment reference counter. No deep copy.
Definition: YAKL_CArray.h:343
YAKL_INLINE Array & operator=(Array &&rhs)
Move metadata and data pointer. No deep copy.
Definition: YAKL_CArray.h:398
YAKL_INLINE Array(char const *label, T *data, index_t const d1)
1-D non-owned constructor
Definition: YAKL_CArray.h:231
#define __YAKL_NAMESPACE_WRAPPER_BEGIN__
Definition: YAKL.h:19
YAKL_INLINE T & operator()(index_t i0, index_t i1, index_t i2, index_t i3, index_t i4) const
Return reference to element at the requested indices (5-D)
Definition: YAKL_CArray.h:514
YAKL_INLINE Array(char const *label, index_t d1)
1-D owned constructor
Definition: YAKL_CArray.h:119
YAKL_INLINE Array(char const *label, T *data, index_t const d1, index_t const d2, index_t const d3)
3-D non-owned constructor
Definition: YAKL_CArray.h:242
#define YAKL_INLINE
Used to decorate functions called from kernels (parallel_for and parallel_outer) or from CPU function...
Definition: YAKL_defines.h:140
YAKL_INLINE Array< T, 5, myMem, styleC > reshape(index_t i0, index_t i1, index_t i2, index_t i3, index_t i4) const
Reshape array into a 5-D array.
Definition: YAKL_CArray.h:860
YAKL_INLINE Array(char const *label, T *data, index_t const d1, index_t const d2)
2-D non-owned constructor
Definition: YAKL_CArray.h:236
The ArrayIR class holds library-agnostic Array metadata to make it easy to transfer array objects bet...
Definition: ArrayIR.h:39
YAKL_INLINE int size() const
Get the number of dimensions.
Definition: YAKL_Array.h:166
YAKL_INLINE Array(char const *label)
Create an empty, unallocated object with a label.
Definition: YAKL_CArray.h:89
YAKL_INLINE Array(char const *label, index_t d1, index_t d2, index_t d3, index_t d4, index_t d5, index_t d6)
6-D owned constructor
Definition: YAKL_CArray.h:154
void fence()
Block the host code until all device code has completed.
Definition: YAKL_fence.h:16
YAKL_INLINE Array< T, 4, myMem, styleC > reshape(index_t i0, index_t i1, index_t i2, index_t i3) const
Reshape array into a 4-D array.
Definition: YAKL_CArray.h:857
YAKL_INLINE Array(Array &&rhs)
Move metadata and data pointer. No deep copy.
Definition: YAKL_CArray.h:380
YAKL_INLINE Array< T, N, myMem, styleC > reshape(Dims const &dims) const
Reshape array using initializer list or std::vector indices.
Definition: YAKL_CArray.h:820
YAKL_INLINE index_t extent(int dim) const
Returns the extent of the requested dimension of this array.
Definition: YAKL_CArray.h:1036
YAKL_INLINE Array< T, N, myMem, styleC > slice(int i0, int i1, int i2, int i3, int i4, int i5, int i6) const
Array slice of 7-D array.
Definition: YAKL_CArray.h:778
YAKL_INLINE Array(char const *label, T *data, index_t const d1, index_t const d2, index_t const d3, index_t const d4, index_t const d5)
5-D non-owned constructor
Definition: YAKL_CArray.h:257
YAKL_INLINE Array< T, N, myMem, styleC > slice(int i0, int i1, int i2) const
Array slice of 3-D array.
Definition: YAKL_CArray.h:750
#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
unsigned int index_t
Definition: YAKL.h:41
YAKL_INLINE Array< T, rank, myMem, styleC > subset_slowest_dimension(int l, int u) const
Return an array aliasing a contiguous subset of the slowest dimension.
Definition: YAKL_CArray.h:647
YAKL_INLINE Array(Array< const_value_type, rank, myMem, styleC > const &rhs)
Copy metadata, share data pointer; if owned, increment reference counter. No deep copy.
Definition: YAKL_CArray.h:324
YAKL_INLINE void yakl_throw(const char *msg)
Throw an error message. Works from the host or device.
Definition: YAKL_error.h:17
constexpr int styleC
Template parameter for yakl::Array that specifies it should follow C-style behavior.
Definition: YAKL_Array.h:20
void memcpy_host_to_host(T1 *dst, T2 *src, index_t elems)
[USE AT YOUR OWN RISK]: memcpy the specified number of elements on the host
Definition: YAKL_mem_transfers.h:20
const char * label() const
Get the label for this array.
Definition: ArrayIR.h:117
T value_type
This is the type T exactly as it was defined upon array object creation.
Definition: YAKL_CArray.h:61
YAKL_INLINE Array< T, 2, myMem, styleC > reshape(index_t i0, index_t i1) const
Reshape array into a 2-D array.
Definition: YAKL_CArray.h:851
YAKL_INLINE Array< T, N, myMem, styleC > slice(Dims const &dims) const
Array slice using initializer list or std::vector indices.
Definition: YAKL_CArray.h:695
This class holds C-style dimensions for using in yakl::Array objects.
Definition: YAKL_Array.h:50
Array< typename std::remove_cv< TLOC >::type, rank, memHost, styleC > createHostObject() const
Create and allocate a yakl::memHost array object of the same type, rank, dimensions,...
Definition: YAKL_CArray.h:939
YAKL_INLINE Array< T, 6, myMem, styleC > reshape(index_t i0, index_t i1, index_t i2, index_t i3, index_t i4, index_t i5) const
Reshape array into a 6-D array.
Definition: YAKL_CArray.h:863
bool data_valid_on_device() const
Determine if the data pointer is valid on the device.
Definition: ArrayIR.h:127
Array< TLOC, rank, memHost, styleC > createHostCopy(Stream stream=Stream()) const
[DEEP_COPY] Create a copy of this array in yakl::memHost space
Definition: YAKL_CArray.h:920
This declares the yakl::Array class. Please see the yakl::styleC and yakl::styleFortran template spec...
Definition: YAKL_Array.h:40
void memcpy_device_to_device(T1 *dst, T2 *src, index_t elems, Stream stream=Stream())
[USE AT YOUR OWN RISK]: memcpy the specified number of elements on the device
Definition: YAKL_mem_transfers.h:119
C-style array on the stack similar in nature to, e.g., float arr[ny][nx];
Definition: YAKL_CSArray.h:30
YAKL_INLINE Array< T, 7, myMem, styleC > reshape(index_t i0, index_t i1, index_t i2, index_t i3, index_t i4, index_t i5, index_t i6) const
Reshape array into a 7-D array.
Definition: YAKL_CArray.h:866
YAKL_INLINE Array(Array< non_const_value_type, rank, myMem, styleC > const &rhs)
Copy metadata, share data pointer; if owned, increment reference counter. No deep copy.
Definition: YAKL_CArray.h:318
YAKL_INLINE Array(char const *label, T *data, Dims const dims)
Generic initializer-list or std::vector based owned constructor.
Definition: YAKL_CArray.h:299
YAKL_INLINE Array< T, rank, myMem, styleC > subset_slowest_dimension(int u) const
Return an array aliasing a contiguous subset of the slowest dimension. Retuns the same array with the...
Definition: YAKL_CArray.h:643
YAKL_INLINE Array< T, 8, myMem, styleC > reshape(index_t i0, index_t i1, index_t i2, index_t i3, index_t i4, index_t i5, index_t i6, index_t i7) const
Reshape array into a 8-D array.
Definition: YAKL_CArray.h:869
YAKL_INLINE Array< T, N, myMem, styleC > slice(int i0, int i1) const
Array slice of 2-D array.
Definition: YAKL_CArray.h:743
size_t extent(int i) const
Get the extent of the dimension of the provided index.
Definition: ArrayIR.h:108
T * data() const
Get the data pointer.
Definition: ArrayIR.h:102
array_ir::ArrayIR< TLOC, rank > create_ArrayIR() const
Create an ArrayIR object from this CArray object for easy interoperability with other C++ portability...
Definition: YAKL_CArray.h:442
void memcpy_device_to_host(T1 *dst, T2 *src, index_t elems, Stream stream=Stream())
[USE AT YOUR OWN RISK]: memcpy the specified number of elements from device to host
Definition: YAKL_mem_transfers.h:51
Array(array_ir::ArrayIR< T, rank > const &ir)
Construct this CArray object from an ArrayIR object for easy interoperability with other C++ portabil...
Definition: YAKL_CArray.h:428
YAKL_INLINE Array(char const *label, index_t d1, index_t d2, index_t d3)
3-D owned constructor
Definition: YAKL_CArray.h:130
YAKL_INLINE Array< T, 1, myMem, styleC > collapse() const
Collapse this array into a 1-D array.
Definition: YAKL_CArray.h:884
bool data_valid_on_host() const
Determine if the data pointer is valid on the host.
Definition: ArrayIR.h:125
YAKL_INLINE Array(char const *label, index_t d1, index_t d2, index_t d3, index_t d4, index_t d5, index_t d6, index_t d7)
7-D owned constructor
Definition: YAKL_CArray.h:164
YAKL_INLINE Array< T, N, myMem, styleC > slice(int i0, int i1, int i2, int i3, int i4) const
Array slice of 5-D array.
Definition: YAKL_CArray.h:764
This class implements functionality common to both yakl::styleC and yakl::styleFortran Array objects.
Definition: YAKL_ArrayBase.h:24
YAKL_INLINE Array(char const *label, index_t d1, index_t d2, index_t d3, index_t d4, index_t d5, index_t d6, index_t d7, index_t d8)
8-D owned constructor
Definition: YAKL_CArray.h:175
constexpr int memHost
Specifies a device memory address space for a yakl::Array object.
Definition: YAKL_memory_spaces.h:15