Enabling Debugging in OpenCL™ CPU Compiler and Runtime

To enable the debugging mode in the OpenCL™ CPU Compiler and Runtime, specific options should be passed to the build options string parameter in the clBuildProgram function:

clBuildProgram Example

Consider the following example of using the clBuildProgram function:

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

Note

The OpenCL™ kernel code must exist in a text file that is separate from the host code. Debugging OpenCL™ code that appears only in a string embedded in the host application is not supported.

Instead of passing the -s option to specify a path to an OpenCL source file, you can use one of the following approaches: