Opencl library library

I would like to port the physics simulation algorithm to the GPU using OpenCL for performance; I have no experience with OpenCL, and I look back. The calculations are mainly a small dense matrix (3x3) and vector products, cross-products, etc.

  • Is there some kind of β€œstandard” / recommended library for these basic operations? Of course, I don’t want to code matrix multiplications and inversions on my own (and not time, and that would be inefficient)

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

  • Are there any (planned) extensions / evolution of OpenCL (or, if necessary, a preprocessor) to make the notation more like math? I got the impression that I’m going back to fortran years. (I know there is CUDA, but it depends on the provider)

+6
source share
2 answers

If you know that you are limited to 3-dimensional objects, you might consider using the type double3 (or float3 if your gpu does not support double precision).

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

You may also be interested to know that there are reserved data types for futures matrix impregnations: see, for example, double nx m. In your case, if this is possible in the future, you can use double3x3 types for your matrices.

+4
source

To answer your questions:

  • Don't know what i know
  • Yes, OpenCL is strictly limited to the C99 syntax, so there are no classes, operator overloads, or strictly procedural calls for the kinds of operations that you have in mind. OpenCL supports elementary operations on its native vector types, but no more complex than that. Matrix multiplication, determinant, transpose, etc. All must be implemented by yourself.
  • Again not what I know. [Aside, I would not make fun of Fortran in this context, F90 and later have built-in matrix and vector operations that make the types of operations you ask for are much easier to write than C99 or C ++].
+5
source

Source: https://habr.com/ru/post/896633/


All Articles