What is the difference between OpenCL and OpenGL compute shader?

I know that OpenCL provides control over the GPU memory architecture and thus provides better optimization, but leaving that aside, can we use Compute Shaders for vector operations (addition, multiplication, inversion, etc.)?

+49
opencl gpgpu opengl compute-shader
Apr 07 '13 at 22:16
source share
2 answers

Unlike other types of OpenGL shaders, computational shaders are not directly related to computer graphics and provide much more direct abstraction of basic equipment similar to CUDA and OpenCL. It provides customizable workgroup size, shared memory, intra-group synchronization, and all those things that are known and loved by CUDA and OpenCL.

The main differences are mainly:

  • It uses GLSL instead of OpenCL C. Although there is no such huge difference between these programming languages, you can use all the graphics-related GLSL functions that are not available to OpenCL, such as advanced texture types (like cube map arrays), advanced filtering (like mipmapping, Good. Well, you probably need to calculate the mip level yourself) and few convenient things like 4x4 matrices or geometric functions.
  • This is an OpenGL shader program, like any other GLSL shader. This means that accessing OpenGL data (e.g., buffers, textures, images) is simply trivial, while the interaction between OpenGL and OpenCL / CUDA can be tedious, with possible manual synchronization efforts on your part. Likewise, integrating it into an existing OpenGL workflow is also trivial, while setting up OpenCL is a standalone book, not to mention integrating it into an existing graphics pipeline.

So, what does it boil down to, that computational shaders are really intended for use in existing OpenGL applications, although they demonstrate the usual (OpenCL / CUDA-like) computational approach to GPU programming, in contrast to the graphical approach, other stages of the shader that are not They had OpenCL / CUDA computational flexibility (while, of course, they offer other advantages). Thus, the execution of computational tasks is more flexible, direct and easy than either compressing them to other stages of the shader, not intended for general calculations, or introducing an additional computational structure with which you must synchronize.

Compute shaders should be able to do what is almost achievable using OpenCL with the same flexibility and control over hardware resources and with the same software approach. Therefore, if you have a good algorithm corresponding to the GPU (which will work well with CUDA or OpenCL) for the task you want to do, then yes, you can also do this using computational shaders. But it won't make sense to use OpenGL (which is still and probably will always be the basis for real-time computer graphics in the first place) just because of the computational shaders. You can simply use OpenCL or CUDA for this. The real power of computing shaders comes into play when mixing graphics and computing capabilities.

+45
Apr 08 '13 at 8:54
source share

Look here for a different perspective. Summarizing:

Yes, OpenCL already exists, but it is aimed at heavy applications (I think, CFD, FEM, etc.), and it is much more universal than OpenGL (I think, in addition to GPUs ... Intel Xeon Phi architecture supports> 50 x 86 cores).

In addition, buffer sharing between OpenGL / CUDA and OpenCL is not fun.

+2
Apr 07 '13 at 22:24
source share



All Articles