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(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(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() |
public GPUMemoryManager getMemoryManager()
public static int cudaGetDevice()
public void printMemoryInfo(String opcode)
opcode
- opcode of callerpublic int getDeviceNum()
public void initializeThread()
ExecutionContext.getGPUContext(int)
If in a multi-threaded environment like parfor, this method must be called when in the
appropriate thread.public jcuda.Pointer allocate(String instructionName, long size)
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 allocatepublic void cudaFreeHelper(String instructionName, jcuda.Pointer toFree, boolean eager)
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 eagerlypublic long getAvailableMemory()
public void ensureComputeCapability()
public 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()
public int getMaxThreadsPerBlock()
public int getMaxBlocks()
public long getMaxSharedMemory()
public int getWarpSize()
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()
public void clearMemory()
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.public void clearTemporaryMemory()
Copyright © 2018 The Apache Software Foundation. All rights reserved.