public class BasicContextPool extends Object implements ContextPool
Modifier and Type | Field and Description |
---|---|
protected Map<Integer,Map<Integer,CudaContext>> |
contextsForDevices |
protected Map<Long,CudaContext> |
contextsPool |
protected Map<Integer,cublasHandle_t> |
cublasPool |
protected Map<Integer,CUcontext> |
cuPool |
protected Semaphore |
lock |
protected static org.slf4j.Logger |
logger |
protected static int |
MAX_STREAMS_PER_DEVICE |
protected NativeOps |
nativeOps |
Constructor and Description |
---|
BasicContextPool() |
Modifier and Type | Method and Description |
---|---|
CudaContext |
acquireContextForDevice(Integer deviceId) |
ContextPack |
acquireContextPackForDevice(Integer deviceId) |
boolean |
containsContextForThread(long threadId) |
protected CUcontext |
createNewContext(Integer deviceId) |
protected cublasHandle_t |
createNewCublasHandle() |
protected cublasHandle_t |
createNewCublasHandle(cudaStream_t stream) |
protected CudaContext |
createNewStream(Integer deviceId) |
CudaContext |
getContextForDevice(Integer deviceId) |
CUcontext |
getCuContextForDevice(Integer deviceId) |
protected void |
getDeviceBuffers(CudaContext context,
int deviceId)
This method is used to allocate
|
void |
resetPool(int deviceId)
This methods reset everything in pool, forcing recreation of all streams
PLEASE NOTE: This is debugging-related method, and should NOT be used in real tasks
|
protected static final int MAX_STREAMS_PER_DEVICE
protected volatile Map<Integer,cublasHandle_t> cublasPool
protected volatile Map<Long,CudaContext> contextsPool
protected volatile Map<Integer,Map<Integer,CudaContext>> contextsForDevices
protected Semaphore lock
protected static org.slf4j.Logger logger
protected NativeOps nativeOps
public boolean containsContextForThread(long threadId)
public CudaContext getContextForDevice(Integer deviceId)
public CudaContext acquireContextForDevice(Integer deviceId)
acquireContextForDevice
in interface ContextPool
protected CudaContext createNewStream(Integer deviceId)
protected cublasHandle_t createNewCublasHandle()
protected cublasHandle_t createNewCublasHandle(cudaStream_t stream)
public void resetPool(int deviceId)
protected void getDeviceBuffers(CudaContext context, int deviceId)
context
- deviceId
- public ContextPack acquireContextPackForDevice(Integer deviceId)
acquireContextPackForDevice
in interface ContextPool
Copyright © 2016. All Rights Reserved.