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 (const arena &)=delete
 
arenaoperator= (const arena &)=delete
 
void * allocate (std::size_t bytes)
 Allocates memory of size at least bytes. More...
 
bool deallocate (void *p, std::size_t bytes, cuda_stream_view stream)
 Deallocate memory pointed to by p, and possibly return superblocks to upstream. More...
 
void clean ()
 Clean the arena and deallocate free blocks from the global arena. More...
 

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 return 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  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.

◆ clean()

template<typename Upstream >
void rmm::mr::detail::arena::arena< Upstream >::clean ( )
inline

Clean the arena and deallocate free blocks from the global arena.

This is only needed when a per-thread arena is about to die.

◆ deallocate()

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

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

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.
streamStream on which to perform deallocation.
Returns
true if the allocation is found, false otherwise.

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