spla
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
spla::CLAllocLinear Class Reference

Linear allocator for temporary device local buffer allocations. More...

#include <cl_alloc_linear.hpp>

Inheritance diagram for spla::CLAllocLinear:
Inheritance graph
[legend]
Collaboration diagram for spla::CLAllocLinear:
Collaboration graph
[legend]

Public Member Functions

 CLAllocLinear (std::size_t arena_size=DEFAULT_SIZE, std::size_t alignment=DEFAULT_ALIGNMENT)
 
 ~CLAllocLinear () override=default
 
cl::Buffer alloc (std::size_t size) override
 
void free (cl::Buffer buffer) override
 
void free_all () override
 
- Public Member Functions inherited from spla::CLAlloc
virtual ~CLAlloc ()=default
 

Static Public Attributes

static constexpr const uint DEFAULT_SIZE = 1024 * 1024
 
static constexpr const uint DEFAULT_ALIGNMENT = 128
 

Protected Member Functions

void expand ()
 
void shrink ()
 

Detailed Description

Linear allocator for temporary device local buffer allocations.

Linear allocator uses linear allocation strategy. It places allocated buffers sequentially in a large pre-allocated arena buffer. If arena is full, new arena allocated. On a free all step, all allocations must be invalid. All allocated arenas cleared, and one new bigger arena allocated.

Constructor & Destructor Documentation

◆ CLAllocLinear()

spla::CLAllocLinear::CLAllocLinear ( std::size_t  arena_size = DEFAULT_SIZE,
std::size_t  alignment = DEFAULT_ALIGNMENT 
)
explicit

◆ ~CLAllocLinear()

spla::CLAllocLinear::~CLAllocLinear ( )
overridedefault

Member Function Documentation

◆ alloc()

cl::Buffer spla::CLAllocLinear::alloc ( std::size_t  size)
overridevirtual

Implements spla::CLAlloc.

◆ expand()

void spla::CLAllocLinear::expand ( )
protected

◆ free()

void spla::CLAllocLinear::free ( cl::Buffer  buffer)
overridevirtual

Implements spla::CLAlloc.

◆ free_all()

void spla::CLAllocLinear::free_all ( )
overridevirtual

Implements spla::CLAlloc.

◆ shrink()

void spla::CLAllocLinear::shrink ( )
protected

Member Data Documentation

◆ DEFAULT_ALIGNMENT

constexpr const uint spla::CLAllocLinear::DEFAULT_ALIGNMENT = 128
staticconstexpr

◆ DEFAULT_SIZE

constexpr const uint spla::CLAllocLinear::DEFAULT_SIZE = 1024 * 1024
staticconstexpr

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