Go to the documentation of this file.
38 template <
class T,
int N>
42 std::array<size_t,N> my_dimensions;
43 char const * my_label;
46 void nullify() { my_data =
nullptr; my_label =
nullptr; my_dimensions.fill(0); }
48 void copy_from(
ArrayIR const &rhs) {
49 my_data = rhs.my_data;
50 my_label = rhs.my_label;
51 my_memory_type = rhs.my_memory_type;
52 my_dimensions = rhs.my_dimensions;
55 void error_message(
char const *message)
const {
56 std::cerr <<
"*** ArrayIR class: A FATAL ERROR WAS ENCOUNTERED ***" << std::endl;
57 std::cerr << message << std::endl;
58 throw std::runtime_error(message);
82 my_dimensions = dimensions;
94 bool empty ()
const {
return my_data ==
nullptr; }
96 bool is_empty()
const {
return my_data ==
nullptr; }
102 T *
data ()
const {
return my_data; }
109 if (i < 0 || i > N-1) error_message(
"extent() index out of bounds");
110 return my_dimensions[i];
113 std::array<size_t,N>
shape()
const {
return my_dimensions; }
117 char const *
label ()
const {
return my_label; }
int get_memory_type() const
Get the memory type for this array object (MEMORY_HOST, MEMORY_DEVICE, or MEMORY_SHARED)
Definition: ArrayIR.h:123
constexpr int MEMORY_SHARED
Declares that the data pointer is defined in both host and device memory.
Definition: ArrayIR.h:18
size_t dimension(int i) const
Get the extent of the dimension of the provided index.
Definition: ArrayIR.h:115
ArrayIR & operator=(ArrayIR const &&rhs)
Move constructor.
Definition: ArrayIR.h:91
const char * get_label() const
Get the label for this array.
Definition: ArrayIR.h:119
ArrayIR & operator=(ArrayIR const &rhs)
Copy constructor.
Definition: ArrayIR.h:89
T * get_data_pointer() const
Get the data pointer.
Definition: ArrayIR.h:106
bool is_valid() const
Is this ArrayIR object valid (does it point to something other than nullptr)?
Definition: ArrayIR.h:100
int memory_type() const
Get the memory type for this array object (MEMORY_HOST, MEMORY_DEVICE, or MEMORY_SHARED)
Definition: ArrayIR.h:121
T exact_type
The exact type of this ArrayIR object with all qualifiers.
Definition: ArrayIR.h:64
bool valid() const
Is this ArrayIR object valid (does it point to something other than nullptr)?
Definition: ArrayIR.h:98
constexpr int MEMORY_HOST
Declares that the data pointer is defined only in host memory.
Definition: ArrayIR.h:14
ArrayIR(ArrayIR const &rhs)
Copy constructor.
Definition: ArrayIR.h:85
std::array< size_t, N > shape() const
Get the shape of the array as a std::array<size_t,N>
Definition: ArrayIR.h:113
bool empty() const
Is this ArrayIR object invalid (does it point to nullptr)?
Definition: ArrayIR.h:94
constexpr int MEMORY_DEVICE
Declares that the data pointer is defined only in device memory.
Definition: ArrayIR.h:16
T * get_data() const
Get the data pointer.
Definition: ArrayIR.h:104
~ArrayIR()
Definition: ArrayIR.h:92
The ArrayIR class holds library-agnostic Array metadata to make it easy to transfer array objects bet...
Definition: ArrayIR.h:39
ArrayIR(T *data, std::array< size_t, N > dimensions, int memory_type, char const *label="")
Creates an ArrayIR object with the given data, dimensions, memory type, and optional label.
Definition: ArrayIR.h:78
The ArrayIR namespace holds the ArrayIR class and memory type constants associated with ArrayIR....
Definition: ArrayIR.h:11
ArrayIR(ArrayIR const &&rhs)
Move constructor.
Definition: ArrayIR.h:87
const char * label() const
Get the label for this array.
Definition: ArrayIR.h:117
bool data_valid_on_device() const
Determine if the data pointer is valid on the device.
Definition: ArrayIR.h:127
std::remove_cv< T >::type remove_cv_type
The type of this ArrayIR object with cv qualifiers removed.
Definition: ArrayIR.h:66
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
ArrayIR()
Creates an empty object with nullptr as the data pointer.
Definition: ArrayIR.h:69
bool is_empty() const
Is this ArrayIR object invalid (does it point to nullptr)?
Definition: ArrayIR.h:96
bool data_valid_on_host() const
Determine if the data pointer is valid on the host.
Definition: ArrayIR.h:125