Debugging Intel OpenCL kernels in Visual Studio

Debugging Intel OpenCL kernels in Visual Studio

Yes, this works for a C++ based Intel OpenCL project - however, my goal is to make this work for .NET bindings too (in particular, my bindings that can be found here http://openclnet.codeplex.com).

As I understand it - making a vcxproj an "Intel OpenCL project" adds IntelOpenCL.props and IntelOpenCL.targets that do the following things

  1. The props file puts in a pre-requisite that either ioc32.exe or ioc64.exe run and produce Visual Studio error output by running a command line with an undocumented switch -VS
  2. This step is a little unclear to me, but it seems to add new items to Link and Lib. Some of these are outputs generated by ioc32/64(?)
  3. During debugging - when stopped in the kernel, I see OclCpuDebugging.dll in the call stack. I also see the process "icldbgsrv.exe".

What I want to do is enable CPU debugging for non-C++ projects too. Can anyone shed some light on this/help me with it?

Thanks in advance!

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Ananth,

Nice question!
You know, I have just tried to create a sample OpenCL.Net project (similar to the one from https://openclnet.codeplex.com/SourceControl/latest#trunk/Samples/Simple...) and the kernel debugging worked just fine for me. Could you please try it (again?) following these general guidelines below. This list looks quite extensive, but some points are for illustration purposes and others are minor details that nevertheless need to be taken into account.

1. Make sure that you have only 1 instance of Visual Studio open.
2. Check that OpenCL debugger is enabled in the "Tools->Intel SDK for OpenCL - Debugger" dialog.
3. Check the work-items value in the same dialog with respect to kernel execution. This is important in case the kernel runs with some offset and with the default work-items value (0,0,0) the debugger will not stop at the kernel breakpoint.
4. Make sure that you are working with Intel OpenCL platform and you select CPU device.
5. Add necessary build parameters to clBuildProgram like so:
clBuildProgram(g_program, 0, NULL, "-g -s c:\\work\\ToneMapping\\ToneMapping.cl", NULL, NULL);
6. Make sure that the kernel source file you open in Visual Studio is the same file/text you pass to clCreateProgramWithSource function.
7. Put a breakpoint at host code right before (or at) clCreateContext function call. Put another breakpoint at kernel function code. Make sure that you put the breakpoint at the same kernel function that will be called/enqueued later.
8. Run the debugging session (F5). The debugger stops near clCreateContext. At this point the kernel breakpoint should be shown as not active (The breakpoint will not currently be hit...).
9. Step over the clCreateContext function call. At this point the kernel breakpoint should become active, showing something like "At ToneMapping.cl, line 60 in process 'icldbgsrv.exe'".
10. Continue debugging (F5) - kernel breakpoint should be hit.

Please, let me know if that works for you or not.

Thanks,
Yuri

Thanks, Yuri. I got it working too, but it was way late on a Friday and I didn't post back here. As you pointed out, I was providing the wrong path to the -s flag (the kernel in the $(outputdir), not the one in $(ProjectDir). It all worked great from there on.

Thanks again!

Thanks, Yuri. I got it working too, but it was way late on a Friday and I didn't post back here. As you pointed out, I was providing the wrong path to the -s flag (the kernel in the $(outputdir), not the one in $(ProjectDir). It all worked great from there on.

Thanks again!

Leave a Comment

Please sign in to add a comment. Not a member? Join today