20 #include <rmm/detail/error.hpp>
21 #include <rmm/detail/export.hpp>
22 #include <rmm/detail/format.hpp>
28 namespace RMM_NAMESPACE {
40 int pageableMemoryAccess;
41 RMM_CUDA_TRY(cudaDeviceGetAttribute(
42 &pageableMemoryAccess, cudaDevAttrPageableMemoryAccess, device_id.
value()));
43 return pageableMemoryAccess == 1;
79 "此硬件/软件版本不支持系统内存分配器。");
101 void* do_allocate(std::size_t bytes, [[maybe_unused]]
cuda_stream_view stream)
override
104 return rmm::detail::aligned_host_allocate(
106 }
catch (std::bad_alloc
const& e) {
107 auto const msg = std::string(
"分配失败 ") + rmm::detail::format_bytes(bytes) +
108 std::string(
"内存:") + e.what();
123 void do_deallocate(
void* ptr,
124 [[maybe_unused]] std::size_t bytes,
133 rmm::detail::aligned_host_deallocate(
147 [[nodiscard]]
bool do_is_equal(device_memory_resource
const& other)
const noexcept
override
149 return dynamic_cast<system_memory_resource const*
>(&other) !=
nullptr;
167 static_assert(cuda::mr::async_resource_with<system_memory_resource, cuda::mr::device_accessible>);
168 static_assert(cuda::mr::async_resource_with<system_memory_resource, cuda::mr::host_accessible>);
CUDA stream 的强类型非拥有包装器,带默认构造函数。
定义: cuda_stream_view.hpp:39
void synchronize() const
同步视图化的 CUDA stream。
定义: cuda_stream_view.hpp:106
librmm 设备内存分配的基类。
定义: device_memory_resource.hpp:92
device_memory_resource 的派生类,使用 malloc/free 进行分配/释放。
定义: system_memory_resource.hpp:74
system_memory_resource(system_memory_resource const &)=default
默认拷贝构造函数。
system_memory_resource(system_memory_resource &&)=default
默认拷贝构造函数。
system_memory_resource & operator=(system_memory_resource const &)=default
默认拷贝赋值运算符。
friend void get_property(system_memory_resource const &, cuda::mr::device_accessible) noexcept
启用 cuda::mr::device_accessible 属性。
定义: system_memory_resource.hpp:156
friend void get_property(system_memory_resource const &, cuda::mr::host_accessible) noexcept
启用 cuda::mr::host_accessible 属性。
定义: system_memory_resource.hpp:163
system_memory_resource & operator=(system_memory_resource &&)=default
默认移动赋值运算符。
RMM 内存不足时抛出的异常。
定义: error.hpp:87
cuda_device_id get_current_cuda_device()
返回当前设备的 cuda_device_id。
定义: cuda_device.hpp:99
static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT
CUDA 内存分配使用的默认对齐方式。
定义: aligned.hpp:43
用于 CUDA 设备标识符的强类型。
定义: cuda_device.hpp:41
constexpr value_type value() const noexcept
包装的整数值。
定义: cuda_device.hpp:57
static bool is_system_memory_supported(cuda_device_id device_id)
检查指定设备上是否支持系统分配内存 (SAM)。
定义: system_memory_resource.hpp:38