YAKL
|
Fortran-style array on the stack similar in nature to, e.g., float arr[ny][nx];
More...
#include <YAKL_FSArray.h>
Public Types | |
typedef 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). More... | |
typedef 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 type). More... | |
typedef std::remove_cv< T >::type | type |
This is the type T without const and volatile modifiers. More... | |
typedef T | value_type |
This is the type T exactly as it was defined upon array object creation. More... | |
Public Member Functions | |
FSArray ()=default | |
YAKL_INLINE | FSArray (T init_fill) |
No constructor arguments allowed. More... | |
~FSArray ()=default | |
YAKL_INLINE T * | begin () const |
Returns pointer to beginning of the data. More... | |
YAKL_INLINE T * | data () const |
Get the underlying raw data pointer. More... | |
YAKL_INLINE T * | end () const |
Returns pointer to end of the data. More... | |
YAKL_INLINE T * | get_data () const |
Get the underlying raw data pointer. More... | |
YAKL_INLINE FSArray< int, 1, SB< rank > > | get_dimensions () const |
Returns the dimensions of this array as a yakl::FSArray object. More... | |
YAKL_INLINE FSArray< int, 1, SB< rank > > | get_lbounds () const |
Returns the lower bound of each dimension of this array as a yakl::FSArray object. More... | |
YAKL_INLINE FSArray< int, 1, SB< rank > > | get_ubounds () const |
Returns the upper bound of each dimension of this array as a yakl::FSArray object. More... | |
YAKL_INLINE T & | operator() (int const i0) const |
Returns a reference to the indexed element (1-D). More... | |
YAKL_INLINE T & | operator() (int const i0, int const i1) const |
Returns a reference to the indexed element (2-D). More... | |
YAKL_INLINE T & | operator() (int const i0, int const i1, int const i2) const |
Returns a reference to the indexed element (3-D). More... | |
YAKL_INLINE T & | operator() (int const i0, int const i1, int const i2, int const i3) const |
Returns a reference to the indexed element (4-D). More... | |
template<class TLOC , typename std::enable_if< std::is_arithmetic< TLOC >::value, int >::type = 0> | |
YAKL_INLINE void | operator= (TLOC val) |
Assign a single arithmetic value to the entire array. More... | |
Static Public Member Functions | |
static constexpr unsigned | get_elem_count () |
Get the total number of array elements. More... | |
static constexpr unsigned | get_rank () |
Get the number of dimensions. More... | |
static constexpr unsigned | get_totElems () |
Get the total number of array elements. More... | |
static constexpr bool | initialized () |
Always true. yakl::SArray objects are by default always initialized / allocated. More... | |
static constexpr unsigned | size () |
Get the total number of array elements. More... | |
static constexpr bool | span_is_contiguous () |
Always true. All YAKL arrays are contiguous with no padding. More... | |
static constexpr unsigned | totElems () |
Get the total number of array elements. More... | |
Static Public Attributes | |
static constexpr unsigned | OFF3 = D0*D1*D2 |
Friends | |
std::ostream & | operator<< (std::ostream &os, FSArray const &v) |
Print out the contents of this array. This should be called only from the host. More... | |
Fortran-style array on the stack similar in nature to, e.g., float arr[ny][nx];
This creates a Fortran-style "Stack Array" (FSArray) class. It should be thought of as similar in nature to a C-style multi-dimensional array, float arr[n1][n2][n3];
, except that it uses column-majore index ordering (left-most index varies the fastest), and it has lower bounds that default to 1
but can also be arbitrary. An example of declaring a yakl:FSArray object is yakl::FSArray<float,3,SB<n1>,SB<0,n2+1>,SB<n3>> arr;
The syntax is a bit ugly, but it's necessary to allow lower bounds other than 1
. The array declared just now will have lower bounds of 1, 0, and 1, respectively, and upper bounds of n1, n2+1, n3, respectively. For bounds checking, define the CPP macro YAKL_DEBUG
. Dimensions sizes must be known at compile time, and data is placed on the stack of whatever context it is declared. When declared in a device parallel_for
kernel, it is a thread-private array, meaning every thread has a separate copy of the array.
T | Type of the yakl::FSArray object |
rank | Number of dimensions |
B[0-3] | Bounds for each dimensions specified using a yakl::SB class. B1, B2, and B3 are optional template parameters. Each yakl::SB object can take one or two template parameters. Specifying only one template parameter assumes a lower bound of 1 . Specifying two template parameters gives the lower and upper bound (inclusive). |
Creating these arrays is very cheap, but copying them does a deep copy every time and can be expensive. Remember that yakl::FSArray objects use column-major index ordering, meaning the left-most index varies the fastest.
typedef std::add_const<type>::type yakl::FSArray< T, rank, B0, B1, B2, B3 >::const_value_type |
This is the type T
with const
added to it (if the original type has volatile
, then so will this type).
typedef std::remove_const<type>::type yakl::FSArray< T, rank, B0, B1, B2, B3 >::non_const_value_type |
This is the type T
with const
removed from it (if the original type has volatile
, then so will this type).
typedef std::remove_cv<T>::type yakl::FSArray< T, rank, B0, B1, B2, B3 >::type |
This is the type T
without const
and volatile
modifiers.
typedef T yakl::FSArray< T, rank, B0, B1, B2, B3 >::value_type |
This is the type T
exactly as it was defined upon array object creation.
|
inline |
No constructor arguments allowed.
|
default |
|
default |
|
inline |
Returns pointer to beginning of the data.
|
inline |
Get the underlying raw data pointer.
|
inline |
Returns pointer to end of the data.
|
inline |
Get the underlying raw data pointer.
|
inline |
Returns the dimensions of this array as a yakl::FSArray object.
You should use one-based indexing on the returned yakl::FSArray object.
|
inlinestaticconstexpr |
Get the total number of array elements.
|
inline |
Returns the lower bound of each dimension of this array as a yakl::FSArray object.
You should use one-based indexing on the returned yakl::FSArray object.
|
inlinestaticconstexpr |
Get the number of dimensions.
|
inlinestaticconstexpr |
Get the total number of array elements.
|
inline |
Returns the upper bound of each dimension of this array as a yakl::FSArray object.
You should use one-based indexing on the returned yakl::FSArray object.
|
inlinestaticconstexpr |
Always true. yakl::SArray objects are by default always initialized / allocated.
|
inline |
Returns a reference to the indexed element (1-D).
Number of indices must match the rank of the array object. For bounds checking, define the CPP macro YAKL_DEBUG
. Always use one-based indexing (unless the dimension has non-default bounds) with column-major ordering (left-most index varying the fastest).
|
inline |
Returns a reference to the indexed element (2-D).
Number of indices must match the rank of the array object. For bounds checking, define the CPP macro YAKL_DEBUG
. Always use one-based indexing (unless the dimension has non-default bounds) with column-major ordering (left-most index varying the fastest).
|
inline |
Returns a reference to the indexed element (3-D).
Number of indices must match the rank of the array object. For bounds checking, define the CPP macro YAKL_DEBUG
. Always use one-based indexing (unless the dimension has non-default bounds) with column-major ordering (left-most index varying the fastest).
|
inline |
Returns a reference to the indexed element (4-D).
Number of indices must match the rank of the array object. For bounds checking, define the CPP macro YAKL_DEBUG
. Always use one-based indexing (unless the dimension has non-default bounds) with column-major ordering (left-most index varying the fastest).
|
inline |
Assign a single arithmetic value to the entire array.
|
inlinestaticconstexpr |
Get the total number of array elements.
|
inlinestaticconstexpr |
Always true. All YAKL arrays are contiguous with no padding.
|
inlinestaticconstexpr |
Get the total number of array elements.
|
friend |
Print out the contents of this array. This should be called only from the host.
|
staticconstexpr |