Public Member Functions | List of all members
rmm::mr::detail::arena::arena< Upstream > Class Template Reference

An arena for allocating memory for a thread. More...

#include <arena.hpp>

Public Member Functions

 arena (global_arena< Upstream > &global_arena)
 Construct an arena. More...
 
 arena (arena const &)=delete
 
arenaoperator= (arena const &)=delete
 
 arena (arena &&) noexcept=delete
 
arenaoperator= (arena &&) noexcept=delete
 
void * allocate (std::size_t size)
 Allocates memory of size at least size bytes. More...
 
bool deallocate (void *ptr, std::size_t size, cuda_stream_view stream)
 Deallocate memory pointed to by ptr, and possibly return superblocks to upstream. More...
 
bool deallocate (void *ptr, std::size_t size)
 Deallocate memory pointed to by ptr, and possibly return superblocks to upstream. More...
 
void clean ()
 Clean the arena and release all superblocks to the global arena.
 
void defragment ()
 Defragment the arena and release empty superblock to the global arena.
 

Detailed Description

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

An arena for allocating memory for a thread.

An arena is a per-thread or per-non-default-stream memory pool. It allocates superblocks from the global arena, and returns them when the superblocks become empty.

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

Constructor & Destructor Documentation

◆ arena()

template<typename Upstream >
rmm::mr::detail::arena::arena< Upstream >::arena ( global_arena< Upstream > &  global_arena)
inlineexplicit

Construct an arena.

Parameters
global_arenaThe global arena from which to allocate superblocks.

Member Function Documentation

◆ allocate()

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

Allocates memory of size at least size bytes.

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::arena< Upstream >::deallocate ( void *  ptr,
std::size_t  size 
)
inline

Deallocate memory pointed to by ptr, and possibly return superblocks to upstream.

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

◆ deallocate() [2/2]

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

Deallocate memory pointed to by ptr, and possibly return superblocks to upstream.

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.

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