Public Member Functions | Static Public Attributes | List of all members
rmm::mr::detail::arena::global_arena< Upstream > Class Template Referencefinal

The global arena for allocating memory from the upstream memory resource. More...

#include <arena.hpp>

Public Member Functions

 global_arena (Upstream *upstream_mr, std::size_t initial_size, std::size_t maximum_size)
 Construct a global arena. More...
 
 global_arena (const global_arena &)=delete
 
global_arenaoperator= (const global_arena &)=delete
 
 ~global_arena ()
 Destroy the global arena and deallocate all memory it allocated using the upstream resource.
 
block allocate (std::size_t bytes)
 Allocates memory of size at least bytes. More...
 
void deallocate (block const &b)
 Deallocate memory pointed to by p. More...
 
void deallocate (std::set< block > const &free_blocks)
 Deallocate a set of free blocks from a dying arena. More...
 

Static Public Attributes

static constexpr std::size_t default_initial_size = std::numeric_limits<std::size_t>::max()
 The default initial size for the global arena.
 
static constexpr std::size_t default_maximum_size = std::numeric_limits<std::size_t>::max()
 The default maximum size for the global arena.
 
static constexpr std::size_t reserved_size = 1u << 26u
 Reserved memory that should not be allocated (64 MiB).
 

Detailed Description

template<typename Upstream>
class rmm::mr::detail::arena::global_arena< Upstream >

The global arena for allocating memory from the upstream memory resource.

The global arena is a shared memory pool from which other arenas allocate superblocks.

Template Parameters
UpstreamMemory resource to use for allocating the arena. Implements rmm::mr::device_memory_resource interface.

Constructor & Destructor Documentation

◆ global_arena()

template<typename Upstream >
rmm::mr::detail::arena::global_arena< Upstream >::global_arena ( Upstream *  upstream_mr,
std::size_t  initial_size,
std::size_t  maximum_size 
)
inline

Construct a global arena.

Exceptions
rmm::logic_errorif upstream_mr == nullptr.
rmm::logic_errorif initial_size is neither the default nor aligned to a multiple of 256 bytes.
rmm::logic_errorif maximum_size is neither the default nor aligned to a multiple of 256 bytes.
Parameters
upstream_mrThe memory resource from which to allocate blocks for the pool
initial_sizeMinimum size, in bytes, of the initial global arena. Defaults to half of the available memory on the current device.
maximum_sizeMaximum size, in bytes, that the global arena can grow to. Defaults to all of the available memory on the current device.

Member Function Documentation

◆ allocate()

template<typename Upstream >
block rmm::mr::detail::arena::global_arena< Upstream >::allocate ( std::size_t  bytes)
inline

Allocates memory of size at least bytes.

Exceptions
<tt>std::bad_alloc</tt>if the requested allocation could not be fulfilled.
Parameters
bytesThe size in bytes of the allocation.
Returns
void* Pointer to the newly allocated memory.

◆ deallocate() [1/2]

template<typename Upstream >
void rmm::mr::detail::arena::global_arena< Upstream >::deallocate ( block const &  b)
inline

Deallocate memory pointed to by p.

Parameters
pPointer to be deallocated.
bytesThe size in bytes of the allocation. This must be equal to the value of bytes that was passed to the allocate call that returned p.

◆ deallocate() [2/2]

template<typename Upstream >
void rmm::mr::detail::arena::global_arena< Upstream >::deallocate ( std::set< block > const &  free_blocks)
inline

Deallocate a set of free blocks from a dying arena.

Parameters
free_blocksThe set of free blocks.

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