|
HAMR
The Heterogeneous Accelerator Memory Resource
|
A technology agnostic buffer that manages memory on the host, GPUs, and other accelerators. More...
#include <hamr_buffer.h>
Public Types | |
| using | allocator = buffer_allocator |
| using | transfer = buffer_transfer |
Public Member Functions | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync=transfer::async) | |
| buffer (allocator alloc) | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync, size_t n_elem) | |
| buffer (allocator alloc, const hamr::stream &strm, size_t n_elem) | |
| buffer (allocator alloc, size_t n_elem) | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync, size_t n_elem, const T &val) | |
| buffer (allocator alloc, const hamr::stream &strm, size_t n_elem, const T &val) | |
| buffer (allocator alloc, size_t n_elem, const T &val) | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync, size_t n_elem, const T *vals) | |
| buffer (allocator alloc, const hamr::stream &strm, size_t n_elem, const T *vals) | |
| buffer (allocator alloc, size_t n_elem, const T *vals) | |
| template<typename delete_func_t > | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync, size_t size, int owner, T *ptr, delete_func_t df) | |
| template<typename delete_func_t > | |
| buffer (allocator alloc, const hamr::stream &strm, size_t size, int owner, T *ptr, delete_func_t df) | |
| template<typename delete_func_t > | |
| buffer (allocator alloc, size_t size, int owner, T *ptr, delete_func_t df) | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync, size_t size, int owner, T *ptr, int take=1) | |
| buffer (allocator alloc, const hamr::stream &strm, size_t size, int owner, T *ptr) | |
| buffer (allocator alloc, size_t size, int owner, T *ptr) | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync, size_t size, int owner, const std::shared_ptr< T > &data) | |
| buffer (allocator alloc, const hamr::stream &strm, size_t size, int owner, const std::shared_ptr< T > &data) | |
| buffer (allocator alloc, size_t size, int owner, const std::shared_ptr< T > &data) | |
| template<typename U > | |
| buffer (const buffer< U > &other) | |
| copy construct from the passed buffer More... | |
| buffer (const buffer< T > &other) | |
| copy construct from the passed buffer More... | |
| template<typename U > | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync, const buffer< U > &other) | |
| template<typename U > | |
| buffer (allocator alloc, const hamr::stream &strm, const buffer< U > &other) | |
| template<typename U > | |
| buffer (allocator alloc, const buffer< U > &other) | |
| buffer (buffer< T > &&other) | |
| Move construct from the passed buffer. More... | |
| buffer (allocator alloc, const hamr::stream &strm, transfer sync, buffer< T > &&other) | |
| buffer (allocator alloc, const hamr::stream &strm, buffer< T > &&other) | |
| buffer (allocator alloc, buffer< T > &&other) | |
| void | operator= (buffer< T > &&other) |
| template<typename U > | |
| void | operator= (const buffer< U > &other) |
| void | operator= (const buffer< T > &other) |
| void | swap (buffer< T > &other) |
| swap the contents of the two buffers More... | |
| int | move (allocator alloc) |
| int | free () |
| free all internal storage More... | |
| size_t | size () const |
| returns the number of elements of storage allocated to the buffer More... | |
| std::shared_ptr< const T > | get_host_accessible () const |
| int | host_accessible () const |
| returns true if the data is accessible from codes running on the host More... | |
| std::shared_ptr< const T > | get_cuda_accessible () const |
| int | cuda_accessible () const |
| returns true if the data is accessible from CUDA codes More... | |
| std::shared_ptr< const T > | get_hip_accessible () const |
| int | hip_accessible () const |
| returns true if the data is accessible from HIP codes More... | |
| int | openmp_accessible () const |
| returns true if the data is accessible from OpenMP off load codes More... | |
| std::shared_ptr< const T > | get_device_accessible () const |
| int | device_accessible () const |
| allocator | get_allocator () const |
| int | get_owner () const |
| const hamr::stream & | get_stream () const |
| hamr::stream & | get_stream () |
| void | set_stream (const stream &strm, transfer sync=transfer::async) |
| void | set_transfer_asynchronous () |
| void | set_transfer_sycnhronous_host () |
| void | set_transfer_sycnhronous () |
| transfer | get_transfer_mode () const |
| int | synchronize () const |
| int | print () const |
| prints the contents to the stderr stream More... | |
reserve | |
allocates space for n_elems of data | |
| int | reserve (size_t n_elem) |
| int | reserve (size_t n_elem, const T &val) |
| reserve n_elem of memory and initialize them to val More... | |
resize | |
resizes storage for n_elems of data | |
| int | resize (size_t n_elem) |
| int | resize (size_t n_elem, const T &val) |
assign | |
Copies data into the buffer resizing the buffer. | |
| template<typename U > | |
| int | assign (const U *src, size_t src_start, size_t n_vals) |
| template<typename U > | |
| int | assign (const buffer< U > &src, size_t src_start, size_t n_vals) |
| assign the range from the passed buffer More... | |
| template<typename U > | |
| int | assign (const buffer< U > &src) |
| assign the passed buffer More... | |
append | |
insert values at the back of the buffer, growing as needed | |
| template<typename U > | |
| int | append (const U *src, size_t src_start, size_t n_vals) |
| template<typename U > | |
| int | append (const buffer< U > &src, size_t src_start, size_t n_vals) |
| template<typename U > | |
| int | append (const buffer< U > &src) |
set | |
sets a range of elements in the buffer | |
| template<typename U > | |
| int | set (size_t dest_start, const U *src, size_t src_start, size_t n_vals) |
| template<typename U > | |
| int | set (const buffer< U > &src) |
| template<typename U > | |
| int | set (size_t dest_start, const buffer< U > &src, size_t src_start, size_t n_vals) |
get | |
gets a range of values from the buffer | |
| template<typename U > | |
| int | get (size_t src_start, U *dest, size_t dest_start, size_t n_vals) const |
| template<typename U > | |
| int | get (size_t src_start, buffer< U > &dest, size_t dest_start, size_t n_vals) const |
| template<typename U > | |
| int | get (buffer< U > &dest) const |
get_openmp_accessible | |
| |
| std::shared_ptr< const T > | get_openmp_accessible () const |
data | |
| |
| T * | data () |
| const T * | data () const |
| return a const pointer to the buffer contents More... | |
pointer | |
| |
| std::shared_ptr< T > & | pointer () |
| const std::shared_ptr< T > & | pointer () const |
Protected Member Functions | |
| int | reserve_for_append (size_t n_vals) |
| grow the buffer if needed. doubles in size More... | |
| std::shared_ptr< T > | allocate (size_t n_elem) |
| allocate space for n_elem More... | |
| std::shared_ptr< T > | allocate (size_t n_elem, const T &val) |
| allocate space for n_elem initialized to val More... | |
| template<typename U > | |
| std::shared_ptr< T > | allocate (size_t n_elem, const U *vals) |
| allocate space for n_elem initialized with an array of values More... | |
| template<typename U > | |
| std::shared_ptr< T > | allocate (const buffer< U > &vals) |
| allocate space for n_elem initialized with an array of values More... | |
| int | set_owner () |
| int | set_owner (const T *ptr) |
| int | get_active_device (int &dev_id) |
| get the active device id associated with the current allocator More... | |
A technology agnostic buffer that manages memory on the host, GPUs, and other accelerators.
The buffer mediates between different accelerator and platform portability technologies' memory models. Examples of platform portability technologies are HIP, OpenMP, OpenCL, SYCL, and Kokos, Examples of accelerator technologies are CUDA and ROCm. Other accelerator and platform portability technologies exist and can be supported. Data can be left in place until it is consumed. The consumer of the data can get a pointer that is accessible in the technology that will be used to process the data. If the data is already accessible in that technology access is a NOOP, otherwise the data will be moved such that it is accessible. Smart pointers take care of destruction of temporary buffers if needed.
| using hamr::buffer< T >::allocator = buffer_allocator |
An enumeration for the type of allocator to use for memory allocations. See buffer_allocator.
| using hamr::buffer< T >::transfer = buffer_transfer |
An enumeration for the types of transfer supported. See buffer_transfer
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync = transfer::async |
||
| ) |
Construct an empty buffer.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
|
inline |
Construct an empty buffer. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync, | ||
| size_t | n_elem | ||
| ) |
Construct a buffer with storage allocated but unitialized.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
| [in] | n_elem | the initial size of the new buffer |
|
inline |
Construct a buffer configured for asynchronous data transfers, with storage allocated, but unitialized.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | n_elem | the initial size of the new buffer |
|
inline |
Construct a buffer with storage allocated but unitialized. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | n_elem | the initial size of the new buffer |
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync, | ||
| size_t | n_elem, | ||
| const T & | val | ||
| ) |
Construct a buffer with storage allocated and initialized to a single value.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
| [in] | n_elem | the initial size of the new buffer |
| [in] | val | an single value used to initialize the buffer contents |
|
inline |
Construct a buffer configured for asynchronous data movement, with storage allocated, and initialized to a single value.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | n_elem | the initial size of the new buffer |
| [in] | val | an single value used to initialize the buffer contents |
|
inline |
Construct a buffer with storage allocated and initialized to a single value. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host. For fully asynchronous data transfers one must explicitly prtovide a stream and specify the asynchronous mode.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | n_elem | the initial size of the new buffer |
| [in] | val | an single value used to initialize the buffer contents |
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync, | ||
| size_t | n_elem, | ||
| const T * | vals | ||
| ) |
Construct a buffer with storage allocated and initialized to the array of values. This array is always assumed to be accessible on the host. Use one of the zero-copy constructors if the data is already accessible on the device.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
| [in] | n_elem | the initial size of the new buffer and number of elements in the array pointed to by vals |
| [in] | vals | an array of values accessible on the host used to initialize the buffer contents |
|
inline |
Construct a buffer configured for asynchronous data movement, with storage allocated, and initialized to the array of values. This array is always assumed to be accessible on the host. Use one of the zero-copy constructors if the data is already accessible on the device.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | n_elem | the initial size of the new buffer and number of elements in the array pointed to by vals |
| [in] | vals | an array of values accessible on the host used to initialize the buffer contents |
|
inline |
Construct a buffer with storage allocated and initialized to the array of values. This array is always assumed to be accessible on the host. Use one of the zero-copy constructors if the data is already accessible on the device. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | n_elem | the initial size of the new buffer and number of elements in the array pointed to by vals |
| [in] | vals | an array of values accessible on the host used to initialize the buffer contents |
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync, | ||
| size_t | size, | ||
| int | owner, | ||
| T * | ptr, | ||
| delete_func_t | df | ||
| ) |
Construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | ptr | a pointer to the array |
| [in] | df | a function void df(void*ptr) used to delete the array when this instance is finished. |
|
inline |
Construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers. The buffer is configured for asynchronous data transfers.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | strm | a ::stream object used to order operations |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | ptr | a pointer to the array |
| [in] | df | a function void df(void*ptr) used to delete the array when this instance is finished. |
|
inline |
Construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | ptr | a pointer to the array |
| [in] | df | a function void df(void*ptr) used to delete the array when this instance is finished. |
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync, | ||
| size_t | size, | ||
| int | owner, | ||
| T * | ptr, | ||
| int | take = 1 |
||
| ) |
Construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers. The pass buffer_allocator is used to create the deleter that will be called when this instance is finished with the memeory. Use this constructor to transfer ownership of the array.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | ptr | a pointer to the array |
| [in] | take | set non-zero if the buffer should delete the passed memory using the named allocator |
|
inline |
Construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers. The pass buffer_allocator is used to create the deleter that will be called when this instance is finished with the memeory. Use this constructor to transfer ownership of the array. The buffer is configured for asynchronous data transfers.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | strm | a ::stream object used to order operations |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | ptr | a pointer to the array |
|
inline |
construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers. The pass buffer_allocator is used to create the deleter that will be called when this instance is finished with the memeory. Use this constructor to transfer ownership of the array. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | ptr | a pointer to the array |
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync, | ||
| size_t | size, | ||
| int | owner, | ||
| const std::shared_ptr< T > & | data | ||
| ) |
Construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | data | a shared pointer managing the data |
|
inline |
Construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers. The buffer is configured for asynchronous data transfers.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | strm | a ::stream object used to order operations |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | data | a shared pointer managing the data |
|
inline |
Construct by directly providing the buffer contents. This can be used for zero-copy transfer of data. One must also name the allocator type and device owning the data. In addition for new allocations the allocator type and owner are used internally to know how to automatically move data during inter technology transfers. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host.
| [in] | alloc | a buffer_allocator indicating the technology backing the pointer |
| [in] | size | the number of elements in the array pointed to by ptr |
| [in] | owner | the device owning the memory, -1 for host. if the allocator is a GPU allocator and -1 is passed the driver API is used to determine the device that allocated the memory. |
| [in] | data | a shared pointer managing the data |
copy construct from the passed buffer
| hamr::buffer< T >::buffer | ( | const buffer< T > & | other | ) |
copy construct from the passed buffer
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync, | ||
| const buffer< U > & | other | ||
| ) |
Copy construct from the passed buffer, while specifying a potentially different allocator, stream, and synchronization behavior.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
|
inline |
Copy construct from the passed buffer, while specifying a potentially different allocator, stream, and synchronization behavior. The buffer is configured for asynchronous data transfers.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
|
inline |
Copy construct from the passed buffer, while specifying a potentially different allocator, stream, and synchronization behavior. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
| hamr::buffer< T >::buffer | ( | buffer< T > && | other | ) |
Move construct from the passed buffer.
| hamr::buffer< T >::buffer | ( | allocator | alloc, |
| const hamr::stream & | strm, | ||
| transfer | sync, | ||
| buffer< T > && | other | ||
| ) |
Move construct from the passed buffer, while specifying a potentially different allocator, owner, stream, and synchronization behavior. The move occurs only if the allocators and owners match, otherwise a copy is made. For non-host allocators, the active device is used to set the owner of the new object prior to the atempted move.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
|
inline |
Move construct from the passed buffer, while specifying a potentially different allocator, owner, stream, and synchronization behavior. The move occurs only if the allocators and owners match, otherwise a copy is made. For non-host allocators, the active device is used to set the owner of the new object prior to the atempted move. The buffer is configured for asynchronous data transfers.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
| [in] | strm | a ::stream object used to order operations |
|
inline |
Move construct from the passed buffer, while specifying a potentially different allocator, owner, stream, and synchronization behavior. The move occurs only if the allocators and owners match, otherwise a copy is made. For non-host allocators, the active device is used to set the owner of the new object prior to the atempted move. This constructor will result in the default stream for the chosen technology with transfer::sync_host mode which synchronizes after data movement from a device to the host.
| [in] | alloc | a buffer_allocator indicates what technology manages the data internally |
|
protected |
allocate space for n_elem initialized with an array of values
|
protected |
allocate space for n_elem
|
protected |
allocate space for n_elem initialized to val
|
protected |
allocate space for n_elem initialized with an array of values
| int hamr::buffer< T >::append | ( | const buffer< U > & | src | ) |
appends to the end of the buffer, extending the buffer as needed.
| int hamr::buffer< T >::append | ( | const buffer< U > & | src, |
| size_t | src_start, | ||
| size_t | n_vals | ||
| ) |
appends n_vals from src starting at src_start to the end of the buffer, extending the buffer as needed.
| int hamr::buffer< T >::append | ( | const U * | src, |
| size_t | src_start, | ||
| size_t | n_vals | ||
| ) |
appends n_vals from src starting at src_start to the end of the buffer, extending the buffer as needed. (src is always on the host)
| int hamr::buffer< T >::assign | ( | const buffer< U > & | src | ) |
assign the passed buffer
| int hamr::buffer< T >::assign | ( | const buffer< U > & | src, |
| size_t | src_start, | ||
| size_t | n_vals | ||
| ) |
assign the range from the passed buffer
| int hamr::buffer< T >::assign | ( | const U * | src, |
| size_t | src_start, | ||
| size_t | n_vals | ||
| ) |
assign the range from the passed array (src is always on the host)
| int hamr::buffer< T >::cuda_accessible |
returns true if the data is accessible from CUDA codes
|
inline |
return a pointer to the buffer contents
|
inline |
return a const pointer to the buffer contents
| int hamr::buffer< T >::device_accessible |
returns true if the data is accessible from device codes using the technology most suitable with the current build configuration.
| int hamr::buffer< T >::free |
free all internal storage
|
inline |
gets n_vals elements starting at src_start into the passed buffer's elements starting at dest_start
| int hamr::buffer< T >::get | ( | size_t | src_start, |
| buffer< U > & | dest, | ||
| size_t | dest_start, | ||
| size_t | n_vals | ||
| ) | const |
gets n_vals elements starting at src_start into the passed buffer's elements starting at dest_start
| int hamr::buffer< T >::get | ( | size_t | src_start, |
| U * | dest, | ||
| size_t | dest_start, | ||
| size_t | n_vals | ||
| ) | const |
gets n_vals elements starting at src_start into the passed array elements starting at dest_start (dest is always on the host)
|
protected |
get the active device id associated with the current allocator
|
inline |
| std::shared_ptr< const T > hamr::buffer< T >::get_cuda_accessible |
| std::shared_ptr< const T > hamr::buffer< T >::get_device_accessible |
| std::shared_ptr< const T > hamr::buffer< T >::get_hip_accessible |
| std::shared_ptr< const T > hamr::buffer< T >::get_host_accessible |
| std::shared_ptr< const T > hamr::buffer< T >::get_openmp_accessible |
returns a pointer to the contents of the buffer accessible from within OpenMP off load
|
inline |
|
inline |
|
inline |
| int hamr::buffer< T >::hip_accessible |
returns true if the data is accessible from HIP codes
| int hamr::buffer< T >::host_accessible |
returns true if the data is accessible from codes running on the host
| int hamr::buffer< T >::move | ( | allocator | alloc | ) |
This is used to change the location of the buffer contents in place. For GPU based allocators, the new allocation is made on the device active at the time the call is made. If the new allocator and owner are the same as the current allocator and owner, then the call is a NOOP. Otherwise the data is reallocated and moved.
| [in] | alloc | the new allocator |
| int hamr::buffer< T >::openmp_accessible |
returns true if the data is accessible from OpenMP off load codes
| void hamr::buffer< T >::operator= | ( | buffer< T > && | other | ) |
move assign from the other buffer. The target buffer's allocator, stream, and device transfer mode are preserved. if this and the passed buffer have the same type, allocator, and owner the passed buffer is moved. If this and the passed buffer have different allocators or owners this allocator is used to allocate space and the data will be copied. if this and the passed buffer have different types elements are cast to this type as they are copied.
| void hamr::buffer< T >::operator= | ( | const buffer< U > & | other | ) |
Allocate space and copy the contents of another buffer. The allocator, owner, stream, and sychronization mode of the receiving object are unmodified by this operation. Thus one may move data around the system using copy assignment.
|
inline |
|
inline |
| int hamr::buffer< T >::print |
prints the contents to the stderr stream
| int hamr::buffer< T >::reserve | ( | size_t | n_elem | ) |
reserve n_elem of memory
| int hamr::buffer< T >::reserve | ( | size_t | n_elem, |
| const T & | val | ||
| ) |
reserve n_elem of memory and initialize them to val
|
protected |
grow the buffer if needed. doubles in size
| int hamr::buffer< T >::resize | ( | size_t | n_elem | ) |
resize the buffer to hold n_elem of memory
| int hamr::buffer< T >::resize | ( | size_t | n_elem, |
| const T & | val | ||
| ) |
resize the buffer to hold n_elem of memory and initialize new elements to val
|
inline |
sets n_vals elements starting at dest_start from the passed buffer's elements starting at src_start
| int hamr::buffer< T >::set | ( | size_t | dest_start, |
| const buffer< U > & | src, | ||
| size_t | src_start, | ||
| size_t | n_vals | ||
| ) |
sets n_vals elements starting at dest_start from the passed buffer's elements starting at src_start
| int hamr::buffer< T >::set | ( | size_t | dest_start, |
| const U * | src, | ||
| size_t | src_start, | ||
| size_t | n_vals | ||
| ) |
sets n_vals elements starting at dest_start from the passed buffer's elements starting at src_start (src is always on the host)
|
protected |
set the device where the buffer is located to the active device or the host. The allocator is used to determine which.
|
protected |
set the device where the buffer is located by querying the driver API or the host. The allocator is used to determine which.
|
inline |
Sets the active stream and data transfer synchrnonization mode. See buffer_transfer.
| [in] | strm | a ::stream object used to order operations |
| [in] | sync | a buffer_transfer specifies synchronous or asynchronous behavior. |
|
inline |
Set the transfer mode to asynchronous. One must manually synchronize before data access when needed. See synchronize
|
inline |
Set the transfer mode to synchronize every data transfer. This mode should not be used except for debugging.
|
inline |
Set the transfer mode to synchronize automatically after data movement from the GPU to the host.
|
inline |
returns the number of elements of storage allocated to the buffer
| void hamr::buffer< T >::swap | ( | buffer< T > & | other | ) |
swap the contents of the two buffers
| int hamr::buffer< T >::synchronize |
synchronizes with the current stream. This ensures that asynchronous data transfers have completed before you access the data.