使用 Upstream
分配内存并限制总分配量的资源。 更多...
#include <limiting_resource_adaptor.hpp>
公共成员函数 | |
limiting_resource_adaptor (device_async_resource_ref upstream, std::size_t allocation_limit, std::size_t alignment=CUDA_ALLOCATION_ALIGNMENT) | |
构造一个新的限制资源适配器,使用 upstream 满足分配请求并限制可能的总分配量。 更多... | |
limiting_resource_adaptor (Upstream *upstream, std::size_t allocation_limit, std::size_t alignment=CUDA_ALLOCATION_ALIGNMENT) | |
构造一个新的限制资源适配器,使用 upstream 满足分配请求并限制可能的总分配量。 更多... | |
limiting_resource_adaptor (limiting_resource_adaptor const &)=delete | |
limiting_resource_adaptor (limiting_resource_adaptor &&) noexcept=default | |
默认移动构造函数。 | |
limiting_resource_adaptor & | operator= (limiting_resource_adaptor const &)=delete |
limiting_resource_adaptor & | operator= (limiting_resource_adaptor &&) noexcept=default |
默认移动赋值运算符。 更多... | |
device_async_resource_ref | get_upstream_resource () const noexcept |
上游资源的 device_async_resource_ref 更多... | |
std::size_t | get_allocated_bytes () const |
查询已分配的字节数。注意,由于可能的碎片以及此分配器未跟踪的内部页面大小和对齐方式,不能使用此函数来了解可能的最大分配量。 更多... | |
std::size_t | get_allocation_limit () const |
查询此分配器允许分配的最大字节数。这是对分配器的限制,并非底层设备的表示。设备可能无法支持此限制。 更多... | |
![]() | |
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{}) |
释放 p 指向的内存。 更多... | |
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) |
释放 p 指向的内存。 更多... | |
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) |
释放 p 指向的内存。 更多... | |
void | deallocate_async (void *ptr, std::size_t bytes, cuda_stream_view stream) |
释放 p 指向的内存。 更多... | |
bool | operator== (device_memory_resource const &other) const noexcept |
与另一个 device_memory_resource 的比较运算符。 更多... | |
bool | operator!= (device_memory_resource const &other) const noexcept |
与另一个 device_memory_resource 的比较运算符。 更多... | |
使用 Upstream
分配内存并限制总分配量的资源。
此资源的一个实例可以使用现有的上游资源来满足分配请求,但任何现有的分配将不被跟踪。原子操作用于确保线程安全,但请注意 get_allocated_bytes
可能不包含正在进行的分配。
Upstream | 用于分配/释放内存的上游资源的类型。 |
|
inline |
构造一个新的限制资源适配器,使用 upstream
满足分配请求并限制可能的总分配量。
upstream | 用于分配/释放设备内存的资源 |
allocation_limit | 此分配器允许的最大内存量 |
alignment | 每个已分配缓冲区起始的对齐字节数 |
|
inline |
构造一个新的限制资源适配器,使用 upstream
满足分配请求并限制可能的总分配量。
rmm::logic_error | 如果 upstream == nullptr |
upstream | 用于分配/释放设备内存的资源 |
allocation_limit | 此分配器允许的最大内存量 |
alignment | 每个已分配缓冲区起始的对齐字节数 |
|
inline |
查询已分配的字节数。注意,由于可能的碎片以及此分配器未跟踪的内部页面大小和对齐方式,不能使用此函数来了解可能的最大分配量。
|
inline |
查询此分配器允许分配的最大字节数。这是对分配器的限制,并非底层设备的表示。设备可能无法支持此限制。
|
inlinenoexcept |
上游资源的 device_async_resource_ref
|
defaultnoexcept |
默认移动赋值运算符。