thrust
Public Member Functions | Static Public Member Functions | List of all members
thrust::mr::disjoint_unsynchronized_pool_resource< Upstream, Bookkeeper > Class Template Referencefinal

#include <thrust/mr/disjoint_pool.h>

Inheritance diagram for thrust::mr::disjoint_unsynchronized_pool_resource< Upstream, Bookkeeper >:
thrust::mr::memory_resource< Upstream::pointer >

Public Member Functions

 disjoint_unsynchronized_pool_resource (Upstream *upstream, Bookkeeper *bookkeeper, pool_options options=get_default_options())
 
 disjoint_unsynchronized_pool_resource (pool_options options=get_default_options())
 
 ~disjoint_unsynchronized_pool_resource ()
 
void release ()
 
virtual void_ptr do_allocate (std::size_t bytes, std::size_t alignment=alignof(max_align_t))
 
virtual void do_deallocate (void_ptr p, std::size_t n, std::size_t alignment=alignof(max_align_t))
 
- Public Member Functions inherited from thrust::mr::memory_resource< Upstream::pointer >
virtual ~memory_resource ()
 
pointer allocate (std::size_t bytes, std::size_t alignment=alignof(max_align_t))
 
void deallocate (pointer p, std::size_t bytes, std::size_t alignment=alignof(max_align_t))
 
__host__ __device__ bool is_equal (const memory_resource &other) const noexcept
 
__host__ virtual __device__ bool do_is_equal (const memory_resource &other) const noexcept
 

Static Public Member Functions

static pool_options get_default_options ()
 

Additional Inherited Members

- Public Types inherited from thrust::mr::memory_resource< Upstream::pointer >
typedef Upstream::pointer pointer
 

Detailed Description

template<typename Upstream, typename Bookkeeper>
class thrust::mr::disjoint_unsynchronized_pool_resource< Upstream, Bookkeeper >

A memory resource adaptor allowing for pooling and caching allocations from Upstream, using Bookkeeper for management of that cached and pooled memory, allowing to cache portions of memory inaccessible from the host.

On a typical memory resource, calls to allocate and deallocate actually allocate and deallocate memory. Pooling memory resources only allocate and deallocate memory from an external resource (the upstream memory resource) when there's no suitable memory currently cached; otherwise, they use memory they have acquired beforehand, to make memory allocation faster and more efficient.

The disjoint version of the pool resources uses a separate upstream memory resource, Bookkeeper, to allocate memory necessary to manage the cached memory. There may be many reasons to do that; the canonical one is that Upstream allocates memory that is inaccessible to the code of the pool resource, which means that it cannot embed the necessary information in memory obtained from Upstream; for instance, Upstream can be a CUDA non-managed memory resource, or a CUDA managed memory resource whose memory we would prefer to not migrate back and forth between host and device when executing bookkeeping code.

This is not the only case where it makes sense to use a disjoint pool resource, though. In a multi-core environment it may be beneficial to avoid stealing cache lines from other cores by writing over bookkeeping information embedded in an allocated block of memory. In such a case, one can imagine wanting to use a disjoint pool where both the upstream and the bookkeeper are of the same type, to allocate memory consistently, but separately for those two purposes.

Template Parameters
Upstreamthe type of memory resources that will be used for allocating memory blocks to be handed off to the user
Bookkeeperthe type of memory resources that will be used for allocating bookkeeping memory

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