Classes | Public Types | Public Member Functions | 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 >
 
using pointer = typename Base::pointer
 
using size_type = typename Base::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, device_memory_resource *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...
 
device_memory_resourceresource () const noexcept
 Returns the device memory resource used by this allocator.
 
cuda_stream_view stream () const noexcept
 Returns the stream used by this allocator.
 

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,
device_memory_resource 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

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