Configure debugging environment#

  1. Activate the debugger and compiler:

    export ONEAPI_ROOT=/path/to/oneapi
    source $ONEAPI_ROOT/debugger/latest/env/vars.sh
    source $ONEAPI_ROOT/compiler/latest/env/vars.sh
    
  2. Create and activate conda environment with the installed numba-dpex:

    conda create numba-dpex-dev numba-dpex
    conda activate numba-dpex-dev
    
  3. Activate NEO drivers (optional).

    If you want to use the local NEO driver, activate the variables for it. See the NEO driver.

  4. Check debugging environment.

    You can check the correctness of the work with the following example:

     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    c[i] = a[i] + b[i]  # Condition breakpoint location
    14
    15
    16global_size = 10
    17N = global_size
    18
    19a = np.array(np.random.random(N), dtype=np.float32)
    20b = np.array(np.random.random(N), dtype=np.float32)
    21c = np.ones_like(a)
    22
    23ndpx.call_kernel(data_parallel_sum, ndpx.Range(global_size), a, b, c)
    24
    25print("Done...")
    

    Launch the Intel® Distribution for GDB* and set a breakpoint in the kernel:

    $ gdb-oneapi -q --args python simple_sum.py
    (gdb) break simple_sum.py:22
    No source file named simple_sum.py.
    Make breakpoint pending on future shared library load? (y or [n]) y
    Breakpoint 1 (simple_sum.py:22) pending.
    (gdb) run
    

    In the output you can see that the breakpoint was hit successfully:

    Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::data_parallel_sum () at simple_sum.py:22
    22           i = dpex.get_global_id(0)
    (gdb) continue
    Done...
    ...