public abstract class Nd4jWorkspace extends Object implements MemoryWorkspace
Modifier and Type | Class and Description |
---|---|
static class |
Nd4jWorkspace.GarbageWorkspaceReference |
DEFAULT_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
|
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 |
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
|
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, wait
getDeviceId, getId, getThreadId, getWorkspaceConfiguration
protected int deviceId
protected Long threadId
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
public Nd4jWorkspace(@NonNull WorkspaceConfiguration configuration)
public Nd4jWorkspace(@NonNull WorkspaceConfiguration configuration, @NonNull String workspaceId)
public long getStepNumber()
public long getSpilledSize()
public long getPinnedSize()
public long getInitialBlockSize()
public MemoryWorkspace getParentWorkspace()
getParentWorkspace
in interface MemoryWorkspace
public long getDeviceOffset()
public long getHostOffset()
public long getCurrentSize()
getCurrentSize
in interface MemoryWorkspace
protected void init()
public PagedPointer alloc(long requiredMemory, DataBuffer.Type type, boolean initialize)
alloc
in interface MemoryWorkspace
public void enableDebug(boolean reallyEnable)
enableDebug
in interface MemoryWorkspace
reallyEnable
- public PagedPointer alloc(long requiredMemory, MemoryKind kind, DataBuffer.Type type, boolean initialize)
alloc
in interface MemoryWorkspace
public void free(org.bytedeco.javacpp.Pointer pointer)
public void initializeWorkspace()
initializeWorkspace
in interface MemoryWorkspace
public int getNumberOfExternalAllocations()
public int getNumberOfPinnedAllocations()
public void destroyWorkspace()
destroyWorkspace
in interface MemoryWorkspace
public void destroyWorkspace(boolean extended)
destroyWorkspace
in interface MemoryWorkspace
extended
- public MemoryWorkspace notifyScopeBorrowed()
notifyScopeBorrowed
in interface MemoryWorkspace
public long getCyclesCount()
public void close()
close
in interface AutoCloseable
close
in interface MemoryWorkspace
protected abstract void clearPinnedAllocations(boolean extended)
protected abstract void clearExternalAllocations()
public MemoryWorkspace notifyScopeEntered()
notifyScopeEntered
in interface MemoryWorkspace
public void reset()
protected abstract void resetWorkspace()
public MemoryWorkspace notifyScopeLeft()
notifyScopeLeft
in interface MemoryWorkspace
public void toggleWorkspaceUse(boolean isEnabled)
toggleWorkspaceUse
in interface MemoryWorkspace
isEnabled
- public long getLastCycleAllocations()
getLastCycleAllocations
in interface MemoryWorkspace
public long getThisCycleAllocations()
getThisCycleAllocations
in interface MemoryWorkspace
public long getMaxCycleAllocations()
getMaxCycleAllocations
in interface MemoryWorkspace
public boolean isScopeActive()
isScopeActive
in interface MemoryWorkspace
public MemoryWorkspace tagOutOfScopeUse()
tagOutOfScopeUse
in interface MemoryWorkspace
Copyright © 2017. All rights reserved.