Visible to Intel only — GUID: ewa1399897859679
Ixiasoft
Visible to Intel only — GUID: ewa1399897859679
Ixiasoft
8.5. Debugging Your OpenCL Kernel on Linux
To compile your OpenCL kernel for debugging, perform the following steps:
- To generate an emulator .aocx file for debugging, invoke the aoc -march=emulator <your_kernel_filename>.cl command.
- Build the host application and link your host application to the Khronos ICD Loader Library. For details, see Linking Your Host Application to the Khronos ICD Loader Library.
- Ensure that the <your_kernel_filename>.aocx file is in a location where the host expects to find it.
- To run the application, invoke the command env CL_CONFIG_CPU_EMULATE_DEVICES=<number_of_devices> gdb --args <your_host_program_name> [<host_program_arguments>], where <number_of_devices> is the number of identical emulation devices that the Emulator needs to provide.
Note: You can omit the CL_CONFIG_CPU_EMULATE_DEVICES environment variable if you only want to emulate a single device.
- If you make changes to only your host application, recompile only the host before restarting the debugger. Similarly, if you make changes to only your kernel code, recompile only the kernel code before restarting the debugger.
- During program execution, the debugger cannot step from the host code to the kernel code. You must set a breakpoint before the actual kernel invocation by adding these lines:
- break <your_kernel>
This line sets a breakpoint before the kernel.
- continue
If you have not begun debugging your host, then type start instead.
- break <your_kernel>
- The debugger does not recognize kernel names until the host actually loads the kernel functions. As a result, the debugger generates the following warning for the breakpoint you set before the execution of the first kernel:
Function "<your_kernel>" not defined.
Make breakpoint pending on future shared library load? (y or [n])
Answer y. After initial program execution, the debugger recognizes the function and variable names, and line number references for the duration of the session.
Did you find the information on this page useful?
Feedback Message
Characters remaining: