Enabling Debugging in OpenCL™ Runtime

To enable debugging mode in the Intel® OpenCL™ Runtime for compiling OpenCL code using Intel® SDK for OpenCL™ Applications - Debugger plug-in for Microsoft Visual Studio* IDE, do the following:

  1. Add the -g flag to the build options string parameter in the clBuildProgram function.
  2. Specify full path to the file in the build options string parameter to the clBuildProgram function accordingly (including the CL file name):
    -s <full path to the OpenCL source file>

If the path includes spaces, enclose the entire path with double quotes.

For example:

err = clBuildProgram(
          g_program, 
          0, 
          NULL, 
          "-g -s \"<path_to_opencl_source_file>\"", 
          NULL, 
          NULL);

Note

Relative path to the CL file is not supported.

According to the OpenCL standard, work-items execute OpenCL kernels simultaneously. The Debugger requires setting the global ID of the work-item to debug before the debugging session starts. The Debugger stops on breakpoints in OpenCL code only when the pre-set work-item reaches them.

Note

To work with the Intel SDK for OpenCL Applications - Debugger plug-in for Microsoft Visual Studio* IDE, the OpenCL kernel code must exist in a text file, separate from the code of the host. Debugging OpenCL code that appears only in a string embedded in the host application is not supported. Create your OpenCL project with the Intel® Code Builder for OpenCL™ API plug-in for Microsoft Visual Studio* to get seamless integration with the Debugger.

For more complete information about compiler optimizations, see our Optimization Notice.