OpenCL bugs

OpenCL is a great framework, however, AMD’s, NVIDIA’s and Apple’s OpenCL compilers are not. I have worked over 4 years with OpenCL and I have experienced a lot of bugs. Here I present a list of the OpenCL bugs I have encountered along with possible solutions/work-arounds to help other frustrated OpenCL programmers. I create this list with a small hope that these bugs will eventually be fixed, and I will try to keep it up to date.

Apple OpenCL

The function “mix” is missing and using it results in a “could not find __gpu_mix” error when building the CL code.
Work-around: Instead of mix(x, y, a) write this: x + (y – x)*a, which is the operation mix actually performs.
System: Mac OS X 10.9 Mavericks, NVIDIA 780M GPU


M_PI is missing, resulting in “error: identifier “M_PI” is undefined” when compiling.
Work-around: Define M_PI yourself: #define M_PI 3.14159265358979323846
System: Ubuntu 14.10, AMD APP 2.9.1, Catalyst 14.9 driver, Radeon HD5780M

Building a program from binary source which uses printf causes a segmentation fault.
Work-around: Remove printf and compile again
System: Ubuntu 14.04, AMD APP 2.9.1, Catalyst 14.9 driver, R9 290 GPU


The compiler recognizes cl_khr_3d_image_writes as defined in the OpenCL code even though NVIDIA does not support this extension.
Work-around: Downgrade driver to 353 series OR you can detect if it is actually supported in the runtime API (e.g. device.getInfo<CL_DEVICE_EXTENSIONS>().find(“cl_khr_3d_image_writes”) != std::string::npos) and then add your own definition when compiling (-Dcustom_3d_image_writes).
System: Windows 8.1, 355.82 driver, NVIDIA GTX 970 GPU. Ubuntu 16.04, 375 driver NVIDIA GTX 980 GPU.

OpenCL-OpenGL interopability does not work. Crash with message “Xlib: extension “NV-GLX” missing on display “:0″”
Work-around: Downgrade driver to 352 series
System: Ubuntu, 361 driver, NVIDIA GTX 980 GPU

You may also like...

4 Responses

  1. Olu says:

    Did you ever work with the OpenCL implementation from Intel? Would it fall in the same category as these three?

    • Erik Smistad says:

      Yes, I’m working with the OpenCL implementation of Intel as well, but not enough to record any bugs yet.

  2. shookees says:

    hey, that’s a good idea on having multiple platform workarounds, though, having in mind, that the bugs might be fixed in future, it would be good to add at least the link to a bug to see whether it still persists 🙂

    • Erik Smistad says:

      Yes, that would be nice. However, some bugs only occur on specific processors or setups. It would be difficult and expensive for me to test all bugs continously on all the hardware out there.

Leave a Reply

Your email address will not be published.