RMM
23.12
RAPIDS Memory Manager
|
A stream ordered Allocator using a rmm::mr::device_memory_resource
to satisfy (de)allocations.
More...
#include <polymorphic_allocator.hpp>
Public Types | |
using | value_type = T |
T, the value type of objects allocated by this allocator. | |
Public Member Functions | |
polymorphic_allocator ()=default | |
Construct a polymorphic_allocator using the return value of rmm::mr::get_current_device_resource() as the underlying memory resource. | |
polymorphic_allocator (device_memory_resource *mr) | |
Construct a polymorphic_allocator using the provided memory resource. More... | |
template<typename U > | |
polymorphic_allocator (polymorphic_allocator< U > const &other) noexcept | |
Construct a polymorphic_allocator using other.resource() as the underlying memory resource. More... | |
value_type * | allocate (std::size_t num, cuda_stream_view stream) |
Allocates storage for num objects of type T using the underlying memory resource. More... | |
void | deallocate (value_type *ptr, std::size_t num, cuda_stream_view stream) |
Deallocates storage pointed to by ptr . More... | |
device_memory_resource * | resource () const noexcept |
Returns pointer to the underlying rmm::mr::device_memory_resource . More... | |
A stream ordered Allocator using a rmm::mr::device_memory_resource
to satisfy (de)allocations.
Similar to std::pmr::polymorphic_allocator
, uses the runtime polymorphism of device_memory_resource
to allow containers with polymorphic_allocator
as their static allocator type to be interoperable, but exhibit different behavior depending on resource used.
Unlike STL allocators, polymorphic_allocator
's allocate
and deallocate
functions are stream ordered. Use stream_allocator_adaptor
to allow interoperability with interfaces that require standard, non stream-ordered Allocator
interfaces.
T | The allocators value type. |
|
inline |
Construct a polymorphic_allocator
using the provided memory resource.
This constructor provides an implicit conversion from memory_resource*
.
mr | The device_memory_resource to use as the underlying resource. |
|
inlinenoexcept |
Construct a polymorphic_allocator
using other.resource()
as the underlying memory resource.
other | The polymorphic_resource whose resource() will be used as the underlying resource of the new polymorphic_allocator . |
|
inline |
Allocates storage for num
objects of type T
using the underlying memory resource.
num | The number of objects to allocate storage for |
stream | The stream on which to perform the allocation |
|
inline |
Deallocates storage pointed to by ptr
.
ptr
must have been allocated from a rmm::mr::device_memory_resource
r
that compares equal to *resource()
using r.allocate(n * sizeof(T))
.
ptr | Pointer to memory to deallocate |
num | Number of objects originally allocated |
stream | Stream on which to perform the deallocation |
|
inlinenoexcept |
Returns pointer to the underlying rmm::mr::device_memory_resource
.