Class DummyWorkspace
- java.lang.Object
-
- org.nd4j.linalg.api.memory.abstracts.DummyWorkspace
-
- All Implemented Interfaces:
AutoCloseable
,Deallocatable
,MemoryWorkspace
public class DummyWorkspace extends Object implements MemoryWorkspace
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nd4j.linalg.api.memory.MemoryWorkspace
MemoryWorkspace.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected MemoryWorkspace
parentWorkspace
-
Fields inherited from interface org.nd4j.linalg.api.memory.MemoryWorkspace
DEFAULT_ID
-
-
Constructor Summary
Constructors Constructor Description DummyWorkspace()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PagedPointer
alloc(long requiredMemory, DataType dataType, boolean initialize)
This method does allocation from a given WorkspacePagedPointer
alloc(long requiredMemory, MemoryKind kind, DataType dataType, boolean initialize)
This method does allocation from a given Workspacevoid
close()
This method is for compatibility with "try-with-resources" java blocks.Deallocator
deallocator()
This method returns deallocator associated with this instancevoid
destroyWorkspace()
This method causes Workspace destruction: all memory allocations are released after this call.void
destroyWorkspace(boolean extended)
void
enableDebug(boolean reallyEnable)
This method enabled debugging mode for this workspacelong
getCurrentOffset()
This mehtod returns current offset within bufferlong
getCurrentSize()
This methos returns current allocated size of this workspaceint
getDeviceId()
Returns deviceId for this workspacelong
getGenerationId()
This method returns current generation IdString
getId()
This method returns Id of this workspacelong
getLastCycleAllocations()
This method returns amount of memory consumed in last successful cycle, in byteslong
getMaxCycleAllocations()
This method returns amount of memory consumed by largest successful cycle, in bytesMemoryWorkspace
getParentWorkspace()
This method returns parent Workspace, if any.long
getPrimaryOffset()
long
getThisCycleAllocations()
This method returns amount of memory consumed in last successful cycle, in bytesLong
getThreadId()
This method returns threadId where this workspace was createdString
getUniqueId()
This method returns unique ID for this instanceWorkspaceConfiguration
getWorkspaceConfiguration()
This method returns WorkspaceConfiguration bean that was used for given Workspace instanceMemoryWorkspace.Type
getWorkspaceType()
This method returns Type of this workspacevoid
initializeWorkspace()
This method causes Workspace initializationboolean
isScopeActive()
This method returns True if scope was opened, and not closed yet.MemoryWorkspace
notifyScopeBorrowed()
This method TEMPORARY enters this workspace, without reset appliedMemoryWorkspace
notifyScopeEntered()
This method notifies given Workspace that new use cycle is starting nowMemoryWorkspace
notifyScopeLeft()
This method notifies given Workspace that use cycle just endedvoid
setPreviousWorkspace(MemoryWorkspace memoryWorkspace)
Set the previous workspace, if any
NOTE: this method should only be used if you are fully aware of the consequences of doing so.MemoryWorkspace
tagOutOfScopeUse()
This method temporary disables this workspaceint
targetDevice()
This method returns deviceId it's affined with, so deallocator thread will be guaranteed to match itvoid
toggleWorkspaceUse(boolean isEnabled)
This method allows you to temporary disable/enable given Workspace use.
-
-
-
Field Detail
-
parentWorkspace
protected MemoryWorkspace parentWorkspace
-
-
Method Detail
-
getWorkspaceConfiguration
public WorkspaceConfiguration getWorkspaceConfiguration()
This method returns WorkspaceConfiguration bean that was used for given Workspace instance- Specified by:
getWorkspaceConfiguration
in interfaceMemoryWorkspace
- Returns:
-
getId
public String getId()
This method returns Id of this workspace- Specified by:
getId
in interfaceMemoryWorkspace
- Returns:
-
getThreadId
public Long getThreadId()
Description copied from interface:MemoryWorkspace
This method returns threadId where this workspace was created- Specified by:
getThreadId
in interfaceMemoryWorkspace
- Returns:
-
getDeviceId
public int getDeviceId()
Description copied from interface:MemoryWorkspace
Returns deviceId for this workspace- Specified by:
getDeviceId
in interfaceMemoryWorkspace
- Returns:
-
getWorkspaceType
public MemoryWorkspace.Type getWorkspaceType()
Description copied from interface:MemoryWorkspace
This method returns Type of this workspace- Specified by:
getWorkspaceType
in interfaceMemoryWorkspace
- Returns:
-
alloc
public PagedPointer alloc(long requiredMemory, DataType dataType, boolean initialize)
This method does allocation from a given Workspace- Specified by:
alloc
in interfaceMemoryWorkspace
- Parameters:
requiredMemory
- allocation size, in bytesdataType
- dataType that is going to be usedinitialize
-- Returns:
-
alloc
public PagedPointer alloc(long requiredMemory, MemoryKind kind, DataType dataType, boolean initialize)
This method does allocation from a given Workspace- Specified by:
alloc
in interfaceMemoryWorkspace
- Parameters:
requiredMemory
- allocation size, in byteskind
- MemoryKind for allocationdataType
- dataType that is going to be usedinitialize
-- Returns:
-
getGenerationId
public long getGenerationId()
Description copied from interface:MemoryWorkspace
This method returns current generation Id- Specified by:
getGenerationId
in interfaceMemoryWorkspace
- Returns:
-
notifyScopeEntered
public MemoryWorkspace notifyScopeEntered()
This method notifies given Workspace that new use cycle is starting now- Specified by:
notifyScopeEntered
in interfaceMemoryWorkspace
- Returns:
-
notifyScopeBorrowed
public MemoryWorkspace notifyScopeBorrowed()
This method TEMPORARY enters this workspace, without reset applied- Specified by:
notifyScopeBorrowed
in interfaceMemoryWorkspace
- Returns:
-
notifyScopeLeft
public MemoryWorkspace notifyScopeLeft()
This method notifies given Workspace that use cycle just ended- Specified by:
notifyScopeLeft
in interfaceMemoryWorkspace
- Returns:
-
isScopeActive
public boolean isScopeActive()
This method returns True if scope was opened, and not closed yet.- Specified by:
isScopeActive
in interfaceMemoryWorkspace
- Returns:
-
initializeWorkspace
public void initializeWorkspace()
This method causes Workspace initializationPLEASE NOTE: This call will have no effect on previously initialized Workspace
- Specified by:
initializeWorkspace
in interfaceMemoryWorkspace
-
destroyWorkspace
public void destroyWorkspace()
This method causes Workspace destruction: all memory allocations are released after this call.- Specified by:
destroyWorkspace
in interfaceMemoryWorkspace
-
destroyWorkspace
public void destroyWorkspace(boolean extended)
- Specified by:
destroyWorkspace
in interfaceMemoryWorkspace
-
toggleWorkspaceUse
public void toggleWorkspaceUse(boolean isEnabled)
This method allows you to temporary disable/enable given Workspace use. If turned off - direct memory allocations will be used.- Specified by:
toggleWorkspaceUse
in interfaceMemoryWorkspace
- Parameters:
isEnabled
-
-
getThisCycleAllocations
public long getThisCycleAllocations()
This method returns amount of memory consumed in last successful cycle, in bytes- Specified by:
getThisCycleAllocations
in interfaceMemoryWorkspace
- Returns:
-
enableDebug
public void enableDebug(boolean reallyEnable)
This method enabled debugging mode for this workspace- Specified by:
enableDebug
in interfaceMemoryWorkspace
- Parameters:
reallyEnable
-
-
getLastCycleAllocations
public long getLastCycleAllocations()
This method returns amount of memory consumed in last successful cycle, in bytes- Specified by:
getLastCycleAllocations
in interfaceMemoryWorkspace
- Returns:
-
getMaxCycleAllocations
public long getMaxCycleAllocations()
This method returns amount of memory consumed by largest successful cycle, in bytes- Specified by:
getMaxCycleAllocations
in interfaceMemoryWorkspace
- Returns:
-
getCurrentSize
public long getCurrentSize()
This methos returns current allocated size of this workspace- Specified by:
getCurrentSize
in interfaceMemoryWorkspace
- Returns:
-
close
public void close()
Description copied from interface:MemoryWorkspace
This method is for compatibility with "try-with-resources" java blocks. Internally it should be equal to notifyScopeLeft() method- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceMemoryWorkspace
-
getParentWorkspace
public MemoryWorkspace getParentWorkspace()
This method returns parent Workspace, if any. Null if there's none.- Specified by:
getParentWorkspace
in interfaceMemoryWorkspace
- Returns:
-
tagOutOfScopeUse
public MemoryWorkspace tagOutOfScopeUse()
Description copied from interface:MemoryWorkspace
This method temporary disables this workspace- Specified by:
tagOutOfScopeUse
in interfaceMemoryWorkspace
- Returns:
-
setPreviousWorkspace
public void setPreviousWorkspace(MemoryWorkspace memoryWorkspace)
Description copied from interface:MemoryWorkspace
Set the previous workspace, if any
NOTE: this method should only be used if you are fully aware of the consequences of doing so. Incorrect use of this method may leave workspace management in an invalid/indeterminant state!- Specified by:
setPreviousWorkspace
in interfaceMemoryWorkspace
- Parameters:
memoryWorkspace
- Workspace to set as the previous workspace. This is the workspace that will become active when this workspace is closed.
-
getCurrentOffset
public long getCurrentOffset()
Description copied from interface:MemoryWorkspace
This mehtod returns current offset within buffer- Specified by:
getCurrentOffset
in interfaceMemoryWorkspace
- Returns:
-
getUniqueId
public String getUniqueId()
Description copied from interface:Deallocatable
This method returns unique ID for this instance- Specified by:
getUniqueId
in interfaceDeallocatable
- Returns:
-
deallocator
public Deallocator deallocator()
Description copied from interface:Deallocatable
This method returns deallocator associated with this instance- Specified by:
deallocator
in interfaceDeallocatable
- Returns:
-
targetDevice
public int targetDevice()
Description copied from interface:Deallocatable
This method returns deviceId it's affined with, so deallocator thread will be guaranteed to match it- Specified by:
targetDevice
in interfaceDeallocatable
-
getPrimaryOffset
public long getPrimaryOffset()
- Specified by:
getPrimaryOffset
in interfaceMemoryWorkspace
-
-