Debugging with Intel® Distribution for GDB*

You can debug SYCL* kernels with Intel® Distribution for GDB*. To enable the emission of debug information, set the debug environment variable NUMBA_DPEX_DEBUGINFO, for example: export NUMBA_DPEX_DEBUGINFO=1 To disable debugging, unset the variable: unset NUMBA_DPEX_DEBUGINFO

Note

Enabling debug information significantly increases the memory consumption for each compiled kernel. For a large application, this may cause out-of-memory error.

Not all debugging features supported by Numba on CPUs are yet supported by the extension. See Features and Limitations.

Requirements

Intel® Distribution for GDB* is required for debugging features to work. Intel® Distribution for GDB* is part of Intel oneAPI. For relevant documentation, refer to the `Intel® Distribution for GDB* product page`_.

Example of Intel® Distribution for GDB* usage

You can use a sample kernel code, simple_sum.py, for basic debugging:

15import dpctl
16import numpy as np
17
18import numba_dpex as dppy
19
20
21@dppy.kernel(debug=True)
22def data_parallel_sum(a, b, c):
23    i = dppy.get_global_id(0)
24    c[i] = a[i] + b[i]  # Condition breakpoint location
25
26
27global_size = 10
28N = global_size
29
30a = np.array(np.random.random(N), dtype=np.float32)
31b = np.array(np.random.random(N), dtype=np.float32)
32c = np.ones_like(a)
33
34device = dpctl.SyclDevice("opencl:gpu")
35with dpctl.device_context(device):
36    data_parallel_sum[global_size, dppy.DEFAULT_LOCAL_SIZE](a, b, c)
37
38print("Done...")

Use the following commands to create a breakpoint inside the kernel and run the debugger:

$ NUMBA_OPT=0 gdb-oneapi -q python
(gdb) set breakpoint pending on
(gdb) break simple_sum.py:22
(gdb) run simple_sum.py
...
Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::data_parallel_sum () at simple_sum.py:22
22           i = dppy.get_global_id(0)
(gdb) next
Thread 2.3 hit Breakpoint 1, with SIMD lanes [0-1], __main__::data_parallel_sum () at simple_sum.py:22
22           i = dppy.get_global_id(0)
(gdb) next
23           c[i] = a[i] + b[i]
(gdb) continue
...
Done...

Features and Limitations