Codeplay Release “clspv”, an OpenCL Tool for Vulkan Enabled Devices

Posted on July 14, 2017 by Melissa Richardson.

In collaboration with Google, Codeplay is proud to announce the release of a new open-source tool allowing the compilation of OpenCL C language kernels to run on the Vulkan API.

Vulkan is a low-overhead, cross-platform 3D graphics and compute API, available on the Android, Linux, and Windows platforms. OpenCL C is the kernel language used in the OpenCL API allowing developers to program for execution on heterogeneous devices.

The tool, named 'clspv', allows a subset of the OpenCL C language to be targeted at the Vulkan API. This tool allows developers to port code containing more than a million lines of OpenCL C to run on the Vulkan API.

As active members of the Khronos Vulkan working group, Codeplay has been instrumental in pushing two extensions that the clspv codebase requires - VK_KHR_variable_pointers and VK_KHR_16bit_storage, which were announced yesterday by Khronos.

The tool source code is available at https://github.com/google/clspv and is available under the Apache 2.0 open source license.

Some notes on the clspv:

  • This is a prototype, with known issues. However, it does compile significant portions of kernels
  • It uses close to top-of-tree versions of LLVM and Clang as third-party projects - this is not a fork
  • It is mainly a set of LLVM module passes. The flow starts with the SPIR code generated from stock Clang, then massages it into SPIR-V for Vulkan
  • It exercises SPV_KHR_variable_pointers (rev13)