HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CE_HotSwapPool Class Reference

#include <CE_HotSwapPool.h>

+ Inheritance diagram for CE_HotSwapPool:

Public Member Functions

void registerCEBuffer (CE_HotSwapPoolEntry *buffer, exint nbytes)
 
bool reserveSpace (exint nbytes)
 
void releaseCEBuffer (CE_HotSwapPoolEntry *buffer)
 
void shareCEBuffer (CE_HotSwapPoolEntry *dst, const CE_HotSwapPoolEntry *src)
 Indicates that dst is to share the GPU buffer of src. More...
 
void swapCEBuffer (CE_HotSwapPoolEntry *buffer1, CE_HotSwapPoolEntry *buffer2)
 Indicates that GPU buffers should be swapped between the two inputs. More...
 
void setInUse (const CE_HotSwapPoolEntry *buffer)
 
void clearInUse (const CE_HotSwapPoolEntry *buffer)
 
exint numReductionRequests () const
 
exint bytesFlushed () const
 
void clearStats ()
 
const char * utGetCacheName () const override
 Returns name of this cache. More...
 
int64 utGetCurrentSize () const override
 Returns the amount of GPU memory currently in use by CE buffers. More...
 
int64 utReduceCacheSizeBy (int64 amount) override
 
bool utHasMaxSize () const override
 Required override to indicate that this cache has a maximum size. More...
 
int64 utGetMaxSize () const override
 Returns the maximum amount of GPU memory CE buffers are allowed to use. More...
 
void utSetMaxSize (int64 size) override
 Change the maximum amount of GPU memory CE buffers are allowed to use. More...
 
 ~CE_HotSwapPool () override
 
 CE_HotSwapPool (PassKey)
 
- Public Member Functions inherited from UT_Cache
 UT_Cache ()
 
virtual ~UT_Cache ()
 
 UT_Cache (const UT_Cache &)=delete
 
UT_Cacheoperator= (const UT_Cache &)=delete
 
void utClearCache ()
 
virtual bool utIsEnabled () const
 optional - is this cache currently operational. More...
 
virtual bool utHasMinSize () const
 
virtual int64 utGetMinSize () const
 
virtual void utSetMinSize (int64)
 
virtual bool utUpdateCacheInfo ()
 

Static Public Member Functions

static CE_HotSwapPoolgetMemoryPool ()
 This static member returns the global memory pool. More...
 
static void setMemoryUsageRatio (fpreal ratio)
 Set maximum memory as a ratio of total GPU memory. More...
 
- Static Public Member Functions inherited from UT_Cache
static const UT_ValArray
< UT_Cache * > & 
utGetCacheList ()
 get the list of caches More...
 
static void setCacheAddRemoveCB (void(*callback)(void *), void *data)
 callback to be called when a cache is added or deleted. More...
 
static int64 utClearSpaceFromCaches (int64 amount)
 this method attempts to free up 'amount' bytes from all the caches. More...
 

Detailed Description

This is a memory manager that is responsible for allocating GPU storage for CE buffers. It has a watermark for the maximum amount of live GPU usage that it tries to stay under. There should only ever be one memory pool active. It can be accessed using the static getMemoryPool() method (or CEgetHotSwapPool() free-standing function).

Definition at line 26 of file CE_HotSwapPool.h.

Constructor & Destructor Documentation

CE_HotSwapPool::~CE_HotSwapPool ( )
override
CE_HotSwapPool::CE_HotSwapPool ( PassKey  )

Member Function Documentation

exint CE_HotSwapPool::bytesFlushed ( ) const
inline

Definition at line 72 of file CE_HotSwapPool.h.

void CE_HotSwapPool::clearInUse ( const CE_HotSwapPoolEntry buffer)

This function should be called after setInUse(), once the GPU buffer has been used (to enqueue a kernel with it, for example). If nobody has marked a buffer in use, it will be a candidate for unloading when the pool needs to make space. This function also bumps recency of the buffer's use, making it less likely to get unloaded due the pool's LRU pollicy. This method should not be called directly (i.e. use setInUseGPUFlag() and clearInUseGPUFlag() on CE_HotSwapPoolEntry; or better yet, use CE_ScopedPoolEntryInUseGPU).

void CE_HotSwapPool::clearStats ( )
inline

Definition at line 73 of file CE_HotSwapPool.h.

static CE_HotSwapPool& CE_HotSwapPool::getMemoryPool ( )
static

This static member returns the global memory pool.

exint CE_HotSwapPool::numReductionRequests ( ) const
inline

Definition at line 71 of file CE_HotSwapPool.h.

void CE_HotSwapPool::registerCEBuffer ( CE_HotSwapPoolEntry buffer,
exint  nbytes 
)

Registeres GPU storage of given buffer for its size. This will make it eligible for invoking unloadToGPU to reduce GPU memory usage.

void CE_HotSwapPool::releaseCEBuffer ( CE_HotSwapPoolEntry buffer)

Releases the GPU memory held by buffer. The myGPUBuffer member of buffer will be automatically updated.

bool CE_HotSwapPool::reserveSpace ( exint  nbytes)

Ensures there is enough room to fit the desired number of bytes. Returns true if the memory pool will have that much room free. NOTE: You probably want to allocate anyways if false, this is more a warning.

void CE_HotSwapPool::setInUse ( const CE_HotSwapPoolEntry buffer)

Mark the given buffer as currently in use. This will prevent it from getting unloaded to make room. This method should not be called directly (i.e. use setInUseGPUFlag() and clearInUseGPUFlag() on CE_HotSwapPoolEntry; or better yet, use CE_ScopedPoolEntryInUseGPU).

static void CE_HotSwapPool::setMemoryUsageRatio ( fpreal  ratio)
static

Set maximum memory as a ratio of total GPU memory.

void CE_HotSwapPool::shareCEBuffer ( CE_HotSwapPoolEntry dst,
const CE_HotSwapPoolEntry src 
)

Indicates that dst is to share the GPU buffer of src.

void CE_HotSwapPool::swapCEBuffer ( CE_HotSwapPoolEntry buffer1,
CE_HotSwapPoolEntry buffer2 
)

Indicates that GPU buffers should be swapped between the two inputs.

const char* CE_HotSwapPool::utGetCacheName ( ) const
overridevirtual

Returns name of this cache.

Implements UT_Cache.

int64 CE_HotSwapPool::utGetCurrentSize ( ) const
inlineoverridevirtual

Returns the amount of GPU memory currently in use by CE buffers.

Implements UT_Cache.

Definition at line 80 of file CE_HotSwapPool.h.

int64 CE_HotSwapPool::utGetMaxSize ( ) const
inlineoverridevirtual

Returns the maximum amount of GPU memory CE buffers are allowed to use.

Reimplemented from UT_Cache.

Definition at line 96 of file CE_HotSwapPool.h.

bool CE_HotSwapPool::utHasMaxSize ( ) const
inlineoverridevirtual

Required override to indicate that this cache has a maximum size.

Reimplemented from UT_Cache.

Definition at line 90 of file CE_HotSwapPool.h.

int64 CE_HotSwapPool::utReduceCacheSizeBy ( int64  amount)
overridevirtual

Attempts to free the specified amount of GPU memory by unloading image data to main memory. Returns the actual amount of memory freed.

Implements UT_Cache.

void CE_HotSwapPool::utSetMaxSize ( int64  size)
overridevirtual

Change the maximum amount of GPU memory CE buffers are allowed to use.

Reimplemented from UT_Cache.


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