RMM
23.12
RAPIDS Memory Manager
|
Adapts a stream ordered allocator to provide a standard Allocator
interface.
More...
#include <polymorphic_allocator.hpp>
Classes | |
struct | rebind |
Rebinds the allocator to the specified type. More... | |
Public Types | |
using | value_type = typename std::allocator_traits< Allocator >::value_type |
Public Member Functions | |
stream_allocator_adaptor (Allocator const &allocator, cuda_stream_view stream) | |
Construct a stream_allocator_adaptor using a as the underlying allocator. More... | |
template<typename OtherAllocator > | |
stream_allocator_adaptor (stream_allocator_adaptor< OtherAllocator > const &other) | |
Construct a stream_allocator_adaptor using other.underlying_allocator() and other.stream() as the underlying allocator and stream. More... | |
value_type * | allocate (std::size_t num) |
Allocates storage for num objects of type T using the underlying allocator on stream() . More... | |
void | deallocate (value_type *ptr, std::size_t num) |
Deallocates storage pointed to by ptr using the underlying allocator on stream() . More... | |
cuda_stream_view | stream () const noexcept |
The stream on which calls to the underlying allocator are made. More... | |
Allocator | underlying_allocator () const noexcept |
The underlying allocator. More... | |
Adapts a stream ordered allocator to provide a standard Allocator
interface.
A stream-ordered allocator (i.e., allocate/deallocate
use a cuda_stream_view
) cannot be used in an interface that expects a standard C++ Allocator
interface. stream_allocator_adaptor
wraps a stream-ordered allocator and a stream to provide a standard Allocator
interface. The adaptor uses the wrapped stream in calls to the underlying allocator's allocate
and deallocate
functions.
Example:
Allocator | Stream ordered allocator type to adapt |
using rmm::mr::stream_allocator_adaptor< Allocator >::value_type = typename std::allocator_traits<Allocator>::value_type |
The value type of objects allocated by this allocator
|
inline |
Construct a stream_allocator_adaptor
using a
as the underlying allocator.
stream
must not be destroyed before the stream_allocator_adaptor
, otherwise behavior is undefined.allocator | The stream ordered allocator to use as the underlying allocator |
stream | The stream used with the underlying allocator |
|
inline |
Construct a stream_allocator_adaptor
using other.underlying_allocator()
and other.stream()
as the underlying allocator and stream.
OtherAllocator | Type of other 's underlying allocator |
other | The other stream_allocator_adaptor whose underlying allocator and stream will be copied |
|
inline |
Allocates storage for num
objects of type T
using the underlying allocator on stream()
.
num | The number of objects to allocate storage for |
|
inline |
Deallocates storage pointed to by ptr
using the underlying allocator on stream()
.
ptr
must have been allocated from by an allocator a
that compares equal to underlying_allocator()
using a.allocate(n)
.
ptr | Pointer to memory to deallocate |
num | Number of objects originally allocated |
|
inlinenoexcept |
The stream on which calls to the underlying allocator are made.
|
inlinenoexcept |
The underlying allocator.