Multi-Target
The multi-target feature enables debugging of multiple targets in a single debugging session.
With this feature, you can define breakpoints inside and outside the kernel to debug the host portion of the program. For example, define two breakpoints and run the target as follows:
$ export ONEAPI_DEVICE_SELECTOR=level_zero:gpu
$ export ZET_ENABLE_PROGRAM_DEBUGGING=1
$ gdb-oneapi array-transform
(gdb) break 54
Breakpoint 1 at 0x405800: file /path/to/array-transform.cpp, line 54.
(gdb) break 81
Breakpoint 2 at 0x403e13: file /path/to/array-transform.cpp, line 81.
(gdb) run gpu
[...]
[Switching to thread 2.9:0 (ZE 0.0.1.0 lane 0)]
Thread 2.129 hit Breakpoint 1, with SIMD lanes [0-7], main::{lambda(auto:1&)#1}::operator()[...] at array-transform.cpp:54
54 int element = in[index]; // breakpoint-here
Now you are inside the kernel (in this case, the kernel is running on the GPU). The context is Thread 2.129, lane 0.
Disable the breakpoint at line 54 and continue:
(gdb) disable 1
(gdb) continue
Continuing.
[Switching to thread 1.1 (Thread 0x7ffff502bc40 (LWP 927533))]
Thread 1.1 "array-transform" hit Breakpoint 2, main (argc=2, argv=0x7fffffffd098) at array-transform.cpp:81
81 cout << "success; result is correct.\n"; // success
This time the stop event is received from the host. The context is automatically switched to Thread 1.1. You can investigate the host-side values. For example, try executing print input and print output as follows:
(gdb) print input[6]
$1 = 106
(gdb) print output[6]
$2 = 206