RMM  23.12
RAPIDS Memory Manager
Classes | Public Types | Public Member Functions | Friends | List of all members
rmm::mr::thrust_allocator< T > Class Template Reference

An allocator compatible with Thrust containers and algorithms using a device_memory_resource for memory (de)allocation. More...

#include <thrust_allocator_adaptor.hpp>

Inheritance diagram for rmm::mr::thrust_allocator< T >:
Inheritance graph
[legend]
Collaboration diagram for rmm::mr::thrust_allocator< T >:
Collaboration graph
[legend]

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, 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)
 Deallocates objects of type T More...
 
async_resource_ref memory_resource () const noexcept
 The async_resource_ref used to allocate and deallocate. 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...
 

Detailed Description

template<typename T>
class rmm::mr::thrust_allocator< T >

An allocator compatible with Thrust containers and algorithms using a device_memory_resource for memory (de)allocation.

Unlike a device_memory_resource, thrust_allocator is typed and bound to allocate objects of a specific type T, but can be freely rebound to other types.

Template Parameters
TThe type of the objects that will be allocated by this allocator

Constructor & Destructor Documentation

◆ thrust_allocator() [1/3]

template<typename T >
rmm::mr::thrust_allocator< T >::thrust_allocator ( cuda_stream_view  stream)
inlineexplicit

Constructs a thrust_allocator using the default device memory resource and specified stream.

Parameters
streamThe stream to be used for device memory (de)allocation

◆ thrust_allocator() [2/3]

template<typename T >
rmm::mr::thrust_allocator< T >::thrust_allocator ( cuda_stream_view  stream,
async_resource_ref  mr 
)
inline

Constructs a thrust_allocator using a device memory resource and stream.

Parameters
mrThe resource to be used for device memory allocation
streamThe stream to be used for device memory (de)allocation

◆ thrust_allocator() [3/3]

template<typename T >
template<typename U >
rmm::mr::thrust_allocator< T >::thrust_allocator ( thrust_allocator< U > const &  other)
inline

Copy constructor. Copies the resource pointer and stream.

Parameters
otherThe thrust_allocator to copy

Member Function Documentation

◆ allocate()

template<typename T >
pointer rmm::mr::thrust_allocator< T >::allocate ( size_type  num)
inline

Allocate objects of type T

Parameters
numThe number of elements of type T to allocate
Returns
pointer Pointer to the newly allocated storage

◆ deallocate()

template<typename T >
void rmm::mr::thrust_allocator< T >::deallocate ( pointer  ptr,
size_type  num 
)
inline

Deallocates objects of type T

Parameters
ptrPointer returned by a previous call to allocate
numnumber of elements, must be equal to the argument passed to the prior allocate call that produced p

◆ memory_resource()

template<typename T >
async_resource_ref rmm::mr::thrust_allocator< T >::memory_resource ( ) const
inlinenoexcept

The async_resource_ref used to allocate and deallocate.

Returns
The async_resource_ref used to allocate and deallocate

◆ stream()

template<typename T >
cuda_stream_view rmm::mr::thrust_allocator< T >::stream ( ) const
inlinenoexcept

The stream used by this allocator.

Returns
The stream used by this allocator

Friends And Related Function Documentation

◆ get_property

template<typename T >
void get_property ( thrust_allocator< T > const &  ,
cuda::mr::device_accessible   
)
friend

Enables the cuda::mr::device_accessible property.

This property declares that a thrust_allocator provides device accessible memory


The documentation for this class was generated from the following file: