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.Pointer
allocate(long bytes, MemoryKind kind, boolean initialize)
This method returns pointer to allocated memory PLEASE NOTE: Cache options depend on specific implementationslong
allocatedMemory(Integer deviceId)
This method returns number of bytes allocated on specified devicevoid
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 implementationsint
getAutoGcWindow()
This method reutrnsint
getAverageLoopTime()
This method returns average time between invokeGCOccasionally() callsMap<Integer,Long>
getBandwidthUse()
This method returns per-device bandwidth use for memory transfersMemoryWorkspace
getCurrentWorkspace()
long
getLastGcTime()
This method returns time (in milliseconds) of the las System.gc() callint
getOccasionalGcFrequency()
This method returnsvoid
invokeGc()
This method calls for GC.void
invokeGcOccasionally()
This method calls for GC, and if frequency is met - System.gc() will be calledboolean
isPeriodicGcActive()
This method returns true, if periodic GC is active.void
memcpy(DataBuffer dstBuffer, DataBuffer srcBuffer)
This method does memcpy from source buffer to destination buffer PLEASE NOTE: This method is NOT safe.void
memset(INDArray array)
This method fills given INDArray with zeroes.void
notifyScopeEntered()
PLEASE NOTE: This method is under development yet.void
notifyScopeLeft()
PLEASE NOTE: This method is under development yet.void
purgeCaches()
This method purges all cached memory chunksvoid
release(org.bytedeco.javacpp.Pointer pointer, MemoryKind kind)
This method releases previously allocated memory chunkvoid
releaseCurrentContext()
This method releases Context (if current backend has one, sure)MemoryWorkspace
scopeOutOfWorkspaces()
This method temporary opens block out of any workspace scope.void
setAutoGcWindow(int windowMillis)
This method enables/disables periodic System.gc() calls.void
setCurrentWorkspace(MemoryWorkspace workspace)
void
setOccasionalGcFrequency(int frequency)
Sets manual GC invocation frequency.void
toggleAveraging(boolean enabled)
This method enables/disables calculation of average time spent within loops Default: falsevoid
togglePeriodicGc(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)
-
-