将 Upstream
内存资源适配为在指定的对齐大小下分配内存的资源。 更多...
#include <aligned_resource_adaptor.hpp>
公共成员函数 | |
aligned_resource_adaptor (device_async_resource_ref upstream, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT, std::size_t alignment_threshold=default_alignment_threshold) | |
构造一个 aligned resource adaptor,使用 upstream 来满足分配请求。 更多... | |
aligned_resource_adaptor (Upstream *upstream, std::size_t alignment=rmm::CUDA_ALLOCATION_ALIGNMENT, std::size_t alignment_threshold=default_alignment_threshold) | |
构造一个 aligned resource adaptor,使用 upstream 来满足分配请求。 更多... | |
aligned_resource_adaptor (aligned_resource_adaptor const &)=delete | |
aligned_resource_adaptor (aligned_resource_adaptor &&)=delete | |
aligned_resource_adaptor & | operator= (aligned_resource_adaptor const &)=delete |
aligned_resource_adaptor & | operator= (aligned_resource_adaptor &&)=delete |
rmm::device_async_resource_ref | get_upstream_resource () const noexcept |
指向 upstream 资源的 rmm::device_async_resource_ref。 更多... | |
![]() | |
device_memory_resource (device_memory_resource const &)=default | |
默认复制构造函数。 | |
device_memory_resource (device_memory_resource &&) noexcept=default | |
默认移动构造函数。 | |
device_memory_resource & | operator= (device_memory_resource const &)=default |
默认复制赋值运算符。 更多... | |
device_memory_resource & | operator= (device_memory_resource &&) noexcept=default |
默认移动赋值运算符。 更多... | |
void * | allocate (std::size_t bytes, cuda_stream_view stream=cuda_stream_view{}) |
分配至少 bytes 大小的内存。 更多... | |
void | deallocate (void *ptr, std::size_t bytes, cuda_stream_view stream=cuda_stream_view{}) |
解除分配由 ptr 指向的内存。 更多... | |
bool | is_equal (device_memory_resource const &other) const noexcept |
将此资源与另一个资源进行比较。 更多... | |
void * | allocate (std::size_t bytes, std::size_t alignment) |
分配至少 bytes 大小的内存。 更多... | |
void | deallocate (void *ptr, std::size_t bytes, std::size_t alignment) |
解除分配由 ptr 指向的内存。 更多... | |
void * | allocate_async (std::size_t bytes, std::size_t alignment, cuda_stream_view stream) |
分配至少 bytes 大小的内存。 更多... | |
void * | allocate_async (std::size_t bytes, cuda_stream_view stream) |
分配至少 bytes 大小的内存。 更多... | |
void | deallocate_async (void *ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view stream) |
解除分配由 ptr 指向的内存。 更多... | |
void | deallocate_async (void *ptr, std::size_t bytes, cuda_stream_view stream) |
解除分配由 ptr 指向的内存。 更多... | |
bool | operator== (device_memory_resource const &other) const noexcept |
与另一个 device_memory_resource 的比较运算符。 更多... | |
bool | operator!= (device_memory_resource const &other) const noexcept |
与另一个 device_memory_resource 的比较运算符。 更多... | |
静态公共属性 | |
static constexpr std::size_t | default_alignment_threshold = 0 |
适配器使用的默认对齐方式。 | |
将 Upstream
内存资源适配为在指定的对齐大小下分配内存的资源。
此资源的实例可以使用现有的上游资源构造,以满足分配请求。此适配器使用给定的对齐大小封装来自 Upstream 的分配和解除分配操作。
默认情况下,CUDA 驱动程序或运行时 API 的任何内存分配例程返回的任何地址始终至少对齐 256 字节。对于某些用例,例如 GPUDirect Storage (GDS),分配需要对齐到更大的大小(GDS 为 4 KiB),以避免额外复制到跳板缓冲区。
由于更大的对齐大小会带来一些额外的开销,用户可以指定一个阈值大小。如果分配的大小低于阈值,它将对齐到默认大小。只有大小高于阈值的分配才会对齐到自定义的对齐大小。
Upstream | 用于分配/解除分配的上游资源的类型。 |
|
inlineexplicit |
构造一个 aligned resource adaptor,使用 upstream
来满足分配请求。
rmm::logic_error | 如果 allocation_alignment 不是 2 的幂 |
upstream | 用于分配/解除分配设备内存的资源。 |
alignment | 用于分配对齐的大小。 |
alignment_threshold | 只有大小大于或等于此阈值的分配才进行对齐。 |
|
inlineexplicit |
构造一个 aligned resource adaptor,使用 upstream
来满足分配请求。
rmm::logic_error | 如果 upstream == nullptr |
rmm::logic_error | 如果 alignment 不是 2 的幂 |
upstream | 用于分配/解除分配设备内存的资源。 |
alignment | 用于分配对齐的大小。 |
alignment_threshold | 只有大小大于或等于此阈值的分配才进行对齐。 |
|
inlinenoexcept |
指向 upstream 资源的 rmm::device_async_resource_ref