Package org.nd4j.linalg.api.concurrency
Class BasicAffinityManager
- java.lang.Object
-
- org.nd4j.linalg.api.concurrency.BasicAffinityManager
-
- All Implemented Interfaces:
AffinityManager
public abstract class BasicAffinityManager extends Object implements AffinityManager
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nd4j.linalg.api.concurrency.AffinityManager
AffinityManager.Location
-
-
Constructor Summary
Constructors Constructor Description BasicAffinityManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allowCrossDeviceAccess(boolean reallyAllow)
This method allows to block cross-device access.void
ensureLocation(INDArray array, AffinityManager.Location location)
This method propagates given INDArray to specified locationAffinityManager.Location
getActiveLocation(INDArray array)
This method returns last-updated location for the given INDArrayInteger
getDeviceForArray(INDArray array)
This method returns id of current device for a given INDArrayInteger
getDeviceForCurrentThread()
This method returns deviceId for current threadInteger
getDeviceForThread(long threadId)
This method returns deviceId for a given threadint
getNumberOfDevices()
This method returns number of available devicesboolean
isCrossDeviceAccessSupported()
This method returns TRUE if cross-device access is allowed on this systemDataBuffer
replicateToDevice(Integer deviceId, DataBuffer buffer)
This method replicates given DataBuffer, and places it to target device.INDArray
replicateToDevice(Integer deviceId, INDArray array)
This method replicates given INDArray, and places it to target device.void
tagLocation(DataBuffer buffer, AffinityManager.Location location)
This method tags specific DataBuffer as "recent" on specified locationvoid
tagLocation(INDArray array, AffinityManager.Location location)
This method tags specific INDArray as "recent" on specified locationvoid
unsafeSetDevice(Integer deviceId)
This method forces specific device for current thread.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nd4j.linalg.api.concurrency.AffinityManager
touch, touch
-
-
-
-
Method Detail
-
getDeviceForCurrentThread
public Integer getDeviceForCurrentThread()
Description copied from interface:AffinityManager
This method returns deviceId for current thread- Specified by:
getDeviceForCurrentThread
in interfaceAffinityManager
- Returns:
-
getDeviceForThread
public Integer getDeviceForThread(long threadId)
Description copied from interface:AffinityManager
This method returns deviceId for a given thread- Specified by:
getDeviceForThread
in interfaceAffinityManager
- Returns:
-
getDeviceForArray
public Integer getDeviceForArray(INDArray array)
Description copied from interface:AffinityManager
This method returns id of current device for a given INDArray- Specified by:
getDeviceForArray
in interfaceAffinityManager
- Returns:
-
getNumberOfDevices
public int getNumberOfDevices()
Description copied from interface:AffinityManager
This method returns number of available devices- Specified by:
getNumberOfDevices
in interfaceAffinityManager
- Returns:
-
replicateToDevice
public INDArray replicateToDevice(Integer deviceId, INDArray array)
This method replicates given INDArray, and places it to target device.- Specified by:
replicateToDevice
in interfaceAffinityManager
- Parameters:
deviceId
- target deviceIdarray
- INDArray to replicate- Returns:
-
replicateToDevice
public DataBuffer replicateToDevice(Integer deviceId, DataBuffer buffer)
This method replicates given DataBuffer, and places it to target device.- Specified by:
replicateToDevice
in interfaceAffinityManager
- Parameters:
deviceId
- target deviceIdbuffer
-- Returns:
-
tagLocation
public void tagLocation(INDArray array, AffinityManager.Location location)
Description copied from interface:AffinityManager
This method tags specific INDArray as "recent" on specified location- Specified by:
tagLocation
in interfaceAffinityManager
-
tagLocation
public void tagLocation(DataBuffer buffer, AffinityManager.Location location)
Description copied from interface:AffinityManager
This method tags specific DataBuffer as "recent" on specified location- Specified by:
tagLocation
in interfaceAffinityManager
-
unsafeSetDevice
public void unsafeSetDevice(Integer deviceId)
Description copied from interface:AffinityManager
This method forces specific device for current thread. PLEASE NOTE: This method is UNSAFE and should NOT be used with 100% clearance about it.- Specified by:
unsafeSetDevice
in interfaceAffinityManager
-
ensureLocation
public void ensureLocation(INDArray array, AffinityManager.Location location)
Description copied from interface:AffinityManager
This method propagates given INDArray to specified location- Specified by:
ensureLocation
in interfaceAffinityManager
-
isCrossDeviceAccessSupported
public boolean isCrossDeviceAccessSupported()
Description copied from interface:AffinityManager
This method returns TRUE if cross-device access is allowed on this system- Specified by:
isCrossDeviceAccessSupported
in interfaceAffinityManager
-
allowCrossDeviceAccess
public void allowCrossDeviceAccess(boolean reallyAllow)
Description copied from interface:AffinityManager
This method allows to block cross-device access. Mostly suitable for debugging/testing purposes- Specified by:
allowCrossDeviceAccess
in interfaceAffinityManager
-
getActiveLocation
public AffinityManager.Location getActiveLocation(INDArray array)
Description copied from interface:AffinityManager
This method returns last-updated location for the given INDArray- Specified by:
getActiveLocation
in interfaceAffinityManager
- Returns:
-
-