Tutorial: Debugging with Intel® Distribution for GDB*

Debug an Application on a GPU

This section describes a basic scenario of debugging a program with the kernel offloaded to the GPU.

Before you proceed, make sure you have completed all necessary setup steps described in the Get Started Guide.

If you are more comfortable with video format, refer to the getting started video describing how to set up Intel distribution for GDB to debug a SYCL* app with kernels offloaded to the GPU device.

  1. For a sample application, set a breakpoint inside the kernel to the line marked as breakpoint-here in the array-transform.cpp file. For OpenCL application, open the kernel file (.CL) in Microsoft Visual Studio and set a breakpoint at the desired line.

  2. To run the application, on the Debug toolbar, click image0Remote Windows Debugger button.

    Microsoft Visual Studio* starts the instance of Intel® Distribution for GDB* that is responsible for debugging kernels offloaded to GPU.

    Note

    Once you start Intel® Distribution for GDB*, you may see several pop-ups.

    • You may be prompted to log in to Intel® Distribution for GDB on the target system. Be sure that credentials are set for the target system.

    • If you see the error message “Target is not available. GDB Server cannot be run automatically” for the first time, run the server on the target manually. Then, you can ignore the message and click OK.

    • Do not click Cancel when you see the “Attaching to the GPU process” message.

    The program stops at the breakpoint. The expected output is the following:

    image1

    Do not expect the output you receive will match exactly the one provided in the picture. The output may vary due to the nature of parallelism and different machine properties.

  3. Now you can investigate local variables, registers, and disassembly by opening the corresponding windows from the Debug tab.

    • To investigate local variables, go to Debug > Windows > Locals.

      You can see the values of element and result variables during the current state of the program execution.

      image2

    • To look into disassembly, go to Debug > Windows > Disassembly.

      image3

    • To investigate registers, go to Debug > Windows > Registers.

      You can see general purpose registers.

      image4

      To see ARF registers in the register window, right-click inside the window and check  Other registers  option.

      image5

  4. You can step through the program using the image6Step button.

  5. If you click Continue, another thread will hit the same breakpoint, so that you can investigate what is happening inside this thread in detail.

  6. Remove the breakpoints and click Continue to continue until the end of the program.