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_ref() as the underlying memory resource. | |
| polymorphic_allocator (device_async_resource_ref 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 the underlying memory resource of other. 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... | |
| rmm::device_async_resource_ref | get_upstream_resource () const noexcept |
| rmm::device_async_resource_ref to the upstream 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 device_async_resource_ref.
| mr | The upstream memory resource to use for allocation. |
|
inlinenoexcept |
Construct a polymorphic_allocator using the underlying memory resource of other.
| other | The polymorphic_allocator whose memory 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 memory resource r that compares equal to get_upstream_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 |
rmm::device_async_resource_ref to the upstream resource