public class GPU extends Object
This is the main class to perform computation on the GPU. Create a GPU via
the factory methods create(..)
GPU gpu = GPU.create(); // Creates a gpu with the JavaCL.createBestContext() FloatMatrix C = gpu.multiplyLocal(A, B);
Note that this is currently in experimental stadium. You cannot influence
the parameters of the openCL kernels. So blocksize,
workgroupsize and
localworkgroupsize are hardcoded. This may change in future
releases.
Modifier and Type | Method and Description |
---|---|
static GPU |
create() |
static GPU |
create(com.nativelibs4java.opencl.CLContext context) |
protected static org.bridj.Pointer<Float> |
matrixToPointer(FloatMatrix matrix) |
protected static org.bridj.Pointer<Double> |
matrixToPointer(Matrix matrix) |
FloatMatrix |
multiply(FloatMatrix A,
FloatMatrix B)
Use the naive openCL kernel, which computes more exact results than the
local variant.
|
FloatMatrix |
multiplyLocal(FloatMatrix A,
FloatMatrix B)
Use the local optimized openCL kernel, which may yield worse results than
the non local variant.
|
protected static FloatMatrix |
pointerToFloatMatrix(org.bridj.Pointer<Float> pointer,
int rows,
int cols) |
protected static Matrix |
pointerToMatrix(org.bridj.Pointer<Double> pointer,
int rows,
int cols) |
protected static FloatMatrix |
removeZeroPadding(FloatMatrix result,
FloatMatrix A,
FloatMatrix B)
Removes the zero padding from the result matrix.
|
protected static int |
workgroupSize(int size,
int blocksize) |
protected static FloatMatrix |
zeroPadding(FloatMatrix matrix,
int workgroupSize)
Returns a padded matrix with width/height of a correct factor determined
by the workgroupSize.
|
public static GPU create()
public static GPU create(com.nativelibs4java.opencl.CLContext context)
public FloatMatrix multiply(FloatMatrix A, FloatMatrix B) throws IOException
A
- - Left input matrixB
- - Right input matrixIOException
public FloatMatrix multiplyLocal(FloatMatrix A, FloatMatrix B) throws IOException
A
- - left input matrixB
- - right input matrixIOException
protected static org.bridj.Pointer<Float> matrixToPointer(FloatMatrix matrix)
protected static Matrix pointerToMatrix(org.bridj.Pointer<Double> pointer, int rows, int cols)
protected static FloatMatrix pointerToFloatMatrix(org.bridj.Pointer<Float> pointer, int rows, int cols)
protected static int workgroupSize(int size, int blocksize)
size
- protected static FloatMatrix zeroPadding(FloatMatrix matrix, int workgroupSize)
matrix
- workgroupSize
- protected static FloatMatrix removeZeroPadding(FloatMatrix result, FloatMatrix A, FloatMatrix B)
result
- - result matrix created with zero padded matricesA
- - original non-padded matrixB
- - original non-padded matrixCopyright © 2012. All Rights Reserved.