public abstract class Nd4jWorkspace extends Object implements MemoryWorkspace
| Modifier and Type | Class and Description |
|---|---|
static class |
Nd4jWorkspace.GarbageWorkspaceReference |
MemoryWorkspace.TypeDEFAULT_ID| Constructor and Description |
|---|
Nd4jWorkspace(WorkspaceConfiguration configuration) |
Nd4jWorkspace(WorkspaceConfiguration configuration,
String workspaceId) |
| Modifier and Type | Method and Description |
|---|---|
PagedPointer |
alloc(long requiredMemory,
DataBuffer.Type type,
boolean initialize) |
PagedPointer |
alloc(long requiredMemory,
MemoryKind kind,
DataBuffer.Type type,
boolean initialize) |
protected abstract void |
clearExternalAllocations() |
protected abstract void |
clearPinnedAllocations(boolean extended) |
void |
close() |
void |
destroyWorkspace() |
void |
destroyWorkspace(boolean extended)
This method basically deallocates workspace memory
|
void |
enableDebug(boolean reallyEnable)
This method enabled debugging mode for this workspace
|
static void |
fillFile(File file,
long length) |
void |
free(org.bytedeco.javacpp.Pointer pointer) |
long |
getCurrentSize()
This method returns current amount of memory allocated for workspace.
|
long |
getCyclesCount() |
long |
getDeviceOffset()
This method returns current device memory offset within workspace
|
long |
getGenerationId() |
long |
getHostOffset()
This method returns current host memory offset within workspace
|
long |
getInitialBlockSize()
This method returns number of bytes for first block of circular workspace.
|
long |
getLastCycleAllocations()
This method returns number of bytes allocated during last full cycle
|
long |
getMaxCycleAllocations()
This method returns number of bytes of biggest cycle
|
int |
getNumberOfExternalAllocations()
This method returns number of spilled allocations, that can be purged at the end of block
|
int |
getNumberOfPinnedAllocations()
This method returns number of pinned allocations, they can be purged after 2 steps.
|
MemoryWorkspace |
getParentWorkspace()
This method returns parent Workspace, if any.
|
long |
getPinnedSize()
This method returns number of bytes in pinned allocations.
|
long |
getSpilledSize()
This method returns number of bytes in spilled allocations.
|
long |
getStepNumber()
This method returns step number.
|
long |
getThisCycleAllocations()
This method returns number of bytes allocated during THIS cycle
|
MemoryWorkspace.Type |
getWorkspaceType() |
protected void |
init() |
void |
initializeWorkspace() |
boolean |
isScopeActive()
This method returns True if scope was opened, and not closed yet.
|
MemoryWorkspace |
notifyScopeBorrowed()
This method TEMPORARY enters this workspace, without reset applied
|
MemoryWorkspace |
notifyScopeEntered() |
MemoryWorkspace |
notifyScopeLeft()
This method is shortcut to close() method
|
void |
reset()
This method reset host/device offsets within workspace
PLEASE NOTE: Never call this method unless you realize all consequences
|
protected abstract void |
resetWorkspace() |
MemoryWorkspace |
tagOutOfScopeUse() |
void |
toggleWorkspaceUse(boolean isEnabled)
This method allows to temporary disable this workspace, and issue allocations directly.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDeviceId, getId, getThreadId, getWorkspaceConfiguration, setPreviousWorkspaceprotected int deviceId
protected Long threadId
protected MemoryWorkspace.Type workspaceType
protected static final long SAFETY_OFFSET
protected String id
protected AtomicLong currentSize
protected AtomicLong hostOffset
protected AtomicLong deviceOffset
protected PointersPair workspace
protected MemoryManager memoryManager
protected AtomicBoolean isLearning
protected AtomicBoolean isUsed
protected AtomicLong disabledCounter
protected AtomicLong cyclesCount
protected AtomicLong stepsCount
protected int stepsNumber
protected AtomicLong lastCycleAllocations
protected AtomicLong cycleAllocations
protected AtomicLong spilledAllocationsSize
protected AtomicLong pinnedAllocationsSize
protected AtomicLong maxCycle
protected AtomicBoolean resetPlanned
protected AtomicBoolean isOpen
protected AtomicBoolean isInit
protected AtomicBoolean isOver
protected AtomicBoolean isBorrowed
protected AtomicInteger tagScope
protected AtomicBoolean isDebug
protected AtomicInteger externalCount
protected AtomicInteger pinnedCount
protected AtomicBoolean trimmedMode
protected AtomicLong trimmedStep
protected final WorkspaceConfiguration workspaceConfiguration
protected List<PointersPair> externalAllocations
protected Queue<PointersPair> pinnedAllocations
protected MemoryWorkspace previousWorkspace
protected MemoryWorkspace borrowingWorkspace
protected AtomicLong initialBlockSize
protected String guid
protected File tempFile
protected AtomicLong generationId
public Nd4jWorkspace(@NonNull
WorkspaceConfiguration configuration)
public Nd4jWorkspace(@NonNull
WorkspaceConfiguration configuration,
@NonNull
String workspaceId)
public MemoryWorkspace.Type getWorkspaceType()
getWorkspaceType in interface MemoryWorkspacepublic long getGenerationId()
getGenerationId in interface MemoryWorkspacepublic long getStepNumber()
public long getSpilledSize()
public long getPinnedSize()
public long getInitialBlockSize()
public MemoryWorkspace getParentWorkspace()
getParentWorkspace in interface MemoryWorkspacepublic long getDeviceOffset()
public long getHostOffset()
public long getCurrentSize()
getCurrentSize in interface MemoryWorkspaceprotected void init()
public PagedPointer alloc(long requiredMemory, DataBuffer.Type type, boolean initialize)
alloc in interface MemoryWorkspacepublic void enableDebug(boolean reallyEnable)
enableDebug in interface MemoryWorkspacereallyEnable - public PagedPointer alloc(long requiredMemory, MemoryKind kind, DataBuffer.Type type, boolean initialize)
alloc in interface MemoryWorkspacepublic void free(org.bytedeco.javacpp.Pointer pointer)
public void initializeWorkspace()
initializeWorkspace in interface MemoryWorkspacepublic int getNumberOfExternalAllocations()
public int getNumberOfPinnedAllocations()
public void destroyWorkspace()
destroyWorkspace in interface MemoryWorkspacepublic void destroyWorkspace(boolean extended)
destroyWorkspace in interface MemoryWorkspaceextended - public MemoryWorkspace notifyScopeBorrowed()
notifyScopeBorrowed in interface MemoryWorkspacepublic long getCyclesCount()
public void close()
close in interface AutoCloseableclose in interface MemoryWorkspaceprotected abstract void clearPinnedAllocations(boolean extended)
protected abstract void clearExternalAllocations()
public MemoryWorkspace notifyScopeEntered()
notifyScopeEntered in interface MemoryWorkspacepublic void reset()
protected abstract void resetWorkspace()
public MemoryWorkspace notifyScopeLeft()
notifyScopeLeft in interface MemoryWorkspacepublic void toggleWorkspaceUse(boolean isEnabled)
toggleWorkspaceUse in interface MemoryWorkspaceisEnabled - public long getLastCycleAllocations()
getLastCycleAllocations in interface MemoryWorkspacepublic long getThisCycleAllocations()
getThisCycleAllocations in interface MemoryWorkspacepublic long getMaxCycleAllocations()
getMaxCycleAllocations in interface MemoryWorkspacepublic boolean isScopeActive()
isScopeActive in interface MemoryWorkspacepublic MemoryWorkspace tagOutOfScopeUse()
tagOutOfScopeUse in interface MemoryWorkspaceCopyright © 2018. All rights reserved.