class

ML::BufferPool

Inherits Reference / Object

Buffer pool for reusing allocations (reduces Metal allocation overhead)

Constants

ALIGNMENT = 256_i64
DEFAULT_MAX_BUFFER_BYTES = (256_i64 * 1024) * 1024
DEFAULT_MAX_CACHED = 32
DEFAULT_MAX_CACHED_BYTES = ((2_i64 * 1024) * 1024) * 1024

Constructors

new(max_cached : Int32 = DEFAULT_MAX_CACHED, max_buffer_bytes : Int64 = DEFAULT_MAX_BUFFER_BYTES, max_cached_bytes : Int64 = DEFAULT_MAX_CACHED_BYTES)
Source

Class methods

env_i64(name : String, default : Int64) : Int64
Source

Instance methods

acquire(size : Int64, mode : StorageMode = StorageMode::Shared) : MetalBuffer

Get buffer of at least size bytes, reusing if possible

Source
clear

Clear all cached buffers

Source
release(buffer : MetalBuffer) : Nil

Return buffer to pool for reuse

Source
stats
Source