<p>To first clear your confusion around the terms:</p>

<p>GPGPU stands for <strong>G</strong>eneral <strong>P</strong>urpose computing on GPUs</p>

<p><strong>CUDA</strong> is the specific NVIDIA API to perform GPGPU only on their hardware</p>

<p><strong>OpenGL</strong> is a graphics specific API and is vendor independent<br>
<strong>OpenCL</strong> is a parallel programming compute API and is vendor independent</p>

<p><strong>Compute Shaders</strong> are a way to perform general purpose computations within<br>
a rendering system but without being part of a fixed rendering architecture.<br>
They exist for OpenGL (<a href="https://www.khronos.org/opengl/wiki/Compute_Shader" rel="nofollow noreferrer">https://www.khronos.org/opengl/wiki/Compute_Shader</a>)<br>
but also for other graphics APIs like DirectX (DirectCompute) etc.</p>

<p>OpenCL is not only built for GPUs and can also be used to write code<br>
for example to run massive parallel computations on supercomputers. </p>

<p>NVIDIA develops their own ray tracer based on CUDA and GPU computing.<br>
The project is called Optix (<a href="https://developer.nvidia.com/optix" rel="nofollow noreferrer">https://developer.nvidia.com/optix</a>)</p>

<p>To your performance question. It depends, as always on your setup and use case.<br>
Some people did already the effort to measure differences. 
One paper for example is this:
<a href="https://arxiv.org/ftp/arxiv/papers/1005/1005.2581.pdf" rel="nofollow noreferrer">https://arxiv.org/ftp/arxiv/papers/1005/1005.2581.pdf</a></p>

<p>Another one is this:
<a href="https://dl.acm.org/citation.cfm?id=2066955" rel="nofollow noreferrer">https://dl.acm.org/citation.cfm?id=2066955</a></p>

<p>Or one thesis about it:
<a href="https://liu.diva-portal.org/smash/get/diva2:909410/FULLTEXT01.pdf" rel="nofollow noreferrer">https://liu.diva-portal.org/smash/get/diva2:909410/FULLTEXT01.pdf</a></p>

<p>In their comparisons did CUDA often show good results. But when they for example used image processing algorithms that can be parallized very efficiently from the GPU then the comparison is nearly worthless compared what you might do in your path tracing code.</p>

<p>If you do not use any "classic" rendering, which you wanna combine your path traced results, I see not why you should use compute shaders for a pure path tracer. If platform independence is important OpenCL might be interesting for you since you then can take the code and run it on a complete other hardware for comparison. If you will stick to NVIDIA GPUs anyways you will likely get better performance using directly CUDA.</p>

CC BY-SA 3.0
2018-02-17T16:26:14.133Z
Even if not using classic rasterization on top of the raytraced image, there's still some nice convenience in having the resulting imagine in an FBO or a texture, provided you don't *just* want to write it out into an image file you have to display it at *some* point. Besides that, there's also nice convenience things an inherently graphical task might still profit from, like builtin matrix types or builtin access to the hardware's advanced texture filtering functionality.
Christian Rau
CC BY-SA 3.0
2018-02-18T11:04:05.743Z
I don't have an Nvidia card but AMD one. Thanks for the links helps a bit. But I think compute shader would be better, since I'd have to use OpenGL anyways to output the result to a window. Keeping this question open a little more in case anybody has some more interesting details or first hand experience.
gallickgunner
CC BY-SA 3.0
2018-02-16T23:31:19.157Z
2018-02-16T23:31:19.157Z
Stefan Lindblad
<p>So I want to implement a path tracer and I am confused between GPGPU computing or using OpenGL's compute shaders. I've already implemented a raytracer using GL's compute shaders. </p>

<p>What are the main differences between CUDA/OpenCL and CS? And is it possible to see a significant speed up if I prefer one over the other? Some main differences I already know are that using CS will make it vendor independent so I could run it on PCs having Nvidia/Amd GPUs alike. CUDA supports recursion while openCL/opengl CS don't. </p>

<p>What are other significant functionalities that would make a person prefer opencl/cuda over CS?</p>

<compute-shader><opencl><cuda>
CUDA/OpenCL vs OpenGL compute shader for Path tracer
gallickgunner
# CUDA/OpenCL vs OpenGL compute shader for Path tracer

(Asked by: username_0 on 2018-02-15)

So I want to implement a path tracer and I am confused between GPGPU computing or using OpenGL's compute shaders. I've already implemented a raytracer using GL's compute shaders.

What are the main differences between CUDA/OpenCL and CS? And is it possible to see a significant speed up if I prefer one over the other? Some main differences I already know are that using CS will make it vendor independent so I could run it on PCs having Nvidia/Amd GPUs alike. CUDA supports recursion while openCL/opengl CS don't.

What are other significant functionalities that would make a person prefer opencl/cuda over CS?

**Tags:** compute-shader, opencl, cuda


---

## 1 answers

### Answer by username_1 on 2018-02-16. Score: 4 | Accepted answer

To first clear your confusion around the terms:

GPGPU stands for **G**eneral **P**urpose computing on GPUs

**CUDA** is the specific NVIDIA API to perform GPGPU only on their hardware

**OpenGL** is a graphics specific API and is vendor independent  
**OpenCL** is a parallel programming compute API and is vendor independent

**Compute Shaders** are a way to perform general purpose computations within  
a rendering system but without being part of a fixed rendering architecture.  
They exist for OpenGL (<https://www.khronos.org/opengl/wiki/Compute_Shader>)  
but also for other graphics APIs like DirectX (DirectCompute) etc.

OpenCL is not only built for GPUs and can also be used to write code  
for example to run massive parallel computations on supercomputers.

NVIDIA develops their own ray tracer based on CUDA and GPU computing.  
The project is called Optix (<https://developer.nvidia.com/optix>)

To your performance question. It depends, as always on your setup and use case.  
Some people did already the effort to measure differences.
One paper for example is this:
<https://arxiv.org/ftp/arxiv/papers/1005/1005.2581.pdf>

Another one is this:
<https://dl.acm.org/citation.cfm?id=2066955>

Or one thesis about it:
<https://liu.diva-portal.org/smash/get/diva2:909410/FULLTEXT01.pdf>

In their comparisons did CUDA often show good results. But when they for example used image processing algorithms that can be parallized very efficiently from the GPU then the comparison is nearly worthless compared what you might do in your path tracing code.

If you do not use any "classic" rendering, which you wanna combine your path traced results, I see not why you should use compute shaders for a pure path tracer. If platform independence is important OpenCL might be interesting for you since you then can take the code and run it on a complete other hardware for comparison. If you will stick to NVIDIA GPUs anyways you will likely get better performance using directly CUDA.

> **Comments:**
> **username_2**: Even if not using classic rasterization on top of the raytraced image, there's still some nice convenience in having the resulting imagine in an FBO or a texture, provided you don't *just* want to write it out into an image file you have to display it at *some* point. Besides that, there's also nice convenience things an inherently graphical task might still profit from, like builtin matrix types or builtin access to the hardware's advanced texture filtering functionality.  
> **username_0**: I don't have an Nvidia card but AMD one. Thanks for the links helps a bit. But I think compute shader would be better, since I'd have to use OpenGL anyways to output the result to a window. Keeping this question open a little more in case anybody has some more interesting details or first hand experience.  

---

