Files | Classes | Typedefs | Functions
Device Resource Adaptors
Collaboration diagram for Device Resource Adaptors:

Files

file  aligned_resource_adaptor.hpp
 
file  failure_callback_resource_adaptor.hpp
 
file  limiting_resource_adaptor.hpp
 
file  logging_resource_adaptor.hpp
 
file  owning_wrapper.hpp
 
file  statistics_resource_adaptor.hpp
 
file  thread_safe_resource_adaptor.hpp
 
file  thrust_allocator_adaptor.hpp
 
file  tracking_resource_adaptor.hpp
 

Classes

class  rmm::mr::aligned_resource_adaptor< Upstream >
 Resource that adapts Upstream memory resource to allocate memory in a specified alignment size. More...
 
class  rmm::mr::failure_callback_resource_adaptor< Upstream, ExceptionType >
 A device memory resource that calls a callback function when allocations throw a specified exception type. More...
 
class  rmm::mr::limiting_resource_adaptor< Upstream >
 Resource that uses Upstream to allocate memory and limits the total allocations possible. More...
 
class  rmm::mr::logging_resource_adaptor< Upstream >
 Resource that uses Upstream to allocate memory and logs information about the requested allocation/deallocations. More...
 
class  rmm::mr::owning_wrapper< Resource, Upstreams >
 Resource adaptor that maintains the lifetime of upstream resources. More...
 
class  rmm::mr::statistics_resource_adaptor< Upstream >
 Resource that uses Upstream to allocate memory and tracks statistics on memory allocations. More...
 
class  rmm::mr::thread_safe_resource_adaptor< Upstream >
 Resource that adapts Upstream memory resource adaptor to be thread safe. More...
 
class  rmm::mr::thrust_allocator< T >
 An allocator compatible with Thrust containers and algorithms using a device_memory_resource for memory (de)allocation. More...
 
class  rmm::mr::tracking_resource_adaptor< Upstream >
 Resource that uses Upstream to allocate memory and tracks allocations. More...
 

Typedefs

using rmm::mr::failure_callback_t = std::function< bool(std::size_t, void *)>
 Callback function type used by failure_callback_resource_adaptor. More...
 

Functions

template<typename Upstream >
limiting_resource_adaptor< Upstream > rmm::mr::make_limiting_adaptor (Upstream *upstream, std::size_t allocation_limit)
 Convenience factory to return a limiting_resource_adaptor around the upstream resource upstream. More...
 
template<typename Upstream >
logging_resource_adaptor< Upstream > rmm::mr::make_logging_adaptor (Upstream *upstream, std::string const &filename=logging_resource_adaptor< Upstream >::get_default_filename(), bool auto_flush=false)
 Convenience factory to return a logging_resource_adaptor around the upstream resource upstream. More...
 
template<typename Upstream >
logging_resource_adaptor< Upstream > rmm::mr::make_logging_adaptor (Upstream *upstream, std::ostream &stream, bool auto_flush=false)
 Convenience factory to return a logging_resource_adaptor around the upstream resource upstream. More...
 
template<template< typename... > class Resource, typename... Upstreams, typename... Args>
auto rmm::mr::make_owning_wrapper (std::tuple< std::shared_ptr< Upstreams >... > upstreams, Args &&... args)
 Constructs a resource of type Resource wrapped in an owning_wrapper using upstreams as the upstream resources and args as the additional parameters for the constructor of Resource. More...
 
template<template< typename > class Resource, typename Upstream , typename... Args>
auto rmm::mr::make_owning_wrapper (std::shared_ptr< Upstream > upstream, Args &&... args)
 Additional convenience factory for owning_wrapper when Resource has only a single upstream resource. More...
 
template<typename Upstream >
statistics_resource_adaptor< Upstream > rmm::mr::make_statistics_adaptor (Upstream *upstream)
 Convenience factory to return a statistics_resource_adaptor around the upstream resource upstream. More...
 
template<typename Upstream >
tracking_resource_adaptor< Upstream > rmm::mr::make_tracking_adaptor (Upstream *upstream)
 Convenience factory to return a tracking_resource_adaptor around the upstream resource upstream. More...
 

Detailed Description

Typedef Documentation

◆ failure_callback_t

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

Callback function type used by failure_callback_resource_adaptor.

The resource adaptor calls this function when a memory allocation throws a specified exception type. The function decides whether the resource adaptor should try to allocate the memory again or re-throw the exception.

The callback function signature is: bool failure_callback_t(std::size_t bytes, void* callback_arg)

