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 | |
arena & | operator= (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... | |
bool | deallocate (void *p, std::size_t bytes) |
Deallocate memory pointed to by p , keeping all free superblocks. More... | |
void | clean () |
Clean the arena and deallocate free blocks from the global arena. More... | |
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.
Upstream | Memory resource to use for allocating the global arena. Implements rmm::mr::device_memory_resource interface. |
|
inlineexplicit |
Construct an arena
.
global_arena | The global arena from which to allocate superblocks. |
|
inline |
Allocates memory of size at least bytes
.
<tt>std::bad_alloc</tt> | if the requested allocation could not be fulfilled. |
bytes | The size in bytes of the allocation. |
|
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.
|
inline |
Deallocate memory pointed to by p
, keeping all free superblocks.
This is done when deallocating from another arena. Since we don't have access to the CUDA stream associated with this arena, we don't coalesce the freed block and return it directly to the global arena.
p | Pointer to be deallocated. |
bytes | The 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 . |
|
inline |
Deallocate memory pointed to by p
, and possibly return superblocks to upstream.
p | Pointer to be deallocated. |
bytes | The 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 . |
stream | Stream on which to perform deallocation. |