Backtrace¶
The backtrace
command displays a summary of how your program got where it
is. Consider the following example
numba_dpex/examples/debug/simple_dpex_func.py
:
5import dpnp as np
6
7import numba_dpex as ndpx
8
9
10@ndpx.device_func(debug=True)
11def func_sum(a_in_func, b_in_func):
12 result = a_in_func + b_in_func # breakpoint location
13 return result
14
15
16@ndpx.kernel(debug=True)
17def kernel_sum(item, a_in_kernel, b_in_kernel, c_in_kernel):
18 i = item.get_id(0)
19 c_in_kernel[i] = func_sum(a_in_kernel[i], b_in_kernel[i])
20
21
22global_size = 10
23a = np.arange(global_size, dtype=np.float32)
24b = np.arange(global_size, dtype=np.float32)
25c = np.empty_like(a)
26
27ndpx.call_kernel(kernel_sum, ndpx.Range(global_size), a, b, c)
28
29print("Done...")
The section presents two examples of using Intel Distribution for GDB* to generate backtrace from a numa_dpex.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_dpex_func.py:28
(gdb) run simple_dpex_func.py
...
Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::kernel_sum () at simple_dpex_func.py:28
28 i = dpex.get_global_id(0)
(gdb) backtrace
#0 __main__::kernel_sum () at simple_dpex_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_dpex_func.py:28
28 i = dpex.get_global_id(0)
(gdb) continue
...
Done...
Example 2:
$ NUMBA_OPT=0 gdb-oneapi -q python
(gdb) set breakpoint pending on
(gdb) break simple_dpex_func.py:22
(gdb) run simple_dpex_func.py
...
Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::func_sum () at simple_dpex_func.py:22
22 result = a_in_func + b_in_func
(gdb) backtrace
#0 __main__::func_sum () at simple_dpex_func.py:22
#1 __main__::kernel_sum () at simple_dpex_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_dpex_func.py:22
22 result = a_in_func + b_in_func
(gdb) continue
...
Done...
See also: