Public Types | Public Member Functions | Friends | List of all members
rmm::mr::failure_callback_resource_adaptor< ExceptionType > Class Template Reference

A device memory resource that calls a callback function when allocations throw a specified exception type. More...

#include <failure_callback_resource_adaptor.hpp>

Inheritance diagram for rmm::mr::failure_callback_resource_adaptor< ExceptionType >:
Inheritance graph
[legend]
Collaboration diagram for rmm::mr::failure_callback_resource_adaptor< ExceptionType >:
Collaboration graph
[legend]

Public Types

using exception_type = ExceptionType
 The type of exception this object catches/throws.
 

Public Member Functions

 failure_callback_resource_adaptor (cuda::mr::any_resource< cuda::mr::device_accessible > upstream, failure_callback_t callback, void *callback_arg)
 Construct a new failure_callback_resource_adaptor using upstream to satisfy allocation requests. More...
 
device_async_resource_ref get_upstream_resource () const noexcept
 rmm::device_async_resource_ref to the upstream resource More...
 

Friends

void get_property (failure_callback_resource_adaptor const &, cuda::mr::device_accessible) noexcept
 Enables the cuda::mr::device_accessible property.
 

Detailed Description

template<typename ExceptionType = rmm::out_of_memory>
class rmm::mr::failure_callback_resource_adaptor< ExceptionType >

A device memory resource that calls a callback function when allocations throw a specified exception type.

An instance of this resource must be constructed with an existing, upstream resource in order to satisfy allocation requests.

The callback function takes an allocation size and a callback argument and returns a bool representing whether to retry the allocation (true) or re-throw the caught exception (false).

This class is copyable and shares ownership of its internal state via cuda::mr::shared_resource.

Template Parameters
ExceptionTypeThe type of exception that this adaptor should respond to

Constructor & Destructor Documentation

◆ failure_callback_resource_adaptor()

template<typename ExceptionType = rmm::out_of_memory>
rmm::mr::failure_callback_resource_adaptor< ExceptionType >::failure_callback_resource_adaptor ( cuda::mr::any_resource< cuda::mr::device_accessible >  upstream,
failure_callback_t  callback,
void *  callback_arg 
)
inline

Construct a new failure_callback_resource_adaptor using upstream to satisfy allocation requests.

Parameters
upstreamThe resource used for allocating/deallocating device memory
callbackCallback function
See also
failure_callback_t
Parameters
callback_argExtra argument passed to callback

Member Function Documentation

◆ get_upstream_resource()

template<typename ExceptionType = rmm::out_of_memory>
device_async_resource_ref rmm::mr::failure_callback_resource_adaptor< ExceptionType >::get_upstream_resource ( ) const
inlinenoexcept

rmm::device_async_resource_ref to the upstream resource

Returns
rmm::device_async_resource_ref to the upstream resource

The documentation for this class was generated from the following file: