Debugging an OpenCL™ Application#

Starting with the 2023.0 release of oneAPI, debugging OpenCL™ applications is not supported. For earlier versions (2022.x and earlier), see the instructions below.

To debug OpenCL™ applications with Intel® Distribution for GDB* version 2022.3 (based on GDB 11.2), make sure you use the following flags when calling the clBuildProgram function:

  • -g -cl-opt-disable to enable the debug information and disable optimizations inside the kernel

  • -s <full_path_to_kernel.cl> to point to the kernel source file.

    This allows you to set a breakpoint in the following format: breakpoint kernel.cl:<line number>.

Launch the debugger as follows:

gdb-oneapi <application>

To start debugging, you must set a pending breakpoint because the kernel source file is not known to the debugger yet:

set breakpoint pending on
break kernel.cl:<line number>
run

At runtime, the kernel sources are loaded to the debugger and the breakpoint is hit, both for CPU and GPU offloads.