OpenCL, Vulkan, Sycl

cor3ntin picture cor3ntin · Nov 20, 2016 · Viewed 13.5k times · Source

I am trying to understand the OpenCL ecosystem and how Vulkan comes into play.

  • I understand that OpenCL is a framework to execute code on GPUs as well as CPUs, using kernels that may be compiled to SPIR.
  • Vulkan can also be used as a compute-API using the same SPIR language.
  • SYCL is a new specification that allows writing OpenCL code as proper standard-conforming C++14. It is my understanding that there are no free implementations of this specification yet.

Given that,

  • How does OpenCL relate to Vulkan? I understand that OpenCL is higher level and abstracts the devices, but does ( or could ) it use Vulkan internally? (instead of relying on vendor specific drivers)

  • Vulkan is advertised as both a compute and graphics API, however I found very little resources for the compute part. Why is that ?

  • Vulkan has performance advantages over OpenGL. Is the same true for Vulkan vs OpenCl? (OpenCL is sadly notorious to being slower than CUDA.)

  • Does SYCL use OpenCL internally or could it use Vulkan ? Or does it use neither and instead rely on low level, vendor specific APIs to be implemented ?

Answer

Nicol Bolas picture Nicol Bolas · Nov 20, 2016

How does OpenCL relates to vulkan ? I understand that OpenCL is higher level and abstracts the devices, but does ( or could ) it uses Vulkan internally ?

They're not related to each other at all.

Well, they do technically use the same intermediate shader language, but Vulkan forbids the Kernel execution model, and OpenCL forbids the Shader execution model. Because of that, you can't just take a shader meant for OpenCL and stick it in Vulkan, or vice-versa.

Vulkan is advertised as both a compute and graphics api, however I found very little resources for the compute part - why is that ?

Because the Khronos Group likes misleading marketing blurbs.

Vulkan is no more of a compute API than OpenGL. It may have Compute Shaders, but they're limited in functionality. The kind of stuff you can do in an OpenCL compute operation is just not available through OpenGL/Vulkan CS's.

Vulkan CS's, like OpenGL's CS's, are intended to be used for one thing: to support graphics operations. To do frustum culling, build indirect graphics commands, manipulate particle systems, and other such things. CS's operate at the same numerical precision as graphical shaders.

Vulkan has a performance advantages over OpenGL. Is the same true for Vulkan vs OpenCl?

The performance of a compute system is based primarily on the quality of its implementation. It's not OpenCL that's slow; it's your OpenCL implementation that's slower than it possibly could be.

Vulkan CS's are no different in this regard. The performance will be based on the maturity of the drivers.

Also, there's the fact that, again, there's a lot of stuff you can do in an OpenCL compute operation that you cannot do in a Vulkan CS.

Does SYCL uses OpenCL internally or could it use vulkan ?

From the Khronos Group:

SYCL (pronounced ‘sickle’) is a royalty-free, cross-platform abstraction layer that builds on the underlying concepts, portability and efficiency of OpenCL...

So yes, it's built on top of OpenCL.