The callback function is passed two parameters: bytes is the size of the failed memory allocation and arg is the extra argument passed to the constructor of the failure_callback_resource_adaptor. The callback function returns a Boolean where true means to retry the memory allocation and false means to re-throw the exception.

Function Documentation

◆ make_limiting_adaptor()

template<typename Upstream >
limiting_resource_adaptor<Upstream> rmm::mr::make_limiting_adaptor ( Upstream *  upstream,
std::size_t  allocation_limit 
)

Convenience factory to return a limiting_resource_adaptor around the upstream resource upstream.

Template Parameters
UpstreamType of the upstream device_memory_resource.
Parameters
upstreamPointer to the upstream resource
allocation_limitMaximum amount of memory to allocate
Returns
The new limiting resource adaptor

◆ make_logging_adaptor() [1/2]

template<typename Upstream >
logging_resource_adaptor<Upstream> rmm::mr::make_logging_adaptor ( Upstream *  upstream,
std::ostream &  stream,
bool  auto_flush = false 
)

Convenience factory to return a logging_resource_adaptor around the upstream resource upstream.

Template Parameters
UpstreamType of the upstream device_memory_resource.
Parameters
upstreamPointer to the upstream resource
streamThe ostream to write log info.
auto_flushIf true, flushes the log for every (de)allocation. Warning, this will degrade performance.
Returns
The new logging resource adaptor

◆ make_logging_adaptor() [2/2]

template<typename Upstream >
logging_resource_adaptor<Upstream> rmm::mr::make_logging_adaptor ( Upstream *  upstream,
std::string const &  filename = logging_resource_adaptor<Upstream>::get_default_filename(),
bool  auto_flush = false 
)

Convenience factory to return a logging_resource_adaptor around the upstream resource upstream.

Template Parameters
UpstreamType of the upstream device_memory_resource.
Parameters
upstreamPointer to the upstream resource
filenameName of the file to write log info. If not specified, retrieves the log file name from the environment variable "RMM_LOG_FILE".
auto_flushIf true, flushes the log for every (de)allocation. Warning, this will degrade performance.
Returns
The new logging resource adaptor

◆ 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 
)

Additional convenience factory for owning_wrapper when Resource has only a single upstream resource.

When a resource has only a single upstream, it can be inconvenient to construct a std::tuple of the upstream resource. This factory allows specifying the single upstream as just a std::shared_ptr.

Template Parameters
ResourceType of the wrapped resource to construct
UpstreamType of the single upstream resource
ArgsTypes of the arguments used in Resources constructor
Parameters
upstreamstd::shared_ptr to the upstream resource
argsFunction parameter pack of arguments to forward to the wrapped resource's constructor
Returns
An owning_wrapper wrapping a newly construct Resource<Upstream> and 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 
)

Constructs a resource of type Resource wrapped in an owning_wrapper using upstreams as the upstream resources and args as the additional parameters for the constructor of 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);
// Constructs an `example_resource<rmm::mr::cuda_memory_resource, rmm::mr::cuda_memory_resource>`
// wrapped by an `owning_wrapper` taking shared ownership of `cuda_mr` and using it as both of
// `example_resource`s upstream resources. Forwards the arguments `42` and `3.14` to the
// additional `n` and `f` arguments of `example_resource` constructor.
auto wrapped_example = rmm::mr::make_owning_wrapper<example_resource>(cuda_upstreams, 42, 3.14);
Template Parameters
ResourceTemplate template parameter specifying the type of the wrapped resource to construct
UpstreamsTypes of the upstream resources
ArgsTypes of the arguments used in Resources constructor
Parameters
upstreamsTuple of std::shared_ptrs to the upstreams used by the wrapped resource, in the same order as expected by Resources constructor.
argsFunction parameter pack of arguments to forward to the wrapped resource's constructor
Returns
An owning_wrapper wrapping a newly constructed Resource<Upstreams...> and upstreams.

◆ make_statistics_adaptor()

template<typename Upstream >
statistics_resource_adaptor<Upstream> rmm::mr::make_statistics_adaptor ( Upstream *  upstream)

Convenience factory to return a statistics_resource_adaptor around the upstream resource upstream.

Template Parameters
UpstreamType of the upstream device_memory_resource.
Parameters
upstreamPointer to the upstream resource
Returns
The new statistics resource adaptor

◆ make_tracking_adaptor()

template<typename Upstream >
tracking_resource_adaptor<Upstream> rmm::mr::make_tracking_adaptor ( Upstream *  upstream)

Convenience factory to return a tracking_resource_adaptor around the upstream resource upstream.

Template Parameters
UpstreamType of the upstream device_memory_resource.
Parameters
upstreamPointer to the upstream resource
Returns
The new tracking resource adaptor