YAKL
Public Types | Public Member Functions | List of all members
array_ir::ArrayIR< T, N > Class Template Reference

The ArrayIR class holds library-agnostic Array metadata to make it easy to transfer array objects between different C++ libraries. More...

#include <ArrayIR.h>

Public Types

typedef T exact_type
 The exact type of this ArrayIR object with all qualifiers. More...
 
typedef std::remove_cv< T >::type remove_cv_type
 The type of this ArrayIR object with cv qualifiers removed. More...
 

Public Member Functions

 ArrayIR ()
 Creates an empty object with nullptr as the data pointer. More...
 
 ArrayIR (ArrayIR const &&rhs)
 Move constructor. More...
 
 ArrayIR (ArrayIR const &rhs)
 Copy constructor. More...
 
 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. More...
 
 ~ArrayIR ()
 
T * data () const
 Get the data pointer. More...
 
bool data_valid_on_device () const
 Determine if the data pointer is valid on the device. More...
 
bool data_valid_on_host () const
 Determine if the data pointer is valid on the host. More...
 
size_t dimension (int i) const
 Get the extent of the dimension of the provided index. More...
 
bool empty () const
 Is this ArrayIR object invalid (does it point to nullptr)? More...
 
size_t extent (int i) const
 Get the extent of the dimension of the provided index. More...
 
T * get_data () const
 Get the data pointer. More...
 
T * get_data_pointer () const
 Get the data pointer. More...
 
const char * get_label () const
 Get the label for this array. More...
 
int get_memory_type () const
 Get the memory type for this array object (MEMORY_HOST, MEMORY_DEVICE, or MEMORY_SHARED) More...
 
bool is_empty () const
 Is this ArrayIR object invalid (does it point to nullptr)? More...
 
bool is_valid () const
 Is this ArrayIR object valid (does it point to something other than nullptr)? More...
 
const char * label () const
 Get the label for this array. More...
 
int memory_type () const
 Get the memory type for this array object (MEMORY_HOST, MEMORY_DEVICE, or MEMORY_SHARED) More...
 
ArrayIRoperator= (ArrayIR const &&rhs)
 Move constructor. More...
 
ArrayIRoperator= (ArrayIR const &rhs)
 Copy constructor. More...
 
std::array< size_t, N > shape () const
 Get the shape of the array as a std::array<size_t,N> More...
 
bool valid () const
 Is this ArrayIR object valid (does it point to something other than nullptr)? More...
 

Detailed Description

template<class T, int N>
class array_ir::ArrayIR< T, N >

The ArrayIR class holds library-agnostic Array metadata to make it easy to transfer array objects between different C++ libraries.

This holds intermediate representation of Array information for transformation between C++ portability libraries ArrayIR is only valid on the host and cannot be used directly in kernels. Please transform to your portability library's Array representation first, and then use that inside kernels. ArrayIR pointers are always assumed to point to contiguous data Dimensions passed to the constructor and accessed via extent() are always assumed to have the right-most dimension varying the fastest. You purposefully cannot use an operator() to get the data because you should only be using this class to transfer Array metadata from one C++ portability framework to another. The ArrayIR is completely un-owned, and it is up to the user to ensure data described by an ArrayIR object remains valid while being used by another portability framework.

Parameters
TThe type of the array
NThe rank (dimensionality) of the array

Member Typedef Documentation

◆ exact_type

template<class T , int N>
typedef T array_ir::ArrayIR< T, N >::exact_type

The exact type of this ArrayIR object with all qualifiers.

◆ remove_cv_type

template<class T , int N>
typedef std::remove_cv<T>::type array_ir::ArrayIR< T, N >::remove_cv_type

The type of this ArrayIR object with cv qualifiers removed.

Constructor & Destructor Documentation

◆ ArrayIR() [1/4]

template<class T , int N>
array_ir::ArrayIR< T, N >::ArrayIR ( )
inline

Creates an empty object with nullptr as the data pointer.

◆ ArrayIR() [2/4]

template<class T , int N>
array_ir::ArrayIR< T, N >::ArrayIR ( T *  data,
std::array< size_t, N >  dimensions,
int  memory_type,
char const *  label = "" 
)
inline

Creates an ArrayIR object with the given data, dimensions, memory type, and optional label.

