Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why OpenCL doesn't have matrix data type?

Considering OpenCL kernels are executed on the same units as shaders it would seem logical to me for OpenCL to have the same data types as GLSL, yet looking here: http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/dataTypes.html I don't see a matrix type.

Why is that?

Also, does it mean if I want to multiply 4x4 matrices it will be slower when using OpenCL than GLSL?

like image 486
zduny Avatar asked Sep 21 '14 15:09

zduny


1 Answers

Actually, if you look at your link more closely there are matrix data types in the category of reserved datatypes: floatnxm, doublenxm. So it is quite likely that there will be implementation for those types in future releases of the standard. I have no idea why they haven't done that already.

At this point you can use either an array or image2d_t to represent matrices. You probably want to take a look at this article

What comes to the speed. It doesn't necessarily mean that OpenCL is slower, but it is quite likely. Even if you manage to write the perfect matrix multiplication code for one platform with OpenCL, in some other platform performance can be quite poor. In OpenGL, manufacturers are writing their own matrix multiplication code which should be quite optimal for each platform.

like image 139
maZZZu Avatar answered Nov 08 '22 03:11

maZZZu