public abstract class Nd4jWorkspace extends Object implements MemoryWorkspace
MemoryWorkspace.TypeDEFAULT_ID| Constructor and Description |
|---|
Nd4jWorkspace(@NonNull WorkspaceConfiguration configuration) |
Nd4jWorkspace(@NonNull WorkspaceConfiguration configuration,
@NonNull String workspaceId) |
| Modifier and Type | Method and Description |
|---|---|
PagedPointer |
alloc(long requiredMemory,
DataType type,
boolean initialize)
This method does allocation from a given Workspace
|
PagedPointer |
alloc(long requiredMemory,
MemoryKind kind,
DataType type,
boolean initialize)
This method does allocation from a given Workspace
|
protected abstract void |
clearExternalAllocations() |
protected abstract void |
clearPinnedAllocations(boolean extended) |
void |
close()
This method is for compatibility with "try-with-resources" java blocks.
|
void |
destroyWorkspace()
This method causes Workspace destruction: all memory allocations are released after this call.
|
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 |
getCurrentOffset()
This mehtod returns current offset within buffer
|
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()
This method returns current generation Id
|
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()
This method returns Type of this workspace
|
protected void |
init() |
void |
initializeWorkspace()
This method causes Workspace initialization
PLEASE NOTE: This call will have no effect on previously initialized Workspace
|
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()
This method notifies given Workspace that new use cycle is starting now
|
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()
This method temporary disables this workspace
|
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, getPrimaryOffset, getThreadId, getWorkspaceConfiguration, setPreviousWorkspacedeallocator, getUniqueId, targetDeviceprotected 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 static final int alignmentBase
public Nd4jWorkspace(@NonNull
@NonNull WorkspaceConfiguration configuration)
public Nd4jWorkspace(@NonNull
@NonNull WorkspaceConfiguration configuration,
@NonNull
@NonNull String workspaceId)
public MemoryWorkspace.Type getWorkspaceType()
MemoryWorkspacegetWorkspaceType in interface MemoryWorkspacepublic long getGenerationId()
MemoryWorkspacegetGenerationId 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 MemoryWorkspacepublic long getCurrentOffset()
MemoryWorkspacegetCurrentOffset in interface MemoryWorkspaceprotected void init()
public PagedPointer alloc(long requiredMemory, DataType type, boolean initialize)
MemoryWorkspacealloc in interface MemoryWorkspacerequiredMemory - allocation size, in bytestype - dataType that is going to be usedpublic void enableDebug(boolean reallyEnable)
enableDebug in interface MemoryWorkspacereallyEnable - public PagedPointer alloc(long requiredMemory, MemoryKind kind, DataType type, boolean initialize)
MemoryWorkspacealloc in interface MemoryWorkspacerequiredMemory - allocation size, in byteskind - MemoryKind for allocationtype - dataType that is going to be usedpublic void free(org.bytedeco.javacpp.Pointer pointer)
public void initializeWorkspace()
MemoryWorkspaceinitializeWorkspace in interface MemoryWorkspacepublic int getNumberOfExternalAllocations()
public int getNumberOfPinnedAllocations()
public void destroyWorkspace()
MemoryWorkspacedestroyWorkspace in interface MemoryWorkspacepublic void destroyWorkspace(boolean extended)
destroyWorkspace in interface MemoryWorkspaceextended - public MemoryWorkspace notifyScopeBorrowed()
notifyScopeBorrowed in interface MemoryWorkspacepublic long getCyclesCount()
public void close()
MemoryWorkspaceclose in interface AutoCloseableclose in interface MemoryWorkspaceprotected abstract void clearPinnedAllocations(boolean extended)
protected abstract void clearExternalAllocations()
public MemoryWorkspace notifyScopeEntered()
MemoryWorkspacenotifyScopeEntered 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()
MemoryWorkspacetagOutOfScopeUse in interface MemoryWorkspaceCopyright © 2021. All rights reserved.