Package org.nd4j.linalg.api.memory
Interface MemoryManager
-
- All Known Implementing Classes:
BasicMemoryManager
public interface MemoryManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.bytedeco.javacpp.Pointerallocate(long bytes, MemoryKind kind, boolean initialize)This method returns pointer to allocated memory PLEASE NOTE: Cache options depend on specific implementationslongallocatedMemory(Integer deviceId)This method returns number of bytes allocated on specified devicevoidcollect(INDArray... arrays)This method detaches off-heap memory from passed INDArray instances, and optionally stores them in cache for future reuse PLEASE NOTE: Cache options depend on specific implementationsintgetAutoGcWindow()This method reutrnsintgetAverageLoopTime()This method returns average time between invokeGCOccasionally() callsMap<Integer,Long>getBandwidthUse()This method returns per-device bandwidth use for memory transfersMemoryWorkspacegetCurrentWorkspace()longgetLastGcTime()This method returns time (in milliseconds) of the las System.gc() callintgetOccasionalGcFrequency()This method returnsvoidinvokeGc()This method calls for GC.voidinvokeGcOccasionally()This method calls for GC, and if frequency is met - System.gc() will be calledbooleanisPeriodicGcActive()This method returns true, if periodic GC is active.voidmemcpy(DataBuffer dstBuffer, DataBuffer srcBuffer)This method does memcpy from source buffer to destination buffer PLEASE NOTE: This method is NOT safe.voidmemset(INDArray array)This method fills given INDArray with zeroes.voidnotifyScopeEntered()PLEASE NOTE: This method is under development yet.voidnotifyScopeLeft()PLEASE NOTE: This method is under development yet.voidpurgeCaches()This method purges all cached memory chunksvoidrelease(org.bytedeco.javacpp.Pointer pointer, MemoryKind kind)This method releases previously allocated memory chunkvoidreleaseCurrentContext()This method releases Context (if current backend has one, sure)MemoryWorkspacescopeOutOfWorkspaces()This method temporary opens block out of any workspace scope.voidsetAutoGcWindow(int windowMillis)This method enables/disables periodic System.gc() calls.voidsetCurrentWorkspace(MemoryWorkspace workspace)voidsetOccasionalGcFrequency(int frequency)Sets manual GC invocation frequency.voidtoggleAveraging(boolean enabled)This method enables/disables calculation of average time spent within loops Default: falsevoidtogglePeriodicGc(boolean enabled)This method enables/disables periodic GC
-
-
-
Method Detail
-
getCurrentWorkspace
MemoryWorkspace getCurrentWorkspace()
-
setCurrentWorkspace
void setCurrentWorkspace(MemoryWorkspace workspace)
-
notifyScopeEntered
void notifyScopeEntered()
PLEASE NOTE: This method is under development yet. Do not use it.
-
notifyScopeLeft
void notifyScopeLeft()
PLEASE NOTE: This method is under development yet. Do not use it.
-
invokeGcOccasionally
void invokeGcOccasionally()
This method calls for GC, and if frequency is met - System.gc() will be called
-
invokeGc
void invokeGc()
This method calls for GC.
-
togglePeriodicGc
void togglePeriodicGc(boolean enabled)
This method enables/disables periodic GC- Parameters:
enabled-
-
toggleAveraging
void toggleAveraging(boolean enabled)
This method enables/disables calculation of average time spent within loops Default: false- Parameters:
enabled-
-
isPeriodicGcActive
boolean isPeriodicGcActive()
This method returns true, if periodic GC is active. False otherwise.- Returns:
-
getLastGcTime
long getLastGcTime()
This method returns time (in milliseconds) of the las System.gc() call- Returns:
-
setOccasionalGcFrequency
void setOccasionalGcFrequency(int frequency)
Sets manual GC invocation frequency. If you set it to 5, only 1/5 of calls will result in GC invocation If 0 is used as frequency, it'll disable all manual invocation hooks. default value: 5- Parameters:
frequency-
-
getOccasionalGcFrequency
int getOccasionalGcFrequency()
This method returns- Returns:
-
getAverageLoopTime
int getAverageLoopTime()
This method returns average time between invokeGCOccasionally() calls- Returns:
-
setAutoGcWindow
void setAutoGcWindow(int windowMillis)
This method enables/disables periodic System.gc() calls. Set to 0 to disable this option.- Parameters:
windowMillis- minimal time milliseconds between calls.
-
getAutoGcWindow
int getAutoGcWindow()
This method reutrns
-
allocate
org.bytedeco.javacpp.Pointer allocate(long bytes, MemoryKind kind, boolean initialize)This method returns pointer to allocated memory PLEASE NOTE: Cache options depend on specific implementations- Parameters:
bytes-
-
release
void release(org.bytedeco.javacpp.Pointer pointer, MemoryKind kind)This method releases previously allocated memory chunk- Parameters:
pointer-kind-
-
collect
void collect(INDArray... arrays)
This method detaches off-heap memory from passed INDArray instances, and optionally stores them in cache for future reuse PLEASE NOTE: Cache options depend on specific implementations- Parameters:
arrays-
-
purgeCaches
void purgeCaches()
This method purges all cached memory chunks
-
memcpy
void memcpy(DataBuffer dstBuffer, DataBuffer srcBuffer)
This method does memcpy from source buffer to destination buffer PLEASE NOTE: This method is NOT safe.- Parameters:
dstBuffer-srcBuffer-
-
memset
void memset(INDArray array)
This method fills given INDArray with zeroes. PLEASE NOTE: Can't be efficiently used on views, .assign(0.0) will be used instead- Parameters:
array-
-
scopeOutOfWorkspaces
MemoryWorkspace scopeOutOfWorkspaces()
This method temporary opens block out of any workspace scope. PLEASE NOTE: Do not forget to close this block.- Returns:
-
getBandwidthUse
Map<Integer,Long> getBandwidthUse()
This method returns per-device bandwidth use for memory transfers
-
allocatedMemory
long allocatedMemory(Integer deviceId)
This method returns number of bytes allocated on specified device- Parameters:
deviceId-- Returns:
-
releaseCurrentContext
void releaseCurrentContext()
This method releases Context (if current backend has one, sure)
-
-