RMM
23.12
RAPIDS Memory Manager
|
Base class for host memory allocation. More...
#include <host_memory_resource.hpp>
Public Member Functions | |
host_memory_resource (host_memory_resource const &)=default | |
Default copy constructor. | |
host_memory_resource (host_memory_resource &&) noexcept=default | |
Default move constructor. | |
host_memory_resource & | operator= (host_memory_resource const &)=default |
Default copy assignment operator. More... | |
host_memory_resource & | operator= (host_memory_resource &&) noexcept=default |
Default move assignment operator. More... | |
void * | allocate (std::size_t bytes, std::size_t alignment=alignof(std::max_align_t)) |
Allocates memory on the host of size at least bytes bytes. More... | |
void | deallocate (void *ptr, std::size_t bytes, std::size_t alignment=alignof(std::max_align_t)) |
Deallocate memory pointed to by ptr . More... | |
bool | is_equal (host_memory_resource const &other) const noexcept |
Compare this resource to another. More... | |
bool | operator== (host_memory_resource const &other) const noexcept |
Comparison operator with another device_memory_resource. More... | |
bool | operator!= (host_memory_resource const &other) const noexcept |
Comparison operator with another device_memory_resource. More... | |
Friends | |
void | get_property (host_memory_resource const &, cuda::mr::host_accessible) noexcept |
Enables the cuda::mr::host_accessible property. More... | |
Base class for host memory allocation.
This is based on std::pmr::memory_resource
: https://en.cppreference.com/w/cpp/memory/memory_resource
When C++17 is available for use in RMM, rmm::host_memory_resource
should inherit from std::pmr::memory_resource
.
This class serves as the interface that all host memory resource implementations must satisfy.
There are two private, pure virtual functions that all derived classes must implement: do_allocate
and do_deallocate
. Optionally, derived classes may also override is_equal
. By default, is_equal
simply performs an identity comparison.
The public, non-virtual functions allocate
, deallocate
, and is_equal
simply call the private virtual functions. The reason for this is to allow implementing shared, default behavior in the base class. For example, the base class' allocate
function may log every allocation, no matter what derived class implementation is used.
|
inline |
Allocates memory on the host of size at least bytes
bytes.
The returned storage is aligned to the specified alignment
if supported, and to alignof(std::max_align_t)
otherwise.
std::bad_alloc | When the requested bytes and alignment cannot be allocated. |
bytes | The size of the allocation |
alignment | Alignment of the allocation |
|
inline |
Deallocate memory pointed to by ptr
.
ptr
must have been returned by a prior call to allocate(bytes,alignment)
on a host_memory_resource
that compares equal to *this
, and the storage it points to must not yet have been deallocated, otherwise behavior is undefined.
ptr | Pointer to be deallocated |
bytes | The size in bytes of the allocation. This must be equal to the value of bytes that was passed to the allocate call that returned ptr . |
alignment | Alignment of the allocation. This must be equal to the value of alignment that was passed to the allocate call that returned ptr . |
|
inlinenoexcept |
Compare this resource to another.
Two host_memory_resource
s compare equal if and only if memory allocated from one host_memory_resource
can be deallocated from the other and vice versa.
By default, simply checks if *this
and other
refer to the same object, i.e., does not check if they are two objects of the same class.
other | The other resource to compare to |
|
inlinenoexcept |
Comparison operator with another device_memory_resource.
other | The other resource to compare to |
|
defaultnoexcept |
Default move assignment operator.
|
default |
Default copy assignment operator.
|
inlinenoexcept |
Comparison operator with another device_memory_resource.
other | The other resource to compare to |
|
friend |
Enables the cuda::mr::host_accessible
property.
This property declares that a host_memory_resource
provides host accessible memory