An allocator compatible with Thrust containers and algorithms using a device_async_resource_ref for memory (de)allocation.
More...
#include <thrust_allocator_adaptor.hpp>


Classes | |
| struct | rebind |
Provides the type of a thrust_allocator instantiated with another type. More... | |
Public Types | |
| using | Base = thrust::device_malloc_allocator< T > |
| The base type of this allocator. | |
| using | pointer = typename Base::pointer |
| The pointer type. | |
| using | size_type = typename Base::size_type |
| The size type. | |
Public Member Functions | |
| thrust_allocator ()=default | |
| Default constructor creates an allocator using the default memory resource and default stream. | |
| thrust_allocator (cuda_stream_view stream) | |
Constructs a thrust_allocator using the default device memory resource and specified stream. More... | |
| thrust_allocator (cuda_stream_view stream, rmm::device_async_resource_ref mr) | |
Constructs a thrust_allocator using a device memory resource and stream. More... | |
| template<typename U > | |
| thrust_allocator (thrust_allocator< U > const &other) | |
| Copy constructor. Copies the resource pointer and stream. More... | |
| pointer | allocate (size_type num) |
Allocate objects of type T More... | |
| void | deallocate (pointer ptr, size_type num) noexcept |
Deallocates objects of type T More... | |
| rmm::device_async_resource_ref | get_upstream_resource () const noexcept |
| rmm::device_async_resource_ref to the upstream resource More... | |
| cuda_stream_view | stream () const noexcept |
| The stream used by this allocator. More... | |
Friends | |
| void | get_property (thrust_allocator const &, cuda::mr::device_accessible) noexcept |
Enables the cuda::mr::device_accessible property. More... | |
An allocator compatible with Thrust containers and algorithms using a device_async_resource_ref for memory (de)allocation.
Unlike a device_async_resource_ref, thrust_allocator is typed and bound to allocate objects of a specific type T, but can be freely rebound to other types.
The allocator records the current cuda device and may only be used with a backing device_async_resource_ref valid for the same device.
| T | The type of the objects that will be allocated by this allocator |
|
inlineexplicit |
Constructs a thrust_allocator using the default device memory resource and specified stream.
| stream | The stream to be used for device memory (de)allocation |
|
inline |
Constructs a thrust_allocator using a device memory resource and stream.
| mr | The resource to be used for device memory allocation |
| stream | The stream to be used for device memory (de)allocation |
|
inline |
Copy constructor. Copies the resource pointer and stream.
| other | The thrust_allocator to copy |
|
inline |
Allocate objects of type T
| num | The number of elements of type T to allocate |
|
inlinenoexcept |
Deallocates objects of type T
| ptr | Pointer returned by a previous call to allocate |
| num | number of elements, must be equal to the argument passed to the prior allocate call that produced p |
|
inlinenoexcept |
rmm::device_async_resource_ref to the upstream resource
|
inlinenoexcept |
The stream used by this allocator.
|
friend |
Enables the cuda::mr::device_accessible property.
This property declares that a thrust_allocator provides device accessible memory