openclamd-rocm

OpenCL visual kernel debugging


Background

I am somewhat familiar with NVidia CUDA development. In CUDA world it's quite easy to debug the code inside kernels: both NSight Visual Studio and Nsight Visual Studio Code allow to do that.

Objective

I would like to be able to run a visual debugger for individual OpenCL kernels at runtime, similar to CUDA kernels in Nsight Visual Studio (with Locals, Watches, Memory and Breakpoints set in kernels).

What I have tried

  1. printf debugging. This is a very limited approach that allows to debug only simple programs. It is not reliable and it does not allow to easily find problems when, for example, two parallel kernels try to write to the same memory address.
  2. Searched the official documentation of Khronos Group for kernel debugging, did not find anything.
  3. Searched the official documentation of Intel OpenCL page for kernel debugging, did not find anything (the last update on their tutorials page is from 2015).
  4. Searched the official documentation of AMD for kernel debugging, did not find anything, but a reference to the discontinued IDE CodeXL.
  5. Searched the respective forum of AMD ROCm for kernel debugging, did not find anything.
  6. Searched the official documentation of ROCDebugger (AMD ROCm), did not find any clues of how visual debugging of OpenCL kernels can be done with it.

Question

How can I run a visual debugger for individual OpenCL kernels at runtime, similar to CUDA kernels in Nsight Visual Studio (with Locals, Watches, Memory and Breakpoints set in kernels)?


Solution

  • Intel provides Intel Distribution for GDB to debug OpenCL kernels on GPU. The debugger is available for both Linux and Windows systems. It is a part of oneAPI Base Toolkit. Additional information about how to use it on a particular system can be found in the official documentation: