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:
-g
flag enables source-level debug information generation.
Passing a -g
flag means that no optimizations (such
as inlining, unrolling, vectorization) are performed, the same
as if a -cl-opt-disable
option was passed.
-s /full/path/to/OpenCL/source/file.cl
option specifies
the full path to the OpenCL™ source file. If the path includes spaces,
the entire path should be enclosed with double or single quotes.clCreateProgramWithSource
function as
a string.-s
option. If
the file contains one or more #include
directives, multiple
paths for files with the -s
option are not needed.Consider the following example of using the clBuildProgram
function:
err = clBuildProgram( g_program, 0, NULL, "-g -s \"<path_to_opencl_source_file>\"", NULL, NULL);
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:
-s
option is not necessary, as the path
to an OpenCL source file is defined by the -input
option:
ioc -cmd=build -input=kernel.cl '-bo=-g'
#include
directives
to clCreateProgramWithSource
.const char* src = "#include kernel.cl"; cl_program program = clCreateProgramWithSource( m_context, 1, &src, NULL, &error);