How can I debug an OpenCL kernel in Xcode 4.1?

I have some OpenCL kernels that aren't doing what they should be, and I would love to debug them in Xcode. Is this possible?

If not, is there any way I can use printf() in my CPU-based kernels? When I use printf() in my kernels the OpenCL compiler always gives me a whole bunch of errors.


Casting the format string to const char * appears to fix this problem.

This works for me on Lion:

printf((char const *)"%d %dn", dl, dll);

This has the error described above:

printf("%d %dn", dl, dll);

You might also want to try using Quartz Composer to test out your kernels. If you have access to the WWDC 2010 videos, I believe they show how to use Quartz Composer for rapid prototyping of OpenCL kernels in Sessions 416: "Harnessing OpenCL in Your Application" or 418: "Maximizing OpenCL Performance". There were also some good sessions on this during WWDC 2009 and 2008 that might also be available via ADC on iTunes.

Using Quartz Composer, you can quickly set up inputs and outputs for a kernel, then monitor the results in realtime. You can avoid the change-compile-test cycle because everything is compiled as you type. Syntax errors and the like will pop up as you change code, which makes it fairly easy to identify those.

I've used this tool to develop and test out OpenGL shaders, which have many things in common with OpenCL kernels.


Have you given the gDEBugger a try already? I think it's the only choice you have currently, for OpenCL debugging on the Mac.

Intel offers a printf in their new OpenCL 1.1 SDK, but that's only for Linux and Windows. Lion has OpenCL 1.1, but at least my Core 2 Duo does not support the printf extension.

AMD ist still developing their OpenCL tools, and the Nvidia Debugging tools are only for CUDA, as far as I understand.

链接地址: http://www.djcxy.com/p/54608.html

上一篇: 平行处理应用程序

下一篇: 我如何在Xcode 4.1中调试OpenCL内核?