Tutorial: Debugging with Intel® Distribution for GDB*
For remote debugging, configure your systems the following way:
The setup procedure depends on whether you want to debug a DPC++, OpenMP™, or OpenCL™ program.
Debugging DPC++ Program
Follow the steps below to setup the debugging session for the Array Transform sample:
On your host system, launch Microsoft Visual Studio*. Navigate to Extensions > Intel > Browse Intel® oneAPI Samples. Under Intel® oneAPI Base Toolkit > Debugger, select the Array Transform sample.
Navigate to Property pages > DPC++ and ensure that Debug Information Format is set to Program Database. Go to the Optimization tab and ensure that Set Optimization is disabled. Go to Property pages > Linker and set Pass additional options to device compilers to `/Od`.
Compile your application.
Debugging OpenMP Program
Debugging OpenCL Program
To debug an OpenCL program, the kernel source file must be available on both host and target systems under the same absolute path. To achieve that, do any of the following:
Share the sources of you project from the host to the target system and create a symbolic link on the target that mirrors the host path to the kernel.
If your project is located on a shared drive, which is accessible from both host and target systems, use its network path everywhere.
Ensure 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.
Without the flag, Microsoft Visual Studio cannot set a breakpoint inside the kernel.
Open Tools > Options > Intel® oneAPI > Intel® Distribution for GDB*.
Set Enable Debugging to True.
Set Server to the name of the remote target system displayed in the Visual Studio remote debugger .
Set TCP/IP post to the port number used when running gdbserver-gt. The default is 1234 .
Open array-transform Property Pages. Under Configuration Properties choose Debugging.
From the Debugger to launch drop-down menu, choose Remote Windows* Debugger.
Set Remote Command to the path to <path_to_deployment_directory>\array-transform.exe.
Set Working Directory to <path_to_deployment_directory>.
Update Remote Server Name. The default port used by the Microsoft Visual Studio* 2019 Remote Debugger server is 4024.
Set Deployment Directory to <path_to_deployment_directory>.
The array-transform executable will be copied to this location on the target system.To debug an OpenMP project, set environment variables as follows:
LIBOMPTARGET_DEVICETYPE=GPU
LIBOMPTARGET_PLUGIN=opencl
For opencl:
LIBOMPTARGET_OPENCL_COMPILATION_OPTIONS=-g -cl-opt-disable
For level0:
LIBOMPTARGET_LEVEL0_COMPILATION_OPTIONS=-g -cl-opt-disable
LIBOMPTARGET_PROFILE=T
LIBOMPTARGET_DEBUG=1
Run the Microsoft Visual Studio* remote debugger. For instructions, see the Microsoft documentation.
gdbserver-gt starts automatically on the target system when debugging is enabled. If not, run the server on the target manually.
Now you are all set to debug both host side of the program and the GPU kernel.