文件 | | 类型定义 | 函数
设备资源适配器
设备资源适配器协作图

文件

文件  aligned_resource_adaptor.hpp
 
文件  failure_callback_resource_adaptor.hpp
 
文件  limiting_resource_adaptor.hpp
 
文件  logging_resource_adaptor.hpp
 
文件  owning_wrapper.hpp
 
文件  prefetch_resource_adaptor.hpp
 
文件  statistics_resource_adaptor.hpp
 
文件  thread_safe_resource_adaptor.hpp
 
文件  thrust_allocator_adaptor.hpp
 
文件  tracking_resource_adaptor.hpp
 

类  rmm::mr::aligned_resource_adaptor< Upstream >
 Upstream 内存资源适配为按指定对齐大小分配内存的资源。 更多...
 
类  rmm::mr::failure_callback_resource_adaptor< Upstream, ExceptionType >
 当分配操作抛出指定异常类型时调用回调函数的设备内存资源。 更多...
 
类  rmm::mr::limiting_resource_adaptor< Upstream >
 使用 Upstream 分配内存并限制总分配量的资源。 更多...
 
类  rmm::mr::logging_resource_adaptor< Upstream >
 使用 Upstream 分配内存并记录请求的分配/释放信息的资源。 更多...
 
类  rmm::mr::owning_wrapper< Resource, Upstreams >
 维护上游资源生命周期的资源适配器。 更多...
 
类  rmm::mr::prefetch_resource_adaptor< Upstream >
 预取所有内存分配的资源。 更多...
 
类  rmm::mr::statistics_resource_adaptor< Upstream >
 使用 Upstream 分配内存并跟踪内存分配统计信息的资源。 更多...
 
类  rmm::mr::thread_safe_resource_adaptor< Upstream >
 Upstream 内存资源适配器适配为线程安全的资源。 更多...
 
类  rmm::mr::thrust_allocator< T >
 一个与 Thrust 容器和算法兼容的 allocator,使用 device_async_resource_ref 进行内存分配和释放。 更多...
 
类  rmm::mr::tracking_resource_adaptor< Upstream >
 使用 Upstream 分配内存并跟踪分配的资源。 更多...
 

类型定义

使用 rmm::mr::failure_callback_t = std::function< bool(std::size_t, void *)>
 failure_callback_resource_adaptor 使用的回调函数类型。 更多...
 

函数

template<template< typename... > class Resource, typename... Upstreams, typename... Args>
auto rmm::mr::make_owning_wrapper (std::tuple< std::shared_ptr< Upstreams >... > upstreams, Args &&... args)
 构造一个类型为 Resource 的资源,该资源被包裹在 ```` owning_wrapper``` 中,使用 upstreams 作为上游资源,args 作为 Resource 构造函数的附加参数。 更多...
 
template<template< typename > class Resource, typename Upstream , typename... Args>
auto rmm::mr::make_owning_wrapper (std::shared_ptr< Upstream > upstream, Args &&... args)
 Resource 只有一个上游资源时,为 ```` owning_wrapper``` 提供的额外便利工厂函数。 更多...
 

详细描述

类型定义文档

◆ failure_callback_t

使用 rmm::mr::failure_callback_t = typedef std::function<bool(std::size_t, void*)>

failure_callback_resource_adaptor 使用的回调函数类型。

当内存分配抛出指定异常类型时,资源适配器会调用此函数。函数决定资源适配器是应尝试再次分配内存还是重新抛出异常。

回调函数签名如下: bool failure_callback_t(std::size_t bytes, void* callback_arg)

回调函数接收两个参数:bytes 是失败的内存分配大小,arg 是传递给 failure_callback_resource_adaptor 构造函数的额外参数。回调函数返回一个布尔值,其中 true 表示重试内存分配,false 表示重新抛出异常。

函数文档

◆ make_owning_wrapper() [1/2]

template<template< typename > class Resource, typename Upstream , typename... Args>
auto rmm::mr::make_owning_wrapper ( std::shared_ptr< Upstream >  upstream,
Args &&...  args 
)

Resource 只有一个上游资源时,为 ```` owning_wrapper``` 提供的额外便利工厂函数。

当资源只有一个上游时,构建包含该上游资源的 std::tuple 可能会不方便。此工厂函数允许仅将单个上游指定为 std::shared_ptr

模板参数
Resource要构造的包裹资源的类型
Upstream单个上游资源的类型
Args`Resource` 构造函数中使用的参数类型
参数
upstream指向该上游资源的 std::shared_ptr
args要转发给包裹资源构造函数的参数包
返回值
一个 ```` owning_wrapper```,包裹着新构造的 Resource<Upstream>upstream

◆ make_owning_wrapper() [2/2]

template<template< typename... > class Resource, typename... Upstreams, typename... Args>
auto rmm::mr::make_owning_wrapper ( std::tuple< std::shared_ptr< Upstreams >... >  upstreams,
Args &&...  args 
)

构造一个类型为 Resource 的资源,该资源被包裹在 ```` owning_wrapper``` 中,使用 upstreams 作为上游资源,args 作为 Resource 构造函数的附加参数。

template <typename Upstream1, typename Upstream2>
class example_resource{
example_resource(Upstream1 * u1, Upstream2 * u2, int n, float f);
};
auto cuda_mr = std::make_shared<rmm::mr::cuda_memory_resource>();
auto cuda_upstreams = std::make_tuple(cuda_mr, cuda_mr);
// 构造一个 `example_resource`
// 被 `owning_wrapper` 包裹,共享拥有 `cuda_mr` 并将其用作 `example_resource` 的两个上游资源。将参数 `42` 和 `3.14` 转发给
// `example_resource` 构造函数的附加参数 `n` 和 `f`。
// example_resource 构造函数的额外 `n` 和 `f` 参数
auto wrapped_example = rmm::mr::make_owning_wrapper<example_resource>(cuda_upstreams, 42, 3.14);
模板参数
Resource指定要构造的包裹资源类型的模板模板参数
Upstreams上游资源的类型
Args`Resource` 构造函数中使用的参数类型
参数
upstreams包裹资源使用的上游资源的 std::shared_ptr 元组,顺序与 Resource 构造函数期望的顺序相同。
args要转发给包裹资源构造函数的参数包
返回值
一个 ```` owning_wrapper```,包裹着新构造的 Resource<Upstreams...>upstreams