SENSEI
A frame work for generic in situ analytics
|
An accelerator aware container for array based data. More...
#include <svtkHAMRDataArray.h>
Public Member Functions | |
svtkTypeMacro (svtkHAMRDataArray, svtkDataArray) | |
void | PrintSelf (ostream &os, svtkIndent indent) override |
template<typename deleter_t > | |
svtkHAMRDataArray< T > * | New (const std::string &name, T *data, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode streamMode, int owner, deleter_t deleter) |
zero-copy data transfer | |
void | SetData (T *data, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode streamMode, int owner) |
zero-copy the passed data. More... | |
void | SetData (const std::shared_ptr< T > &data, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode, int owner) |
zero-copy the passed data. More... | |
template<typename deleter_t > | |
void | SetData (T *dataPtr, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode, int owner, deleter_t deleter) |
zero-copy the passed data. More... | |
location agnostic access | |
std::shared_ptr< const T > | GetHostAccessible () const |
std::shared_ptr< const T > | GetDeviceAccessible () const |
std::shared_ptr< const T > | GetCUDAAccessible () const |
std::shared_ptr< const T > | GetHIPAccessible () const |
std::shared_ptr< const T > | GetOpenMPAccessible () const |
direct access | |
T * | GetData () |
fast access to the internally managed memory. More... | |
std::shared_ptr< T > | GetDataPointer () |
fast access to the internally managed memory. More... | |
device location | |
int | GetOwner () const |
get the device where the memory was allocated. More... | |
void | SetOwner () |
Set the device id that owns the memory to the currently aactive device. More... | |
void | SetAllocator (svtkAllocator alloc) |
Sets or changes the allocator used to manage the menory, this may move the data from one device to another. More... | |
svtkAllocator | GetAllocator () |
bool | HostAccessible () |
return true if a pooniter to the data is safe to use on the Host More... | |
bool | CUDAAccessible () |
return true if a pooniter to the data is safe to use with CUDA More... | |
bool | HIPAccessible () |
returns a pointer to the data that is safe to use with HIP More... | |
bool | OpenMPAccessible () |
return true if a pooniter to the data is safe to use with OpenMP device off load More... | |
synchronization | |
void | SetStream (const svtkStream &stream, svtkStreamMode &mode) |
sets the stream. mode indicate synchronous behavior or not. More... | |
svtkStream & | GetStream () |
const svtkStream & | GetStream () const |
void | Synchronize () const |
synchronizes on the internal stream More... | |
modify the size of the array | |
svtkIdType | GetNumberOfValues () const override |
returns the number of values. this is the current size, not the capacity. More... | |
void | SetNumberOfTuples (svtkIdType numTuples) override |
sets the current size and may change the capacity of the array More... | |
void | SetNumberOfTuples (svtkIdType numTuples, svtkAllocator alloc) |
svtkTypeBool | Resize (svtkIdType numTuples) override |
resize the container using the current allocator More... | |
conversions | |
svtkAOSDataArrayTemplate< T > * | AsSvtkAOSDataArray (int zeroCopy) |
Convert to an svtkAOSDataArrayTemplate instance. More... | |
Static Public Member Functions | |
construct uninitialized | |
static svtkHAMRDataArray * | New () |
construct a new instance that is uninitiazed. More... | |
copy construct | |
static svtkHAMRDataArray * | New (svtkDataArray *da) |
copy construct from the passed instance. More... | |
static svtkHAMRDataArray * | New (svtkDataArray *da, svtkAllocator alloc, svtkStream stream, svtkStreamMode streamMode) |
copy construct from the passed instance. More... | |
zero-copy construct | |
static svtkHAMRDataArray * | New (const std::string &name, T *data, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode streamMode, int owner, int take) |
zero-copy the passed data. More... | |
static svtkHAMRDataArray * | New (const std::string &name, const std::shared_ptr< T > &data, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode streamMode, int owner) |
zero-copy the passed data. More... | |
template<typename deleter_t > | |
static svtkHAMRDataArray * | New (const std::string &name, T *data, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode streamMode, int owner, deleter_t deleter) |
zero-copy the passed data. More... | |
construct and allocate | |
static svtkHAMRDataArray * | New (const std::string &name, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode streamMode) |
Allocate a new array of the specified size using the specified allocator. More... | |
static svtkHAMRDataArray * | New (const std::string &name, size_t numTuples, int numComps, svtkAllocator alloc, svtkStream stream, svtkStreamMode streamMode, const T &initVal) |
Allocate a new array of the specified size using the specified allocator initialized to the specified value. More... | |
Friends | |
template<typename U > | |
class | svtkHAMRDataArray |
An accelerator aware container for array based data.
The svtkHAMRDataArray can be used to allocate and manage data on the host and on accelerators. The purpose of the container is to pass data in between simulation and analysis codes in a platform portable, programming model portable, efficient manner.
Data can be allocated on the host or a specific accelerator. See ::New overloads in the "construct and allocate" group.
Data can be explicitly moved between devices and between the host and any device. See ::SetAllocator.
Zero-copy tansfer of device memory is supported, see ::New overloads in the "zero-copy construct" group for zero-copy construction and ::SetData overloads in the "zero-copy data transfer" group.
When consuming data passed from an unknown sorce, accessibility methods can be used to access the data on the host or desired device. These may move the data to the requested device or the host. Data movement is only done if the data is not in the reqeusted location. Smart pointers are used to automate and hide the details from the caller. See ::GetHostAccessible, ::GetDeviceAccessible and programming model specific overloads ::GetCUDAAccessible, ::GetHIPAccessible, and ::GetOpenMPAccessible.
When one knows where data resides direct access methods provide access to the raw pointers. See ::GetData and ::GetPointer.
By default all operations including allocations, and data movement, are asynchronous. Care must be taken before accessing the data to be sure outstanding operations have been completed. See ::Synchronize.
svtkAOSDataArrayTemplate< T > * svtkHAMRDataArray< T >::AsSvtkAOSDataArray | ( | int | zeroCopy | ) |
Convert to an svtkAOSDataArrayTemplate instance.
Because SVTK only supports host based data, a deep-copy is made when this array is located on the GPU. Otherwise the data is passed via zero-copy
[in] | zeroCopy | if true and the data resides on the host, the data is passed to the new svtkAOSDataArrayTemplate instance by zero-copy. Otehrwise a deep-copy is made. |
|
inline |
return true if a pooniter to the data is safe to use with CUDA
|
inline |
|
inline |
|
inline |
fast access to the internally managed memory.
Use this only when you know where the data resides and will access it in that location. This method saves the cost of a smart_ptr copy construct and the cost of the logic that determines if a temporary is needed. For all other cases use GetXAccessible to access the data.
|
inline |
fast access to the internally managed memory.
Use this only when you know where the data resides and will access it in that location. This method saves the cost of the logic determining if a temporary is needed. For all other cases use GetXAccessible to access the data.
|
inline |
|
inline |
|
inline |
|
inlineoverride |
returns the number of values. this is the current size, not the capacity.
|
inline |
|
inline |
get the device where the memory was allocated.
|
inline |
|
inline |
returns a pointer to the data that is safe to use with HIP
|
inline |
return true if a pooniter to the data is safe to use on the Host
|
static |
construct a new instance that is uninitiazed.
Before use call ::SetAllocator (and optionally ::SetStream), and either ::SetData or some combination of ::SetNumberOfTuples, ::SetNumberOfComponents, and/or ::Resize.
|
static |
copy construct from the passed instance.
this is a deep copy.
[in] | da | the array to deep copy. |
|
static |
copy construct from the passed instance.
this is a deep copy. if the allocator is a device allocator the memory is allocated on the active device.
[in] | da | the array to deep copy. |
[in] | alloc | the allocator to use to allocate memory for the copy |
[in] | stream | the stream to make the allocation and copy on |
[in] | streamMode | the sychnronization behavior of the container. |
|
static |
zero-copy the passed data.
[in] | name | the name of the array |
[in] | data | a pointer to the data |
[in] | numTuples | the number of data tuples |
[in] | numComps | the numper of components per tuple |
[in] | alloc | an ::svtkAllocator instance declaring where the data resides |
[in] | stream | an ::svtkStream instance providing an ordering on operations |
[in] | streamMode | an ::svtkStreamMode instance declaring synchronous behavior or not |
[in] | owner | the device id where the data resides, or -1 for the host |
[in] | take | if true the pointed to data will be released using the deleter associated with the declared ::svtkAllocator alloc |
|
static |
zero-copy the passed data.
This override gives one direct control over the management and reference counting of the pointed to data.
[in] | name | the name of the array |
[in] | data | a smart pointer that manages the pointed to data |
[in] | numTuples | the number of data tuples |
[in] | numComps | the numper of components per tuple |
[in] | alloc | an ::svtkAllocator instance declaring where the data resides |
[in] | stream | an ::svtkStream instance providing an ordering on operations |
[in] | streamMode | an ::svtkStreamMode instance declaring synchronous behavior or not |
[in] | owner | the device id where the data resides, or -1 for the host |
|
static |
zero-copy the passed data.
This override gives one direct control over the method that is used to release the pointed to array.
[in] | name | the name of the array |
[in] | data | a smart pointer that manages the pointed to data |
[in] | numTuples | the number of data tuples |
[in] | numComps | the numper of components per tuple |
[in] | alloc | an ::svtkAllocator instance declaring where the data resides |
[in] | stream | an ::svtkStream instance providing an ordering on operations |
[in] | streamMode | an ::svtkStreamMode instance declaring synchronous behavior or not |
[in] | owner | the device id where the data resides, or -1 for the host |
|
static |
Allocate a new array of the specified size using the specified allocator.
[in] | name | the name of the array |
[in] | numTuples | the number of data tuples |
[in] | numComps | the numper of components per tuple |
[in] | alloc | an ::svtkAllocator instance declaring where the data resides |
[in] | stream | an ::svtkStream instance providing an ordering on operations |
[in] | streamMode | an ::svtkStreamMode instance declaring synchronous behavior or not |
|
static |
Allocate a new array of the specified size using the specified allocator initialized to the specified value.
[in] | name | the name of the array |
[in] | numTuples | the number of data tuples |
[in] | numComps | the numper of components per tuple |
[in] | alloc | an ::svtkAllocator instance declaring where the data resides |
[in] | stream | an ::svtkStream instance providing an ordering on operations |
[in] | streamMode | an ::svtkStreamMode instance declaring synchronous behavior or not |
[in] | initVal | the value to initialize the contents to |
|
inline |
return true if a pooniter to the data is safe to use with OpenMP device off load
|
override |
resize the container using the current allocator
|
inline |
Sets or changes the allocator used to manage the menory, this may move the data from one device to another.
void svtkHAMRDataArray< T >::SetData | ( | T * | data, |
size_t | numTuples, | ||
int | numComps, | ||
svtkAllocator | alloc, | ||
svtkStream | stream, | ||
svtkStreamMode | streamMode, | ||
int | owner | ||
) |
zero-copy the passed data.
the allocator is used to tell where the data resides. the callee (array instance) takes ownership of the pointer.
void svtkHAMRDataArray< T >::SetData | ( | const std::shared_ptr< T > & | data, |
size_t | numTuples, | ||
int | numComps, | ||
svtkAllocator | alloc, | ||
svtkStream | stream, | ||
svtkStreamMode | streamMode, | ||
int | owner | ||
) |
zero-copy the passed data.
the allocator is used to tell where the data resides.
void svtkHAMRDataArray< T >::SetData | ( | T * | dataPtr, |
size_t | numTuples, | ||
int | numComps, | ||
svtkAllocator | alloc, | ||
svtkStream | stream, | ||
svtkStreamMode | streamMode, | ||
int | owner, | ||
deleter_t | deleter | ||
) |
zero-copy the passed data.
the allocator is used to tell where the data resides the deleter will be called as void deleter(void *dataPtr) when the data is no longer needed
|
override |
sets the current size and may change the capacity of the array
|
inline |
Set the device id that owns the memory to the currently aactive device.
this may be used to move the data from one device to another.
|
inline |
sets the stream. mode indicate synchronous behavior or not.
|
inline |
synchronizes on the internal stream