Module |
|
Header |
/Engine/Source/Runtime/RHI/Public/GPUDefragAllocator.h |
Include |
#include "GPUDefragAllocator.h" |
class FGPUDefragAllocator
Simple best fit allocator, splitting and coalescing whenever/ wherever possible. NOT THREAD-SAFE.
uses TMap to find memory chunk given a Pointer (potentially colliding with malloc/ free from main thread)
uses separate linked list for free allocations, assuming that relatively few free chunks due to coalescing
Name | Description | ||
---|---|---|---|
|
AllocatedMemorySize |
||
|
AllocationAlignment |
Allocation alignment requirements. |
|
|
AvailableMemorySize |
Available memory in uint8s. |
|
|
bBenchmarkMode |
When in benchmark mode, don't call any Platform functions. |
|
|
BlockedCycles |
Amount of time blocked by a platform fence since the beginning of the last call to Tick(), in appCycles. |
|
|
CompletedSyncIndex |
Sync index that has been completed, so far. |
|
|
CurrentLargestHole |
||
|
CurrentNumHoles |
||
|
CurrentSyncIndex |
Ever-increasing index to synchronize all relocations initiated by Tick(). |
|
|
FMemoryChunk &#... |
FirstChunk |
Head of linked list of chunks. Sorted by memory address. |
|
FMemoryChunk &#... |
FirstFreeChunk |
Head of linked list of free chunks. Unsorted. |
|
friend |
FScopedGPUDefragLock |
|
|
FMemoryChunk &#... |
LastChunk |
Last chunk in the linked list of chunks (see FirstChunk). |
|
MaxNumHoles |
Maximum number of disjoint32 free memory regions we've had. |
|
|
uint8 * |
MemoryBase |
Base of memory pool. |
|
MemorySize |
Total size of memory pool, in uint8s. |
|
|
MinLargestHole |
Smallest consecutive free memory region we've had. |
|
|
NumCanceledAsyncRequests |
Total number of async requests that has been canceled so far. |
|
|
NumFinishedAsyncAllocations |
Total number of async allocations successfully completed so far. |
|
|
NumFinishedAsyncReallocations |
Total number of async reallocations successfully completed so far. |
|
|
NumLockedChunks |
||
|
NumRelocationsInProgress |
Number of async relocations that are currently in progress. |
|
|
PaddingWasteSize |
||
|
PendingFreeChunks |
Chunks that couldn't be freed immediately because they were being relocated. |
|
|
PendingMemoryAdjustment |
Adjustment to allocated memory, pending all reallocations. |
|
|
PlatformSyncFence |
Platform-specific (GPU) fence, used for synchronizing the Sync Index. |
|
|
PointerToChunkMap |
Mapping from Pointer to chunk for fast removal. |
|
|
Settings |
Allocator settings that affect its behavior. |
|
|
SynchronizationObject |
||
|
double |
TimeSpentInAllocator |
Cumulative time spent in allocator. |
|
TotalNumBytesRelocated |
Total number of uint8s relocated so far. |
|
|
TotalNumRelocations |
Stats. |
Name | Description | |
---|---|---|
|
FGPUDefragAllocator() |
Constructor, zero initializing all member variables |
Name | Description | |
---|---|---|
|
~FGPUDefragAllocator() |
Name | Description | ||
---|---|---|---|
|
void * |
Allocate |
Allocate physical memory. |
|
FMemoryChunk... |
AllocateChunk ( |
Marks the specified chunk as 'allocated' and updates tracking variables. |
|
Benchmark |
Performs a benchmark of the allocator and outputs the result to the log. |
|
|
BlockOnAsyncReallocation ( |
Blocks the calling thread until the specified request has been completed. |
|
|
BlockOnFence() |
Blocks the calling thread until the current sync fence has been completed. |
|
|
BlockOnSyncIndex ( |
Blocks the calling thread until the specified sync index has been completed. |
|
|
CancelAsyncReallocation ( |
Cancels the specified reallocation request. |
|
|
CanRelocate ( |
Returns true if the specified chunk is allowed to relocate at this time. |
|
|
CheckForErrors ( |
Checks the int32ernal state for errors. (Slow) Checks the internal state for errors. (Slow) |
|
|
Coalesce ( |
Merges any adjacent free chunks into the specified free chunk. |
|
|
DefragmentMemory ( |
Fully defragments the memory and blocks until it's done. |
|
|
DumpAllocs ( |
Dump allocation information. |
|
|
FMemoryChunk... |
FindAdjacent ( |
Defrag helper function. Checks if the specified allocation fits within the adjacent free chunk(s). |
|
FMemoryChunk... |
FindAdjacentToHole ( |
Searches for an allocated chunk that would fit within the specified free chunk. |
|
FMemoryChunk... |
FindAny ( |
Searches for an allocated chunk that would fit within the specified free chunk. |
|
FinishAllRelocations() |
Blocks the calling thread until all relocations and reallocations that were initiated by Tick() have completed. |
|
|
Free ( |
Frees allocation associated with the specified Pointer. |
|
|
FreeChunk ( |
Marks the specified chunk as 'free' and updates tracking variables. |
|
|
FullDefragmentation ( |
Performs a full defrag and ignores all reallocation requests. |
|
|
GetAllocatedSize ( |
Returns the amount of memory allocated for the specified address. |
|
|
GetAllocationAlignment() |
||
|
GetBlockedCycles() |
Returns the amount of time blocked by a platform fence since the beginning of the last call to Tick(), in appCycles. |
|
|
EMemoryEleme... |
GetChunkType ( |
|
|
GetCurrentSyncIndex() |
Returns the sync index to be completed by the next call to FinishAllRelocations(). |
|
|
GetLargestAvailableAllocation ( |
Scans the free chunks and returns the largest size you can allocate. |
|
|
GetMemoryLayout ( |
||
|
GetMemoryStats |
Retrieves allocation stats. |
|
|
GetSettings ( |
Returns the current allocator settings. |
|
|
GetTextureMemoryVisualizeData |
Fills a texture with to visualize the texture pool memory. |
|
|
GetTotalSize() |
||
|
void * |
GetUserPayload ( |
Returns the user payload for an FMemoryChunk |
|
FMemoryChunk... |
Grow ( |
Tries to immediately grow a memory chunk by moving the base address, without relocating any memory. |
|
InBenchmarkMode() |
Returns whether we're in benchmark mode or not. |
|
|
Initialize |
||
|
Initialize |
Initialize this allocator with a preallocated block of memory. |
|
|
InsertFence() |
Inserts a platform fence and updates the allocator sync index to match. |
|
|
IsAligned |
||
|
IsInitialized() |
Returns whether allocator has been initialized. |
|
|
IsValidPoolMemory ( |
||
|
LinkFreeChunk ( |
Frees the passed in chunk and coalesces adjacent free chunks into 'Chunk' if possible. |
|
|
Lock ( |
Locks an FMemoryChunk |
|
|
PartialDefragmentationDownshift ( |
Performs a partial defrag by shifting down memory to fill holes, in a brute-force manner. |
|
|
PartialDefragmentationFast ( |
Performs a partial defrag doing fast checks only. Adjacency and freelist walk. |
|
|
PartialDefragmentationSlow ( |
Performs a partial defrag doing slow all chunk search to find used chunks to move that are surrounded by other used chunks That a freechunk walk won't find. |
|
|
PlatformBlockOnFence ( |
Blocks the calling thread until all relocations initiated before the fence was added has been fully completed. |
|
|
PlatformCanRelocate |
Allows each platform to decide whether an allocation can be relocated at this time. |
|
|
PlatformInsertFence() |
Inserts a fence to synchronize relocations. |
|
|
PlatformNotifyReallocationFinished ( |
Notifies the platform that an async reallocation request has been completed. |
|
|
PlatformRelocate |
Copy memory from one location to another. |
|
|
void * |
Reallocate |
Tries to reallocate texture memory in-place (without relocating), by adjusting the base address of the allocation but keeping the end address the same. |
|
Relocate ( |
Copy memory from one location to another. |
|
|
FMemoryChunk... |
RelocateAllowed ( |
Performs a partial defrag while trying to process any pending async reallocation requests. |
|
FMemoryChunk... |
RelocateIntoFreeChunk ( |
Initiates an async relocation of an allocated chunk into a free chunk. |
|
SetSettings ( |
Sets new allocator settings. |
|
|
SetUserPayload |
Sets the user payload for an FMemoryChunk |
|
|
FMemoryChunk... |
Shrink ( |
Immediately shrinks a memory chunk by moving the base address, without relocating any memory. |
|
SortFreeList |
Sorts the freelist based on increasing base address. |
|
|
Split ( |
Split allocation into two, first chunk being used and second being available. |
|
|
Tick ( |
Partially defragments the memory and tries to process all async reallocation requests at the same time. |
|
|
Unlock ( |
Unlocks an FMemoryChunk |
Name |
Description |
|
---|---|---|
|
FMemoryChunk |
Contains information of a single allocation or free block. |
|
FMemoryLayoutElement |
|
|
FRelocationStats |
Container for allocator relocation stats. |
|
FSettings |
Container for allocator settings. |
Name |
Description |
|
---|---|---|
|
EMemoryElementType |
Name |
Description |
---|---|
FRequestList |
|
FRequestNode |
|
memsize_t |
Allocated memory in uint8s. |