Debug OpenCL Kernel ?


I would like to debug my OpenCL Kernel code… so, I have create a ‘char array’ that I send to my kernel.

But how can I :

  • Add a string ?
  • Convert int to string ?


There are no built-in string methods in OpenCL. You’ll have to write them yourself to do so. I would suggest a more primitive approach of using error codes to indicate status and using that instead. Remember that either way you are going to need to make sure that the work-items don’t overwrite each other when returning information. Another good approach is to just use the CPU device which (at least on Mac OS X) supports printf().


There is a tool called gDebugger which supports debugging OpenCL kernels. It is in its beta phase and for this time for free

I don’t know if gDebugger will let you debug kernels or just API calls. Debugging the kernel requires getting access to breakpoints on the device. (These don’t exist for GPU hardware, so you would have to use a CPU.)

You can use this article to debug OpenCL kernel and Java openCL API call: … -host.html