Parameters
dataThe data pointer
dimensionsDimensions with right-most varying the fastest. Initializer lists are allowed
memory_typearray_ir::MEMORY_HOST if the data is valid only on the host. array_ir::MEMORY_DEVICE if the data is valid only on the device. array_ir::MEMORY_SHARED if the data is valid on both host and device.
labelOptional label parameter for debugging and such things.

◆ ArrayIR() [3/4]

template<class T , int N>
array_ir::ArrayIR< T, N >::ArrayIR ( ArrayIR< T, N > const &  rhs)
inline

Copy constructor.

◆ ArrayIR() [4/4]

template<class T , int N>
array_ir::ArrayIR< T, N >::ArrayIR ( ArrayIR< T, N > const &&  rhs)
inline

Move constructor.

◆ ~ArrayIR()

template<class T , int N>
array_ir::ArrayIR< T, N >::~ArrayIR ( )
inline

Member Function Documentation

◆ data()

template<class T , int N>
T* array_ir::ArrayIR< T, N >::data ( ) const
inline

Get the data pointer.

◆ data_valid_on_device()

template<class T , int N>
bool array_ir::ArrayIR< T, N >::data_valid_on_device ( ) const
inline

Determine if the data pointer is valid on the device.

◆ data_valid_on_host()

template<class T , int N>
bool array_ir::ArrayIR< T, N >::data_valid_on_host ( ) const
inline

Determine if the data pointer is valid on the host.

◆ dimension()

template<class T , int N>
size_t array_ir::ArrayIR< T, N >::dimension ( int  i) const
inline

Get the extent of the dimension of the provided index.

◆ empty()

template<class T , int N>
bool array_ir::ArrayIR< T, N >::empty ( ) const
inline

Is this ArrayIR object invalid (does it point to nullptr)?

◆ extent()

template<class T , int N>
size_t array_ir::ArrayIR< T, N >::extent ( int  i) const
inline

Get the extent of the dimension of the provided index.

◆ get_data()

template<class T , int N>
T* array_ir::ArrayIR< T, N >::get_data ( ) const
inline

Get the data pointer.

◆ get_data_pointer()

template<class T , int N>
T* array_ir::ArrayIR< T, N >::get_data_pointer ( ) const
inline

Get the data pointer.

◆ get_label()

template<class T , int N>
const char* array_ir::ArrayIR< T, N >::get_label ( ) const
inline

Get the label for this array.

◆ get_memory_type()

template<class T , int N>
int array_ir::ArrayIR< T, N >::get_memory_type ( ) const
inline

Get the memory type for this array object (MEMORY_HOST, MEMORY_DEVICE, or MEMORY_SHARED)

◆ is_empty()

template<class T , int N>
bool array_ir::ArrayIR< T, N >::is_empty ( ) const
inline

Is this ArrayIR object invalid (does it point to nullptr)?

◆ is_valid()

template<class T , int N>
bool array_ir::ArrayIR< T, N >::is_valid ( ) const
inline

Is this ArrayIR object valid (does it point to something other than nullptr)?

◆ label()

template<class T , int N>
const char* array_ir::ArrayIR< T, N >::label ( ) const
inline

Get the label for this array.

◆ memory_type()

template<class T , int N>
int array_ir::ArrayIR< T, N >::memory_type ( ) const
inline

Get the memory type for this array object (MEMORY_HOST, MEMORY_DEVICE, or MEMORY_SHARED)

◆ operator=() [1/2]

template<class T , int N>
ArrayIR& array_ir::ArrayIR< T, N >::operator= ( ArrayIR< T, N > const &&  rhs)
inline

Move constructor.

◆ operator=() [2/2]

template<class T , int N>
ArrayIR& array_ir::ArrayIR< T, N >::operator= ( ArrayIR< T, N > const &  rhs)
inline

Copy constructor.

◆ shape()

template<class T , int N>
std::array<size_t,N> array_ir::ArrayIR< T, N >::shape ( ) const
inline

Get the shape of the array as a std::array<size_t,N>

◆ valid()

template<class T , int N>
bool array_ir::ArrayIR< T, N >::valid ( ) const
inline

Is this ArrayIR object valid (does it point to something other than nullptr)?


The documentation for this class was generated from the following file: