Backtrace

The backtrace command displays a summary of how your program got where it is. Consider the following example numba_dpex/examples/debug/simple_dppy_func.py:

15import dpctl
16import numpy as np
17
18import numba_dpex as dppy
19
20
21@dppy.func(debug=True)
22def func_sum(a_in_func, b_in_func):
23    result = a_in_func + b_in_func
24    return result
25
26
27@dppy.kernel(debug=True)
28def kernel_sum(a_in_kernel, b_in_kernel, c_in_kernel):
29    i = dppy.get_global_id(0)
30    c_in_kernel[i] = func_sum(a_in_kernel[i], b_in_kernel[i])
31
32
33global_size = 10
34a = np.arange(global_size, dtype=np.float32)
35b = np.arange(global_size, dtype=np.float32)
36c = np.empty_like(a)
37
38device = dpctl.SyclDevice("opencl:gpu")
39with dpctl.device_context(device):
40    kernel_sum[global_size, dppy.DEFAULT_LOCAL_SIZE](a, b, c)
41
42print("Done...")

The section presents two examples of using Intel Distribution for GDB* to generate backtrace from a numa_dppy.kernel function. The first example presents the case where the kernel function does not invoke any other function. The second example presents the case where the kernel function invokes a numba_dpex.func.

Example 1:

$ NUMBA_OPT=0 gdb-oneapi -q python
(gdb) set breakpoint pending on
(gdb) break simple_dppy_func.py:28
(gdb) run simple_dppy_func.py
...
Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::kernel_sum () at simple_dppy_func.py:28
28          i = dppy.get_global_id(0)
(gdb) backtrace
#0  __main__::kernel_sum () at simple_dppy_func.py:28
(gdb) continue
...
[Switching to Thread 1.1073742080 lane 0]
Thread 2.3 hit Breakpoint 1, with SIMD lanes [0-1], __main__::kernel_sum () at simple_dppy_func.py:28
28          i = dppy.get_global_id(0)
(gdb) continue
...
Done...

Example 2:

$ NUMBA_OPT=0 gdb-oneapi -q python
(gdb) set breakpoint pending on
(gdb) break simple_dppy_func.py:22
(gdb) run simple_dppy_func.py
...
Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::func_sum () at simple_dppy_func.py:22
22          result = a_in_func + b_in_func
(gdb) backtrace
#0  __main__::func_sum () at simple_dppy_func.py:22
#1  __main__::kernel_sum () at simple_dppy_func.py:29
(gdb) continue
...
[Switching to Thread 1.1073742080 lane 0]
Thread 2.3 hit Breakpoint 1, with SIMD lanes [0-1], __main__::func_sum () at simple_dppy_func.py:22
22          result = a_in_func + b_in_func
(gdb) continue
...
Done...

See also: