Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencl matrix library

I would like to port a physics simulation algorithm to GPU using OpenCL for performance; I have no experience with OpenCL, and I am looking around. The computations are mostly small dense matrix (3x3) and vector products, cross-products and so on.

  1. Is there some "standard"/recommended library for such basic operations? I certainly don't want to code matrix multiplications and inversions myself (not time, and it would be inefficent)

  2. As OpenCL does not have classes, operator overloading etc, do I have to write mmul(a,mtrans(b)) instead of a*b.transpose() for instance?

  3. Are there some (planned) extensions/evolution of OpenCL (or pre-processor, for that matter) to make the notation more math-like? I have the impression of going back to fortran years. (I know there is CUDA, but it is vendor-bound)

like image 617
eudoxos Avatar asked Sep 05 '11 10:09

eudoxos


2 Answers

To answer your questions:

  1. Not that I am aware of
  2. Yes, OpenCL is strictly limited to C99 syntax, so no classes, no operator overloading, and strictly procedural calls for the sorts of operations you have in mind. OpenCL supports element wise operations on its native vector types, but nothing more sophisticated than that. Matrix multiplication, determinant, transpose, etc. will all have to be implement yourself.
  3. Again not that I am aware of. [As an aside, I would not deride Fortran in this context, F90 and later versions have intrinsic matrix and vector operations which make the sorts of operations you are asking about far easier to write than C99 or C++].
like image 100
talonmies Avatar answered Oct 20 '22 19:10

talonmies


If you know for a fact that you are limited to 3-dimensional objects, then you might consider using the double3 type (or float3 if your gpu doesn't support double precision).

So far, only vectors are supported, so you will have to do some coding yourself regarding any use of matrix multiplication or inversion. However, you might be interested in the following built-in geometric functions. In particular, dot products and cross products are defined.

You might also be interested to know that there are reserved data types for futures implentations of matrices: see for example double n x m. In your case, if available in the future, you will be able to use double3x3 types for your matrices.

like image 29
FelixCQ Avatar answered Oct 20 '22 21:10

FelixCQ