CSol
Public Member Functions | List of all members
LinearAlgebra Class Reference

OpenCL linear algebra class. More...

#include <csol_la.h>

Public Member Functions

 LinearAlgebra (int, cl::Context &, cl::CommandQueue &, std::vector< cl::Device > &, int)
 LinearAlgebra constructor. More...
 
 LinearAlgebra (const LinearAlgebra &)
 
 ~LinearAlgebra ()
 
void copyIntBuffer (const cl::Buffer &, cl::Buffer &, int)
 LinearAlgebra integer buffer copy. More...
 
void copyRealBuffer (const cl::Buffer &, cl::Buffer &, int)
 LinearAlgebra floating-point buffer copy. More...
 
cl::Buffer createIntBuffer (int)
 LinearAlgebra integer buffer creation. More...
 
cl::Buffer createRealBuffer (int)
 LinearAlgebra floating-point buffer creation. More...
 
REAL Dot (const Vector &, const Vector &)
 LinearAlgebra vector dot product. More...
 
int getWorkGroupSize ()
 
void minusEqualsVector (cl::Buffer &, const cl::Buffer &, int, int)
 LinearAlgebra -= operation. More...
 
LinearAlgebraoperator= (const LinearAlgebra &)
 
void plusEqualsVector (cl::Buffer &, const cl::Buffer &, int, int)
 LinearAlgebra += operation. More...
 
void readIntBuffer (int *, const cl::Buffer &, int)
 LinearAlgebra integer read. More...
 
void readRealBuffer (REAL *, const cl::Buffer &, int)
 LinearAlgebra floating-point read. More...
 
void reserveSparseMatrix (int, int, int, int, cl::Buffer &, cl::Buffer &, cl::Buffer &, cl::Buffer &, cl::Buffer &)
 LinearAlgebra sparse matrix reservation implementation. More...
 
void setIntBuffer (cl::Buffer &, int, int)
 LinearAlgebra integer vector set operation. More...
 
void setRealBuffer (cl::Buffer &, REAL, int)
 LinearAlgebra floating-point vector set operation. More...
 
Vector Solve (const SparseMatrix &, const Vector &, const Vector &)
 LinearAlgebra sparse matrix solve. More...
 
void sparseMatrixProduct (const cl::Buffer &, cl::Buffer &, const cl::Buffer &, const cl::Buffer &, const cl::Buffer &, const cl::Buffer &, int, int)
 LinearAlgebra sparse matrix product implementation. More...
 
void timesEqualsScalar (cl::Buffer &, REAL, int, int)
 LinearAlgebra *= operation. More...
 
void timesEqualsVector (cl::Buffer &, const cl::Buffer &, int, int)
 LinearAlgebra *= operation. More...
 
void writeIntBuffer (int *, cl::Buffer &, int)
 LinearAlgebra integer write. More...
 
void writeRealBuffer (REAL *, cl::Buffer &, int)
 LinearAlgebra floating-point write. More...
 

Detailed Description

Base class for OpenCL linear algebra operations, including vector and matrix types. Implements a number of vector operations as well as a preconditioned conjugate gradient solver.

Constructor & Destructor Documentation

LinearAlgebra ( int  workGroupSize_,
cl::Context &  context_,
cl::CommandQueue &  queue_,
std::vector< cl::Device > &  devices_,
int  deviceID 
)
Parameters
workGroupSize_OpenCL work-group size to use.
context_OpenCL context handle.
queue_OpenCL queue handle.
devices_OpenCL device list.
deviceIDOpenCL device ID to use.
~LinearAlgebra ( )
inline

Member Function Documentation

void copyIntBuffer ( const cl::Buffer &  source,
cl::Buffer &  dest,
int  n 
)
Parameters
sourcesource buffer.
destdestination buffer.
nnumber of items to copy.
void copyRealBuffer ( const cl::Buffer &  source,
cl::Buffer &  dest,
int  n 
)
Parameters
sourcesource buffer.
destdestination buffer.
nnumber of items to copy.
cl::Buffer createIntBuffer ( int  size)
Parameters
sizesize of buffer.
cl::Buffer createRealBuffer ( int  size)
Parameters
sizesize of buffer.
REAL Dot ( const Vector a,
const Vector b 
)
Parameters
afirst vector.
bsecond vector.
Returns
valur of dot product.
int getWorkGroupSize ( )
inline
void minusEqualsVector ( cl::Buffer &  base,
const cl::Buffer &  op,
int  padn,
int  n 
)
Parameters
basebuffer to set.
opbuffer to subtract.
padnnumber of items padded to work-group size.
nnumber of items to set.
LinearAlgebra& operator= ( const LinearAlgebra )
void plusEqualsVector ( cl::Buffer &  base,
const cl::Buffer &  op,
int  padn,
int  n 
)
Parameters
basebuffer to set.
opbuffer to add.
padnnumber of items padded to work-group size.
nnumber of items to set.
void readIntBuffer ( int *  dest,
const cl::Buffer &  source,
int  n 
)
Parameters
destmemory pointer to copy to.
sourcesource buffer.
nnumber of items to copy.
void readRealBuffer ( REAL *  dest,
const cl::Buffer &  source,
int  n 
)
Parameters
destmemory pointer to copy to.
sourcesource buffer.
nnumber of items to copy.
void reserveSparseMatrix ( int  i,
int  j,
int  index,
int  nWritten,
cl::Buffer &  row,
cl::Buffer &  col,
cl::Buffer &  idx,
cl::Buffer &  rowstart,
cl::Buffer &  rowlength 
)
void setIntBuffer ( cl::Buffer &  base,
int  op,
int  padn 
)
Parameters
basebuffer to set.
opvalue to set buffer to.
padnnumber of items to set.
void setRealBuffer ( cl::Buffer &  base,
REAL  op,
int  padn 
)
Parameters
basebuffer to set.
opvalue to set buffer to.
padnnumber of items to set.
Vector Solve ( const SparseMatrix A,
const Vector iM,
const Vector b 
)

Solves linear system of the form Ax = b using CGM with Jacobi preconditioner. The sparse matrix must be symmetric positive definite. The preconditioner iM must contain the inverse diagonal entries of A.

Parameters
Asparse matrix.
iMJacobi preconditioning vector.
bforcing vector.
Returns
solution vector.
void sparseMatrixProduct ( const cl::Buffer &  vec_in,
cl::Buffer &  vec_out,
const cl::Buffer &  v,
const cl::Buffer &  col,
const cl::Buffer &  rowstart,
const cl::Buffer &  rowlength,
int  rowdim,
int  padrowdim 
)
void timesEqualsScalar ( cl::Buffer &  base,
REAL  op,
int  padn,
int  n 
)
Parameters
basebuffer to set.
opmultiplication value.
padnnumber of items padded to work-group size.
nnumber of items to set.
void timesEqualsVector ( cl::Buffer &  base,
const cl::Buffer &  op,
int  padn,
int  n 
)
Parameters
basebuffer to set.
opbuffer to multiply.
padnnumber of items padded to work-group size.
nnumber of items to set.
void writeIntBuffer ( int *  source,
cl::Buffer &  dest,
int  n 
)
Parameters
sourcememory pointer to copy from.
destdestination buffer.
nnumber of items to copy.
void writeRealBuffer ( REAL *  source,
cl::Buffer &  dest,
int  n 
)
Parameters
sourcememory pointer to copy from.
destdestination buffer.
nnumber of items to copy.