RMM  23.12
RAPIDS Memory Manager
Classes | Functions
owning_wrapper.hpp File Reference
#include <rmm/mr/device/device_memory_resource.hpp>
#include <functional>
#include <iostream>
#include <memory>
#include <utility>
Include dependency graph for owning_wrapper.hpp:

Go to the source code of this file.

Classes

class  rmm::mr::owning_wrapper< Resource, Upstreams >
 Resource adaptor that maintains the lifetime of upstream resources. More...
 

Functions

template<typename Resource , typename UpstreamTuple , std::size_t... Indices, typename... Args>
auto rmm::mr::detail::make_resource_impl (UpstreamTuple const &upstreams, std::index_sequence< Indices... >, Args &&... args)
 Converts a tuple into a parameter pack. More...
 
template<typename Resource , typename... Upstreams, typename... Args>
auto rmm::mr::detail::make_resource (std::tuple< std::shared_ptr< Upstreams >... > const &upstreams, Args &&... args)
 Create a std::unique_ptr to a Resource with the given upstreams and arguments. 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...
 

Function Documentation

◆ make_resource()

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

Create a std::unique_ptr to a Resource with the given upstreams and arguments.

Template Parameters
ResourceThe resource type to create
UpstreamsThe types of the upstream resources
ArgsThe types of the arguments to the resource's 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
std::unique_ptr<Resource> A unique pointer to the created resource

◆ make_resource_impl()

template<typename Resource , typename UpstreamTuple , std::size_t... Indices, typename... Args>
auto rmm::mr::detail::make_resource_impl ( UpstreamTuple const &  upstreams,
std::index_sequence< Indices... >  ,
Args &&...  args 
)

Converts a tuple into a parameter pack.

This helper function for make_resource allows passing the upstreams as a list of arguments to the Resource's constructor.

Template Parameters
ResourceThe resource type to create
UpstreamTupleA tuple of shared pointers of the types of the upstream resources
ArgsThe types of the arguments to the resource's 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 Resource's constructor
Returns
std::unique_ptr<Resource> A unique pointer to the created resource.