public class GPUContext extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static org.apache.commons.logging.Log |
LOG |
| Modifier | Constructor and Description |
|---|---|
protected |
GPUContext(int deviceNum) |
| Modifier and Type | Method and Description |
|---|---|
jcuda.Pointer |
allocate(long size)
Convenience method for
allocate(String, long). |
jcuda.Pointer |
allocate(String instructionName,
long size)
Invokes memory manager's malloc method
|
void |
clearMemory()
Clears all memory used by this
GPUContext. |
void |
clearTemporaryMemory() |
GPUObject |
createGPUObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject mo)
Instantiates a new
GPUObject initialized with the given MatrixObject. |
void |
cudaFreeHelper(jcuda.Pointer toFree)
Does lazy cudaFree calls.
|
void |
cudaFreeHelper(jcuda.Pointer toFree,
boolean eager)
Does lazy/eager cudaFree calls.
|
void |
cudaFreeHelper(String instructionName,
jcuda.Pointer toFree)
Does lazy cudaFree calls.
|
void |
cudaFreeHelper(String instructionName,
jcuda.Pointer toFree,
boolean eager)
Does cudaFree calls, lazily.
|
static int |
cudaGetDevice()
Returns which device is currently being used.
|
void |
destroy()
Destroys this GPUContext object.
|
void |
ensureComputeCapability()
Makes sure that GPU that SystemML is trying to use has the minimum compute capability needed.
|
long |
getAvailableMemory()
Gets the available memory on GPU that SystemML can use.
|
jcuda.jcublas.cublasHandle |
getCublasHandle()
Returns cublasHandle for BLAS operations on the GPU.
|
jcuda.jcudnn.cudnnHandle |
getCudnnHandle()
Returns the cudnnHandle for Deep Neural Network operations on the GPU.
|
jcuda.jcusolver.cusolverDnHandle |
getCusolverDnHandle()
Returns cusolverDnHandle for invoking solve() function on dense matrices on the GPU.
|
jcuda.jcusparse.cusparseHandle |
getCusparseHandle()
Returns cusparseHandle for certain sparse BLAS operations on the GPU.
|
int |
getDeviceNum()
Returns which device is assigned to this GPUContext instance.
|
jcuda.runtime.cudaDeviceProp |
getGPUProperties()
Gets the device properties for the active GPU (set with cudaSetDevice()).
|
JCudaKernels |
getKernels()
Returns utility class used to launch custom CUDA kernel, specific to the active GPU for this GPUContext.
|
int |
getMaxBlocks()
Gets the maximum number of blocks supported by the active cuda device.
|
long |
getMaxSharedMemory()
Gets the shared memory per block supported by the active cuda device.
|
int |
getMaxThreadsPerBlock()
Gets the maximum number of threads per block for "active" GPU.
|
GPUMemoryManager |
getMemoryManager() |
int |
getWarpSize()
Gets the warp size supported by the active cuda device.
|
void |
initializeThread()
Sets the device for the calling thread.
|
void |
printMemoryInfo(String opcode)
Print information of memory usage.
|
String |
toString() |
protected GPUContext(int deviceNum)
throws DMLRuntimeException
DMLRuntimeExceptionpublic GPUMemoryManager getMemoryManager()
public static int cudaGetDevice()
public void printMemoryInfo(String opcode) throws DMLRuntimeException
opcode - opcode of callerDMLRuntimeException - if errorpublic int getDeviceNum()
public void initializeThread()
throws DMLRuntimeException
ExecutionContext.getGPUContext(int)
If in a multi-threaded environment like parfor, this method must be called when in the
appropriate thread.DMLRuntimeException - if DMLRuntimeException occurspublic jcuda.Pointer allocate(long size)
throws DMLRuntimeException
allocate(String, long).size - size of data (in bytes) to allocateDMLRuntimeException - if DMLRuntimeException occurspublic jcuda.Pointer allocate(String instructionName, long size) throws DMLRuntimeException
instructionName - name of instruction for which to record per instruction performance statistics, null if don't want to recordsize - size of data (in bytes) to allocateDMLRuntimeException - if DMLRuntimeException occurspublic void cudaFreeHelper(jcuda.Pointer toFree)
throws DMLRuntimeException
toFree - Pointer instance to be freedDMLRuntimeException - if errorpublic void cudaFreeHelper(jcuda.Pointer toFree,
boolean eager)
throws DMLRuntimeException
toFree - Pointer instance to be freedeager - true if to be done eagerlyDMLRuntimeException - if errorpublic void cudaFreeHelper(String instructionName, jcuda.Pointer toFree) throws DMLRuntimeException
instructionName - name of the instruction for which to record per instruction free time, null if do not want to recordtoFree - Pointer instance to be freedDMLRuntimeException - if errorpublic void cudaFreeHelper(String instructionName, jcuda.Pointer toFree, boolean eager) throws DMLRuntimeException
instructionName - name of the instruction for which to record per instruction free time, null if do not want to recordtoFree - Pointer instance to be freedeager - true if to be done eagerlyDMLRuntimeException - if errorpublic long getAvailableMemory()
public void ensureComputeCapability()
throws DMLRuntimeException
DMLRuntimeException - if the compute capability is less than what is requiredpublic GPUObject createGPUObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject mo)
GPUObject initialized with the given MatrixObject.mo - a MatrixObject that represents a matrixGPUObject instancepublic jcuda.runtime.cudaDeviceProp getGPUProperties()
throws DMLRuntimeException
DMLRuntimeException - ?public int getMaxThreadsPerBlock()
throws DMLRuntimeException
DMLRuntimeException - ?public int getMaxBlocks()
throws DMLRuntimeException
DMLRuntimeException - ?public long getMaxSharedMemory()
throws DMLRuntimeException
DMLRuntimeException - ?public int getWarpSize()
throws DMLRuntimeException
DMLRuntimeException - ?public jcuda.jcudnn.cudnnHandle getCudnnHandle()
public jcuda.jcublas.cublasHandle getCublasHandle()
public jcuda.jcusparse.cusparseHandle getCusparseHandle()
public jcuda.jcusolver.cusolverDnHandle getCusolverDnHandle()
public JCudaKernels getKernels()
JCudaKernels for current threadpublic void destroy()
throws DMLRuntimeException
DMLRuntimeException - if errorpublic void clearMemory()
throws DMLRuntimeException
GPUContext.
Be careful to ensure that no memory is currently being used in the temporary memory before invoking this.
If memory is being used between MLContext invocations, they are pointed to by a GPUObject instance
which would be part of the MatrixObject. The cleanup of that MatrixObject instance will
cause the memory associated with that block on the GPU to be freed up.DMLRuntimeException - ?public void clearTemporaryMemory()
throws DMLRuntimeException
DMLRuntimeExceptionCopyright © 2018 The Apache Software Foundation. All rights reserved.