![]() |
Taskflow
3.2.0-Master-Branch
|
class to create a unified shared memory (USM) allocator More...
#include <cuda_memory.hpp>
Classes | |
| struct | rebind |
its member type U is the equivalent allocator type to allocate elements of type U More... | |
Public Types | |
| using | value_type = T |
| element type | |
| using | pointer = T * |
| element pointer type | |
| using | reference = T & |
| element reference type | |
| using | const_pointer = const T * |
| const element pointer type | |
| using | const_reference = const T & |
| constant element reference type | |
| using | size_type = std::size_t |
| size type | |
| using | difference_type = std::ptrdiff_t |
| pointer difference type | |
Public Member Functions | |
| cudaUSMAllocator () noexcept | |
| Constructs a device allocator object. | |
| cudaUSMAllocator (const cudaUSMAllocator &) noexcept | |
| Constructs a device allocator object from another device allocator object. | |
| template<typename U > | |
| cudaUSMAllocator (const cudaUSMAllocator< U > &) noexcept | |
| Constructs a device allocator object from another device allocator object with a different element type. | |
| ~cudaUSMAllocator () noexcept | |
| Destructs the device allocator object. | |
| pointer | address (reference x) |
| Returns the address of x. | |
| const_pointer | address (const_reference x) const |
| Returns the address of x. | |
| pointer | allocate (size_type n, std::allocator< void >::const_pointer=0) |
| allocates block of storage. | |
| void | deallocate (pointer ptr, size_type) |
| Releases a block of storage previously allocated with member allocate and not yet released. | |
| size_type | max_size () const noexcept |
| returns the maximum number of elements that could potentially be allocated by this allocator | |
| void | construct (pointer ptr, const_reference val) |
| Constructs an element object on the location pointed by ptr. | |
| void | destroy (pointer ptr) |
destroys in-place the object pointed by ptr | |
| template<typename U > | |
| bool | operator== (const cudaUSMAllocator< U > &) const noexcept |
compares two allocator of different types using == | |
| template<typename U > | |
| bool | operator!= (const cudaUSMAllocator< U > &) const noexcept |
compares two allocator of different types using != | |
class to create a unified shared memory (USM) allocator
| T | element type |
A cudaUSMAllocator enables using unified shared memory (USM) allocation for standard library containers. It is typically passed as template parameter when declaring standard library containers (e.g. std::vector).
|
inline |
Returns the address of x.
This effectively means returning &x.
| x | reference to an object |
|
inline |
Returns the address of x.
This effectively means returning &x.
| x | reference to an object |
|
inline |
allocates block of storage.
Attempts to allocate a block of storage with a size large enough to contain n elements of member type, value_type, and returns a pointer to the first element.
The storage is aligned appropriately for object of type value_type, but they are not constructed.
The block of storage is allocated using cudaMalloc and throws std::bad_alloc if it cannot allocate the total amount of storage requested.
| n | number of elements (each of size sizeof(value_type)) to be allocated |
|
inline |
Constructs an element object on the location pointed by ptr.
| ptr | pointer to a location with enough storage soace to contain an element of type value_type |
| val | value to initialize the constructed element to |
|
inline |
Releases a block of storage previously allocated with member allocate and not yet released.
The elements in the array are not destroyed by a call to this member function.
| ptr | pointer to a block of storage previously allocated with allocate |
|
inline |
destroys in-place the object pointed by ptr
Notice that this does not deallocate the storage for the element but calls its destructor.
| ptr | pointer to the object to be destroye |
|
inlinenoexcept |
returns the maximum number of elements that could potentially be allocated by this allocator
A call to member allocate with the value returned by this function can still fail to allocate the requested storage.
|
inlinenoexcept |
compares two allocator of different types using !=
USM allocators of different types are always equal to each other because the storage allocated by the allocator a1 can be deallocated through a2.
|
inlinenoexcept |
compares two allocator of different types using ==
USM allocators of different types are always equal to each other because the storage allocated by the allocator a1 can be deallocated through a2.