|
Nebula
|
#include <rangeallocator.h>
Allocates memory ranges using the TLSF method, with extended handling of padding to better suit GPUs.
Doesn't manage memory itself but is meant to be used with a memory allocation/buffer of maxSize. Fast O(1) insertion and deletion and with minimal fragmentation.
More details: http://www.gii.upv.es/tlsf/files/ecrts04_tlsf.pdf
Classes | |
| struct | RangeAllocatorNode |
| struct | BinIndex |
Public Member Functions | |
| RangeAllocator () | |
| Default constructor. | |
| RangeAllocator (size_t size, SizeT maxNumAllocs) | |
| Construct with predetermined size and max allowed number of allocations. | |
| ~RangeAllocator () | |
| Destructor. | |
| void | Clear () |
| Clears the allocator. | |
| bool | Empty () |
| Checks if the allocator is empty. | |
| RangeAllocation | Alloc (size_t size, size_t alignment=1) |
| Allocate range. | |
| void | Dealloc (const RangeAllocation &allocation) |
| Deallocate range. | |
Public Attributes | |
| size_t | size |
| size_t | freeStorage |
| uint | freeNodeIterator |
| uint | numAllocs |
| uint | bucketUsageMask |
| uint | binMasks [NUM_BUCKETS] |
| uint | binHeads [NUM_BUCKETS *NUM_BINS_PER_BUCKET] |
| Util::Array< RangeAllocatorNode > | nodes |
| Util::Array< uint > | freeNodes |
Static Public Attributes | |
| static constexpr uint | NUM_BUCKETS = 32u |
| static constexpr uint | NUM_BINS_PER_BUCKET = 8u |
Private Member Functions | |
| uint | InsertNode (size_t size, size_t offset) |
| Insert node at bin location, return node index. | |
| void | RemoveNode (uint nodeIndex) |
| Remove node from bin. | |
Static Private Member Functions | |
| static BinIndex | IndexFromSize (size_t size, bool round=false) |
| Get bin index from size. | |
| static uint | BucketFromSize (size_t size) |
| Get bucket from index. | |
| static uint | BinFromSize (uint size, uint bucket) |
| Get bin from index. | |
|
inline |
Default constructor.
|
inline |
Construct with predetermined size and max allowed number of allocations.
|
inline |
Destructor.
|
inline |
Allocate range.
Returns a range using the TLSF method.
Get bin from index.
|
staticprivate |
Get bucket from index.
|
inline |
Clears the allocator.
|
inline |
Deallocate range.
|
inline |
Checks if the allocator is empty.
|
inlinestaticprivate |
Get bin index from size.
|
inlineprivate |
Insert node at bin location, return node index.
|
inlineprivate |
Remove node from bin.
| uint Memory::RangeAllocator::binHeads[NUM_BUCKETS *NUM_BINS_PER_BUCKET] |
| uint Memory::RangeAllocator::binMasks[NUM_BUCKETS] |
| uint Memory::RangeAllocator::bucketUsageMask |
| uint Memory::RangeAllocator::freeNodeIterator |
| Util::Array<uint> Memory::RangeAllocator::freeNodes |
| size_t Memory::RangeAllocator::freeStorage |
| Util::Array<RangeAllocatorNode> Memory::RangeAllocator::nodes |
|
staticconstexpr |
|
staticconstexpr |
| uint Memory::RangeAllocator::numAllocs |
| size_t Memory::RangeAllocator::size |