Information About a Frame

See GDB* documentation.

info args

Test numba_dpex/tests/debugging/test_info.py:test_info_args.

Note

Requires Numba 0.55 or higher. In previous versions info args always returns No arguments..

Example

Source code numba_dpex/examples/debug/side-by-side.py:

14def common_loop_body(param_a, param_b):
15    param_c = param_a + numba.float32(10)  # Set breakpoint here
16    param_d = param_b * numba.float32(0.5)
17    result = param_c + param_d
18    return result

Debug session:

$ NUMBA_OPT=0 gdb-oneapi -q python
...
(gdb) break side-by-side.py:25
...
(gdb) run numba_dpex/examples/debug/side-by-side.py --api=numba-dpex-kernel
...
Thread 2.1 hit Breakpoint 1, with SIMD lanes [0-7], __main__::common_loop_body (param_a=0, param_b=0) at side-by-side.py:25
25          param_c = param_a + 10  # Set breakpoint here
(gdb) info args
param_a = 0
param_b = 0

info locals

Test numba_dpex/tests/debugging/test_info.py:test_info_locals.

Note

Requires Numba 0.55 or higher.

Example

Source code sum_local_vars.py:

 5import dpnp as np
 6
 7import numba_dpex as ndpx
 8
 9
10@ndpx.kernel(debug=True)
11def data_parallel_sum(item, a, b, c):
12    i = item.get_id(0)
13    l1 = a[i] + 2.5
14    l2 = b[i] * 0.3
15    c[i] = l1 + l2
16
17
18global_size = 10
19N = global_size
20
21a = np.array(np.random.random(N), dtype=np.float32)
22b = np.array(np.random.random(N), dtype=np.float32)
23c = np.ones_like(a)
24
25ndpx.call_kernel(data_parallel_sum, ndpx.Range(global_size), a, b, c)
26
27print("Done...")

Run the debugger with NUMBA_OPT=0:

$ NUMBA_OPT=0 gdb-oneapi -q python
(gdb) set breakpoint pending on
(gdb) break sum_local_vars.py:22
(gdb) run sum_local_vars.py
...
Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::data_parallel_sum () at sum_local_vars.py:22

Use info locals. Note that uninitialized variables are zeros:

(gdb) info locals
a = '\000' <repeats 55 times>
b = '\000' <repeats 55 times>
c = '\000' <repeats 55 times>
i = 0
l1 = 0
l2 = 0
__ocl_dbg_gid0 = 0
__ocl_dbg_gid1 = 0
__ocl_dbg_gid2 = 0
__ocl_dbg_lid0 = 0
__ocl_dbg_lid1 = 0
__ocl_dbg_lid2 = 0
__ocl_dbg_grid0 = 0
__ocl_dbg_grid1 = 0
__ocl_dbg_grid2 = 0
(gdb) next
Thread 2.3 hit Breakpoint 1, with SIMD lanes [0-1], __main__::data_parallel_sum () at sum_local_vars.py:22
22          i = dpex.get_global_id(0)
(gdb) next
23          l1 = a[i] + 2.5
(gdb) next
24          l2 = b[i] * 0.3
(gdb) info locals
a = '\000' <repeats 55 times>
b = '\000' <repeats 16 times>, "\n\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\240\016XUU\000\000\n\000\000\000\000\000\000\000\004\000\000\000\000\000\000"
c = '\000' <repeats 16 times>, "\n\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000@\256WUU\000\000\n\000\000\000\000\000\000\000\004\000\000\000\000\000\000"
i = 8
l1 = 2.5931931659579277
l2 = 0
__ocl_dbg_gid0 = 0
__ocl_dbg_gid1 = 0
__ocl_dbg_gid2 = 0
__ocl_dbg_lid0 = 42949672970
__ocl_dbg_lid1 = 0
__ocl_dbg_lid2 = 93825037590528
__ocl_dbg_grid0 = 4612811918334230528
__ocl_dbg_grid1 = 0
__ocl_dbg_grid2 = 0
(gdb) next
25          c[i] = l1 + l2