public class AtomicAllocator extends Object implements Allocator
Modifier | Constructor and Description |
---|---|
protected |
AtomicAllocator() |
Modifier and Type | Method and Description |
---|---|
AllocationPoint |
allocateMemory(DataBuffer buffer,
AllocationShape requiredMemory,
AllocationStatus location,
boolean initialize)
This method allocates required chunk of memory in specific location
|
AllocationPoint |
allocateMemory(DataBuffer buffer,
AllocationShape requiredMemory,
boolean initialize)
This method allocates required chunk of memory
|
void |
applyConfiguration(Configuration configuration)
Consume and apply configuration passed in as argument
PLEASE NOTE: This method should only be used BEFORE any calculations were started.
|
AllocationPoint |
getAllocationPoint(DataBuffer buffer) |
AllocationPoint |
getAllocationPoint(INDArray array) |
protected AllocationPoint |
getAllocationPoint(Long objectId)
This method returns AllocationPoint POJO for specified tracking ID
|
Configuration |
getConfiguration()
Returns current Allocator configuration
|
DataBuffer |
getConstantBuffer(double[] array) |
DataBuffer |
getConstantBuffer(float[] array) |
DataBuffer |
getConstantBuffer(int[] array) |
ContextPool |
getContextPool() |
ExternalContext |
getDeviceContext()
This method returns CudaContext for current thread
|
Integer |
getDeviceId()
This method returns deviceId for current thread
All values >= 0 are considered valid device IDs, all values < 0 are considered stubs.
|
Integer |
getDeviceId(INDArray array)
This method returns CUDA deviceId for specified buffer
|
org.bytedeco.javacpp.Pointer |
getDeviceIdPointer()
Returns
getDeviceId() wrapped as a Pointer . |
FlowController |
getFlowController() |
org.bytedeco.javacpp.Pointer |
getHostPointer(DataBuffer buffer)
This method returns actual host pointer valid for current object
|
org.bytedeco.javacpp.Pointer |
getHostPointer(INDArray array)
This method returns actual host pointer valid for current object
|
static AtomicAllocator |
getInstance() |
org.bytedeco.javacpp.Pointer |
getPointer(DataBuffer buffer,
AllocationShape shape,
boolean isView,
CudaContext context)
Deprecated.
|
org.bytedeco.javacpp.Pointer |
getPointer(DataBuffer buffer,
CudaContext context)
This method returns actual device pointer valid for current object
|
org.bytedeco.javacpp.Pointer |
getPointer(INDArray array,
CudaContext context)
This method returns actual device pointer valid for specified INDArray
|
long |
getTotalAllocatedDeviceMemory(Integer deviceId)
This method returns total amount of memory allocated on specified device
|
long |
getTotalAllocatedHostMemory()
This method returns the number of tracked zero-copy allocations
|
protected int |
getTotalTrackingPoints()
This method returns the number of all tracked memory chunks
|
protected void |
initDeviceCollectors()
This method executes garbage collectors for each special device (i.e.
|
protected void |
initHostCollectors()
This method executes preconfigured number of host memory garbage collectors
|
void |
memcpy(DataBuffer dstBuffer,
DataBuffer srcBuffer)
This method implements blocking memcpy
|
void |
memcpyAsync(DataBuffer dstBuffer,
org.bytedeco.javacpp.Pointer srcPointer,
long length,
long dstOffset)
This method implements asynchronous memcpy, if that's available on current hardware
|
void |
memcpyBlocking(DataBuffer dstBuffer,
org.bytedeco.javacpp.Pointer srcPointer,
long length,
long dstOffset)
This method implements blocking memcpy
|
void |
memcpyDevice(DataBuffer dstBuffer,
org.bytedeco.javacpp.Pointer srcPointer,
long length,
long dstOffset,
CudaContext context) |
void |
memcpySpecial(DataBuffer dstBuffer,
org.bytedeco.javacpp.Pointer srcPointer,
long length,
long dstOffset) |
DataBuffer |
moveToConstant(DataBuffer dataBuffer) |
protected void |
purgeDeviceObject(Long threadId,
Integer deviceId,
Long objectId,
AllocationPoint point,
boolean copyback)
This method frees native device memory referenced by specified tracking id/AllocationPoint
|
protected void |
purgeZeroObject(Long bucketId,
Long objectId,
AllocationPoint point,
boolean copyback)
This method frees native system memory referenced by specified tracking id/AllocationPoint
|
void |
registerAction(CudaContext context,
INDArray result,
INDArray... operands) |
protected long |
seekUnusedDevice(Long threadId,
Integer deviceId,
Aggressiveness aggressiveness)
This method seeks for unused device memory allocations, for specified thread and device
|
protected long |
seekUnusedZero(Long bucketId,
Aggressiveness aggressiveness)
This method seeks for unused zero-copy memory allocations
|
void |
setMemoryHandler(MemoryHandler memoryHandler)
This method specifies Mover implementation to be used internally
|
void |
synchronizeHostData(DataBuffer buffer)
This method should be called to make sure that data on host side is actualized
|
void |
synchronizeHostData(INDArray array)
This method should be called to make sure that data on host side is actualized
|
void |
tickDeviceWrite(INDArray array) |
void |
tickHostWrite(DataBuffer buffer) |
void |
tickHostWrite(INDArray array) |
public static AtomicAllocator getInstance()
protected void initHostCollectors()
protected void initDeviceCollectors()
public ExternalContext getDeviceContext()
getDeviceContext
in interface Allocator
public void setMemoryHandler(@NonNull MemoryHandler memoryHandler)
setMemoryHandler
in interface Allocator
memoryHandler
- public void applyConfiguration(@NonNull Configuration configuration)
applyConfiguration
in interface Allocator
configuration
- configuration bean to be appliedpublic Configuration getConfiguration()
getConfiguration
in interface Allocator
public org.bytedeco.javacpp.Pointer getPointer(DataBuffer buffer, CudaContext context)
getPointer
in interface Allocator
buffer
- @Deprecated public org.bytedeco.javacpp.Pointer getPointer(DataBuffer buffer, AllocationShape shape, boolean isView, CudaContext context)
getPointer
in interface Allocator
buffer
- shape
- isView
- public org.bytedeco.javacpp.Pointer getPointer(INDArray array, CudaContext context)
getPointer
in interface Allocator
array
- public org.bytedeco.javacpp.Pointer getHostPointer(INDArray array)
getHostPointer
in interface Allocator
array
- public org.bytedeco.javacpp.Pointer getHostPointer(DataBuffer buffer)
getHostPointer
in interface Allocator
buffer
- public void synchronizeHostData(INDArray array)
synchronizeHostData
in interface Allocator
array
- public void synchronizeHostData(DataBuffer buffer)
synchronizeHostData
in interface Allocator
buffer
- public Integer getDeviceId(INDArray array)
array
- public AllocationPoint allocateMemory(DataBuffer buffer, AllocationShape requiredMemory, boolean initialize)
allocateMemory
in interface Allocator
requiredMemory
- public AllocationPoint allocateMemory(DataBuffer buffer, AllocationShape requiredMemory, AllocationStatus location, boolean initialize)
PLEASE NOTE: Do not use this method, unless you're 100% sure what you're doing
allocateMemory
in interface Allocator
requiredMemory
- location
- protected AllocationPoint getAllocationPoint(Long objectId)
objectId
- protected void purgeZeroObject(Long bucketId, Long objectId, AllocationPoint point, boolean copyback)
bucketId
- objectId
- point
- copyback
- protected void purgeDeviceObject(Long threadId, Integer deviceId, Long objectId, AllocationPoint point, boolean copyback)
threadId
- deviceId
- objectId
- point
- copyback
- protected long seekUnusedZero(Long bucketId, Aggressiveness aggressiveness)
bucketId
- Id of the bucket, serving allocationsprotected long seekUnusedDevice(Long threadId, Integer deviceId, Aggressiveness aggressiveness)
threadId
- Id of the thread, retrieved via Thread.currentThread().getId()deviceId
- Id of the devicepublic long getTotalAllocatedHostMemory()
protected int getTotalTrackingPoints()
public long getTotalAllocatedDeviceMemory(Integer deviceId)
deviceId
- public void memcpyAsync(DataBuffer dstBuffer, org.bytedeco.javacpp.Pointer srcPointer, long length, long dstOffset)
memcpyAsync
in interface Allocator
dstBuffer
- srcPointer
- length
- dstOffset
- public void memcpySpecial(DataBuffer dstBuffer, org.bytedeco.javacpp.Pointer srcPointer, long length, long dstOffset)
memcpySpecial
in interface Allocator
public void memcpyDevice(DataBuffer dstBuffer, org.bytedeco.javacpp.Pointer srcPointer, long length, long dstOffset, CudaContext context)
memcpyDevice
in interface Allocator
public void memcpyBlocking(DataBuffer dstBuffer, org.bytedeco.javacpp.Pointer srcPointer, long length, long dstOffset)
memcpyBlocking
in interface Allocator
dstBuffer
- srcPointer
- length
- dstOffset
- public void memcpy(DataBuffer dstBuffer, DataBuffer srcBuffer)
public Integer getDeviceId()
getDeviceId
in interface Allocator
public org.bytedeco.javacpp.Pointer getDeviceIdPointer()
getDeviceId()
wrapped as a Pointer
.getDeviceIdPointer
in interface Allocator
public void tickHostWrite(DataBuffer buffer)
tickHostWrite
in interface Allocator
public void tickHostWrite(INDArray array)
tickHostWrite
in interface Allocator
public void tickDeviceWrite(INDArray array)
tickDeviceWrite
in interface Allocator
public AllocationPoint getAllocationPoint(INDArray array)
getAllocationPoint
in interface Allocator
public AllocationPoint getAllocationPoint(DataBuffer buffer)
getAllocationPoint
in interface Allocator
public void registerAction(CudaContext context, INDArray result, INDArray... operands)
registerAction
in interface Allocator
public FlowController getFlowController()
getFlowController
in interface Allocator
public ContextPool getContextPool()
getContextPool
in interface Allocator
public DataBuffer getConstantBuffer(int[] array)
getConstantBuffer
in interface Allocator
public DataBuffer getConstantBuffer(float[] array)
getConstantBuffer
in interface Allocator
public DataBuffer getConstantBuffer(double[] array)
getConstantBuffer
in interface Allocator
public DataBuffer moveToConstant(DataBuffer dataBuffer)
moveToConstant
in interface Allocator
Copyright © 2016. All Rights Reserved.