Public Member Functions | 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::optional< std::size_t > arena_size)
 Construct a global arena. More...
 
 global_arena (global_arena const &)=delete
 
global_arenaoperator= (global_arena const &)=delete
 
 global_arena (global_arena &&) noexcept=delete
 
global_arenaoperator= (global_arena &&) noexcept=delete
 
 ~global_arena ()
 Destroy the global arena and deallocate all memory it allocated using the upstream resource.
 
bool handles (std::size_t size) const
 Should allocation of size bytes be handled by the global arena directly? More...
 
superblock acquire (std::size_t size)
 Acquire a superblock that can fit a block of the given size. More...
 
void release (superblock &&sblk)
 Release a superblock. More...
 
void release (std::set< superblock > &superblocks)
 Release a set of superblocks from a dying arena. More...
 
void * allocate (std::size_t size)
 Allocate a large block directly. More...
 
bool deallocate (void *ptr, std::size_t size, cuda_stream_view stream)
 Deallocate memory pointed to by ptr. More...
 
bool deallocate (void *ptr, std::size_t bytes)
 Deallocate memory pointed to by ptr. More...
 
void dump_memory_log (std::shared_ptr< spdlog::logger > const &logger) const
 Dump memory to log. More...
 

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::optional< std::size_t >  arena_size 
)
inline

Construct a global arena.

Exceptions
rmm::logic_errorif upstream_mr == nullptr.
Parameters
upstream_mrThe memory resource from which to allocate blocks for the pool
arena_sizeSize in bytes of the global arena. Defaults to half of the available memory on the current device.

Member Function Documentation

◆ acquire()

template<typename Upstream >
superblock rmm::mr::detail::arena::global_arena< Upstream >::acquire ( std::size_t  size)
inline

Acquire a superblock that can fit a block of the given size.

Parameters
sizeThe size in bytes of the allocation.
Returns
superblock The acquired superblock.

◆ allocate()

template<typename Upstream >
void* rmm::mr::detail::arena::global_arena< Upstream >::allocate ( std::size_t  size)
inline

Allocate a large block directly.

Parameters
sizeThe size in bytes of the allocation.
Returns
void* Pointer to the newly allocated memory.

◆ deallocate() [1/2]

template<typename Upstream >
bool rmm::mr::detail::arena::global_arena< Upstream >::deallocate ( void *  ptr,
std::size_t  bytes 
)
inline

Deallocate memory pointed to by ptr.

Parameters
ptrPointer 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 ptr.
Returns
bool true if the allocation is found, false otherwise.

◆ deallocate() [2/2]

template<typename Upstream >
bool rmm::mr::detail::arena::global_arena< Upstream >::deallocate ( void *  ptr,
std::size_t  size,
cuda_stream_view  stream 
)
inline

Deallocate memory pointed to by ptr.

Parameters
ptrPointer to be deallocated.
sizeThe size in bytes of the allocation. This must be equal to the value of size that was passed to the allocate call that returned p.
streamStream on which to perform deallocation.
Returns
bool true if the allocation is found, false otherwise.

◆ dump_memory_log()

template<typename Upstream >
void rmm::mr::detail::arena::global_arena< Upstream >::dump_memory_log ( std::shared_ptr< spdlog::logger > const &  logger) const
inline

Dump memory to log.

Parameters
loggerthe spdlog logger to use

◆ handles()

template<typename Upstream >
bool rmm::mr::detail::arena::global_arena< Upstream >::handles ( std::size_t  size) const
inline

Should allocation of size bytes be handled by the global arena directly?

Parameters
sizeThe size in bytes of the allocation.
Returns
bool True if the allocation should be handled by the global arena.

◆ release() [1/2]

template<typename Upstream >
void rmm::mr::detail::arena::global_arena< Upstream >::release ( std::set< superblock > &  superblocks)
inline

Release a set of superblocks from a dying arena.

Parameters
superblocksThe set of superblocks.

◆ release() [2/2]

template<typename Upstream >
void rmm::mr::detail::arena::global_arena< Upstream >::release ( superblock &&  sblk)
inline

Release a superblock.

Parameters
sSuperblock to be released.

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