Host memory resource using standard CPU allocation. More...
#include <host_memory_resource.hpp>
Public Member Functions | |
| HostMemoryResource ()=default | |
| Default constructor. | |
| virtual | ~HostMemoryResource ()=default |
| Virtual destructor to allow polymorphic use. | |
| HostMemoryResource (HostMemoryResource const &)=default | |
| Copyable. | |
| HostMemoryResource (HostMemoryResource &&)=default | |
| Movable. | |
| HostMemoryResource & | operator= (HostMemoryResource const &)=default |
| Copy assignment. More... | |
| HostMemoryResource & | operator= (HostMemoryResource &&)=default |
| Move assignment. More... | |
| void * | allocate_sync (std::size_t, std::size_t) |
| Synchronously allocates host memory is disabled. More... | |
| void | deallocate_sync (void *, std::size_t, std::size_t) |
| Synchronously deallocates host memory is disabled. More... | |
| virtual void * | allocate (rmm::cuda_stream_view stream, std::size_t size, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) |
| Allocates host memory associated with a CUDA stream. More... | |
| virtual void | deallocate (rmm::cuda_stream_view stream, void *ptr, std::size_t size, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept |
| Deallocates host memory associated with a CUDA stream. More... | |
| virtual bool | is_equal ([[maybe_unused]] HostMemoryResource const &other) const noexcept |
| Compares this resource to another resource. More... | |
| bool | operator== (HostMemoryResource const &other) const noexcept |
| Compares this resource to another resource. More... | |
| bool | operator!= (HostMemoryResource const &other) const noexcept |
| Compares this resource to another resource. More... | |
Friends | |
| void | get_property (HostMemoryResource const &, cuda::mr::host_accessible) noexcept |
Enables the cuda::mr::host_accessible property. More... | |
Host memory resource using standard CPU allocation.
This resource allocates pageable host memory using the new and delete operators. It is intended for use with cuda::mr::resource and related facilities, and advertises the cuda::mr::host_accessible property.
For sufficiently large allocations (>4 MiB), this resource also issues a best-effort request to enable Transparent Huge Pages (THP) on the allocated region. THP can improve device-host memory transfer performance for large buffers. The hint is applied via madvise(MADV_HUGEPAGE) and may be ignored by the kernel depending on system configuration or resource availability.
Definition at line 32 of file host_memory_resource.hpp.
|
virtual |
Allocates host memory associated with a CUDA stream.
Derived classes may override this to provide custom host allocation strategies.
| stream | CUDA stream associated with the allocation. |
| size | Number of bytes to at least allocate. |
| alignment | Required alignment. |
| std::bad_alloc | If the allocation fails. |
| std::invalid_argument | If alignment is not a valid alignment. |
Reimplemented in rapidsmpf::PinnedMemoryResource.
|
inline |
Synchronously allocates host memory is disabled.
Always use stream-ordered allocators in RapidsMPF.
| std::invalid_argument | Always. |
Definition at line 60 of file host_memory_resource.hpp.
|
virtualnoexcept |
Deallocates host memory associated with a CUDA stream.
The default implementation synchronizes stream before deallocating the memory with the delete operator. This ensures that any in-flight CUDA operations using the memory complete before it is freed.
Derived classes may override this to provide custom host deallocation strategies.
| stream | CUDA stream associated with operations that used ptr. |
| ptr | Pointer to the memory to deallocate. May be nullptr. |
| size | Number of bytes previously allocated at ptr. |
| alignment | Alignment originally used for the allocation. |
Reimplemented in rapidsmpf::PinnedMemoryResource.
|
inline |
Synchronously deallocates host memory is disabled.
| std::invalid_argument | Always. |
Definition at line 72 of file host_memory_resource.hpp.
|
inlinevirtualnoexcept |
Compares this resource to another resource.
Two resources are considered equal if memory allocated by one may be deallocated by the other. The default implementation compares object identity.
The base class is stateless, and all instances behave identically. Any instance can deallocate memory allocated by any other instance of this base class, so the comparison always returns true.
Derived classes that use different allocation or deallocation strategies must override this function. Such classes should return true only when the other resource is compatible with their allocation and free methods.
| other | The resource to compare with. |
Definition at line 136 of file host_memory_resource.hpp.
|
inlinenoexcept |
Compares this resource to another resource.
Two resources are considered equal if memory allocated by one may be deallocated by the other. The default implementation compares object identity.
The base class is stateless, and all instances behave identically. Any instance can deallocate memory allocated by any other instance of this base class, so the comparison always returns true.
Derived classes that use different allocation or deallocation strategies must override this function. Such classes should return true only when the other resource is compatible with their allocation and free methods.
| other | The resource to compare with. |
Definition at line 148 of file host_memory_resource.hpp.
|
default |
Move assignment.
|
default |
Copy assignment.
|
inlinenoexcept |
Compares this resource to another resource.
Two resources are considered equal if memory allocated by one may be deallocated by the other. The default implementation compares object identity.
The base class is stateless, and all instances behave identically. Any instance can deallocate memory allocated by any other instance of this base class, so the comparison always returns true.
Derived classes that use different allocation or deallocation strategies must override this function. Such classes should return true only when the other resource is compatible with their allocation and free methods.
| other | The resource to compare with. |
Definition at line 143 of file host_memory_resource.hpp.
|
friend |
Enables the cuda::mr::host_accessible property.
This property declares that a HostMemoryResource provides host accessible memory
Definition at line 157 of file host_memory_resource.hpp.