Debug an Application on a GPU
- For a sample application, set a breakpoint inside the kernel to the line marked asbreakpoint-herein thearray-transform.cppfile. For OpenCL application, open the kernel file (.CL) in Microsoft Visual Studio and set a breakpoint at the desired line.
- To run the application, on theDebugtoolbar, clickRemote Windows Debuggerbutton.Microsoft Visual Studio* starts the instance of Intel® Distribution for GDB* that is responsible for debugging kernels offloaded to GPU.Once you start Intel® Distribution for GDB*, you may see several pop-ups.
The program stops at the breakpoint. The expected output is the following: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.
- 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 clickOK.
- Do not clickCancelwhen you see the “Attaching to the GPU process” message.
- Now you can investigate local variables, registers, and disassembly by opening the corresponding windows from theDebugtab.
- To investigate local variables, go toDebug > Windows > Locals.You can see the values ofelementandresultvariables during the current state of the program execution.
- To look into disassembly, go toDebug > Windows > Disassembly.
- To investigate registers, go toDebug > Windows > Registers.You can see general purpose registers.To see ARF registers in the register window, right-click inside the window and checkOther registersoption.
- You can step through the program using theStepbutton.
- If you clickContinue, another thread will hit the same breakpoint, so that you can investigate what is happening inside this thread in detail.
- Remove the breakpoints and clickContinueto continue until the end of the program.