36#ifndef ScratchBufferManager_h
37#define ScratchBufferManager_h
95 static std::shared_ptr< AcceleratorBuffer<uint8_t> > Allocate(PoolID_uint8
pool);
96 static std::shared_ptr< AcceleratorBuffer<uint32_t> > Allocate(PoolID_uint32
pool);
97 static std::shared_ptr< AcceleratorBuffer<float> > Allocate(PoolID_float32
pool);
98 static std::shared_ptr< AcceleratorBuffer<int64_t> > Allocate(PoolID_int64
pool);
129template<
class ID,
class T>
148 :
m_ptr(ScratchBufferManager::Allocate(
id))
170 {
return *
m_ptr.get(); }
174 {
return m_ptr.get(); }
179 std::shared_ptr< AcceleratorBuffer<T> >
m_ptr;
MemoryPressureLevel
Levels of memory pressure.
Definition AcceleratorBuffer.h:172
MemoryPressureType
Types of memory pressure.
Definition AcceleratorBuffer.h:189
Definition AcceleratorBuffer.h:204
std::set< std::unique_ptr< ScratchBufferBase > > m_usedScratchBuffers
Scratch buffers used by jobs in the queue.
Definition QueueHandle.h:126
void MarkScratchBufferUsed(T &buf)
Mark a scratch buffer as in use by command buffers pending for this queue.
Definition ScratchBufferManager.h:187
Definition QueueHandle.h:50
Memory pool for temporary working buffers.
Definition ScratchBufferManager.h:44
static bool OnMemoryPressure(MemoryPressureLevel level, MemoryPressureType type, size_t requestedSize)
Called when we run out of (probably) VRAM.
Definition ScratchBufferManager.cpp:174
static std::list< std::shared_ptr< AcceleratorBuffer< uint8_t > > > m_pool_u8_gpu_waveform
Pool for U8_GPU_WAVEFORM.
Definition ScratchBufferManager.h:111
static std::list< std::shared_ptr< AcceleratorBuffer< uint32_t > > > m_pool_u32_gpu_waveform
Pool for U32_GPU_WAVEFORM.
Definition ScratchBufferManager.h:114
static void clear()
Flush all cached buffers.
Definition ScratchBufferManager.cpp:161
static std::mutex m_poolMutex
Mutex for all pools.
Definition ScratchBufferManager.h:108
static size_t GetTotalSize()
Get the total number of bytes in scratch buffers.
Definition ScratchBufferManager.cpp:51
static std::list< std::shared_ptr< AcceleratorBuffer< int64_t > > > m_pool_i64_gpu_waveform
Pool for I64_GPU_WAVEFORM.
Definition ScratchBufferManager.h:120
static std::list< std::shared_ptr< AcceleratorBuffer< float > > > m_pool_f32_gpu_waveform
Pool for F32_GPU_WAVEFORM.
Definition ScratchBufferManager.h:117
static size_t GetPoolSize(PoolID_uint8 id)
Get the total number of bytes in a specific scratch buffer pool.
Definition ScratchBufferManager.cpp:65
static std::list< std::shared_ptr< AcceleratorBuffer< int64_t > > > m_pool_i64_gpu_small
Pool for I64_GPU_SMALL.
Definition ScratchBufferManager.h:123
RAII helper for allocations.
Definition ScratchBufferManager.h:131
AcceleratorBuffer< T > & operator*()
Get the underlying temporary.
Definition ScratchBufferManager.h:169
std::shared_ptr< AcceleratorBuffer< T > > m_ptr
The underlying buffer pointer.
Definition ScratchBufferManager.h:179
AcceleratorBuffer< T > * operator->()
Get the underlying temporary.
Definition ScratchBufferManager.h:173
ID m_pool
The pool we were allocated from.
Definition ScratchBufferManager.h:182