Skip to content

Adopt Numba 0.55 debugging features #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d9317ed
expected_line
PokhodenkoSA Dec 22, 2021
cb9b54a
Rename and refactor symbols.rst
PokhodenkoSA Dec 22, 2021
17b435a
frame_info
PokhodenkoSA Dec 22, 2021
4aa0009
frame_info: info locals
PokhodenkoSA Dec 22, 2021
221f1d2
frame_info: info locals
PokhodenkoSA Dec 22, 2021
bfe9a01
features: other topics
PokhodenkoSA Dec 22, 2021
30ba8f3
local_variables: title
PokhodenkoSA Dec 22, 2021
2dd937d
frame_info: links
PokhodenkoSA Dec 22, 2021
d86482c
numba-0.55
PokhodenkoSA Dec 22, 2021
b5661da
test_info_args
PokhodenkoSA Dec 22, 2021
2acd654
frame_info: info args: note
PokhodenkoSA Dec 22, 2021
6f05e97
numba-0.55: example
PokhodenkoSA Dec 23, 2021
3f8ad08
test_breakpoint_with_condition_by_function_argument
PokhodenkoSA Dec 23, 2021
1a12a7e
test_info_args
PokhodenkoSA Dec 23, 2021
61201ee
test_info_args: side-by-side
PokhodenkoSA Dec 23, 2021
beb12ac
frame_info: info args: example
PokhodenkoSA Dec 23, 2021
a43d823
numba-0.55: info args
PokhodenkoSA Dec 23, 2021
474dfed
frame_info: info args: small fix
PokhodenkoSA Dec 23, 2021
0098faf
test_info_args
PokhodenkoSA Dec 23, 2021
1886143
test_info_locals_NUMBA_OPT_0
PokhodenkoSA Dec 23, 2021
e378ec0
Add TESTING_LOG_DEBUGGING
PokhodenkoSA Dec 23, 2021
72347c2
local_variables.rst: numba-opt
PokhodenkoSA Dec 23, 2021
676b1ae
test_info_locals
PokhodenkoSA Dec 23, 2021
bf202ee
local_variables.rst: lifetime: examples
PokhodenkoSA Dec 23, 2021
0c369a0
gdb.py: set_environment
PokhodenkoSA Dec 23, 2021
e9d5a78
frame_info.rst: info locals
PokhodenkoSA Dec 23, 2021
9811d19
features.rst: title and head
PokhodenkoSA Dec 23, 2021
38d29ac
test_info_locals
PokhodenkoSA Dec 23, 2021
54cd17d
numba-0.55: NUMBA_EXTEND_VARIABLE_LIFETIMES
PokhodenkoSA Dec 23, 2021
d890ff0
Move whatis and ptype to symbols.rst
PokhodenkoSA Dec 24, 2021
6d828bd
Move print to data.rst
PokhodenkoSA Dec 24, 2021
5456065
test_info: side-by-side2.py
PokhodenkoSA Dec 24, 2021
f1ea5c6
data.rst: complex data
PokhodenkoSA Dec 24, 2021
8830c20
symbols.rst: complex data
PokhodenkoSA Dec 24, 2021
17ac107
numba-0.55: complex data
PokhodenkoSA Dec 24, 2021
368095e
local_variables: ANNOTATION
PokhodenkoSA Dec 27, 2021
ff3da9f
numba-0.55: NUMBA_EXTEND_VARIABLE_LIFETIMES and NUMBA_DUMP_ANNOTATION
PokhodenkoSA Dec 27, 2021
0da56f1
test_print_array_element
PokhodenkoSA Dec 27, 2021
aaf2c0b
data.rst: array element
PokhodenkoSA Dec 27, 2021
c6797fa
numba-0.55: array element
PokhodenkoSA Dec 27, 2021
06c9393
data.rst: source code
PokhodenkoSA Dec 27, 2021
c6ef29d
frame_info.rst: sources code
PokhodenkoSA Dec 27, 2021
fcd2928
symbol.rst: sources code
PokhodenkoSA Dec 27, 2021
a4e287e
Add sltering.rst
PokhodenkoSA Dec 27, 2021
3baf18d
featires: altering
PokhodenkoSA Dec 27, 2021
86eb7ca
test_assignment_to_variable
PokhodenkoSA Dec 27, 2021
981c78d
test_assignment_to_variable
PokhodenkoSA Dec 27, 2021
8046e87
altering: limitation
PokhodenkoSA Dec 27, 2021
4c3739b
limitations.rst: clean and alter argument
PokhodenkoSA Dec 27, 2021
b8999bb
limitations: gdb()
PokhodenkoSA Dec 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/user_guides/debugging/altering.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Altering Execution
==================

See `GDB* documentation <https://sourceware.org/gdb/onlinedocs/gdb/Altering.html>`_.

.. _assignment-to-variables:

Assignment to Variables
-----------------------

To alter the value of a variable, evaluate an assignment expression.
This also works for function arguments.

.. note::

Altering arguments has limitation. For it to work correctly
arguments should not be modified in code.
See `Numba issue <https://github.com/numba/numba/pull/7196>`_.

Example
```````

Source code :file:`numba_dppy/examples/debug/side-by-side-2.py`:

.. literalinclude:: ../../../numba_dppy/examples/debug/side-by-side-2.py
:pyobject: common_loop_body
:linenos:
:lineno-match:
:emphasize-lines: 6

Debug session:

.. code-block:: shell-session
:emphasize-lines: 11-

$ gdb-oneapi -q python
...
(gdb) set environment NUMBA_OPT 0
(gdb) set environment NUMBA_EXTEND_VARIABLE_LIFETIMES 1
(gdb) break side-by-side-2.py:29 if param_a == 5
...
(gdb) run numba_dppy/examples/debug/side-by-side-2.py --api=numba-dppy-kernel
...
Thread 2.1 hit Breakpoint 1, with SIMD lane 5, __main__::common_loop_body (i=5, a=..., b=...) at side-by-side-2.py:29
29 result = param_c + param_d
(gdb) print param_c
$1 = 15
(gdb) print param_c=200
$2 = 200
(gdb) print param_c
$3 = 200
58 changes: 58 additions & 0 deletions docs/user_guides/debugging/data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Examining Data
==============

See `GDB* documentation <https://www.sourceware.org/gdb/onlinedocs/gdb/Data.html>`_.

.. _print:

``print expr``
--------------

To print the value of a variable, run the ``print <variable>`` command.

.. literalinclude:: ../../../numba_dppy/examples/debug/commands/docs/local_variables_0
:language: shell-session
:lines: 67-72
:emphasize-lines: 1-6

.. note::

Displaying complex data types requires Numba 0.55 or higher.

Example - Complex Data Types
````````````````````````````

Source code :file:`numba_dppy/examples/debug/side-by-side-2.py`:

.. literalinclude:: ../../../numba_dppy/examples/debug/side-by-side-2.py
:pyobject: common_loop_body
:linenos:
:lineno-match:
:emphasize-lines: 6

Debug session:

.. code-block:: shell-session
:emphasize-lines: 9-

$ gdb-oneapi -q python
...
(gdb) set environment NUMBA_OPT 0
(gdb) set environment NUMBA_EXTEND_VARIABLE_LIFETIMES 1
(gdb) break side-by-side-2.py:29 if param_a == 5
...
(gdb) run numba_dppy/examples/debug/side-by-side-2.py --api=numba-dppy-kernel
...
Thread 2.1 hit Breakpoint 1, with SIMD lane 5, __main__::common_loop_body (i=5, a=..., b=...) at side-by-side-2.py:29
29 result = param_c + param_d
(gdb) print a
$1 = {meminfo = 0x0, parent = 0x0, nitems = 10, itemsize = 4,
data = 0x555558461000, shape = {10}, strides = {4}}
(gdb) x/10f a.data
0x555558461000: 0 1 2 3
0x555558461010: 4 5 6 7
0x555558461020: 8 9
(gdb) print a.data[5]
$2 = 5

This example prints array and its element.
25 changes: 15 additions & 10 deletions docs/user_guides/debugging/features.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
Supported Features
====================
==================

The following debugging features are available:

- Source location (filename and line number).
- Setting breakpoints by the line number.
- Stepping over breakpoints.

Numba-dppy supports the following Intel® Distribution for GDB* commands:
Numba-dppy and Intel® Distribution for GDB* provide at least
following debugging features:

.. toctree::
:maxdepth: 2

breakpoints
stepping
local_variables
frame_info
backtrace
info
data
symbols
altering

Other topics:

.. toctree::
:maxdepth: 2

local_variables
numba-0.55
79 changes: 79 additions & 0 deletions docs/user_guides/debugging/frame_info.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Information About a Frame
=========================

See `GDB* documentation <https://www.sourceware.org/gdb/onlinedocs/gdb/Frame-Info.html>`_.

.. _info-args:

``info args``
-------------

Test :file:`numba_dppy/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 :file:`numba_dppy/examples/debug/side-by-side.py`:

.. literalinclude:: ../../../numba_dppy/examples/debug/side-by-side.py
:pyobject: common_loop_body
:linenos:
:lineno-match:
:emphasize-lines: 2

Debug session:

.. code-block:: shell-session
:emphasize-lines: 9-11

$ NUMBA_OPT=0 gdb-oneapi -q python
...
(gdb) break side-by-side.py:25
...
(gdb) run numba_dppy/examples/debug/side-by-side.py --api=numba-dppy-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:

``info locals``
---------------

Test :file:`numba_dppy/tests/debugging/test_info.py:test_info_locals`.

.. note::

Requires Numba 0.55 or higher.

Example
```````

Source code :file:`sum_local_vars.py`:

.. literalinclude:: ../../../numba_dppy/examples/debug/sum_local_vars.py
:lines: 15-
:linenos:
:lineno-match:

Run the debugger with ``NUMBA_OPT=0``:

.. literalinclude:: ../../../numba_dppy/examples/debug/commands/docs/local_variables_0
:language: shell-session
:lines: 1-6

Use ``info locals``.
Note that uninitialized variables are zeros:

.. literalinclude:: ../../../numba_dppy/examples/debug/commands/docs/local_variables_0
:language: shell-session
:lines: 8-48
:emphasize-lines: 1-16, 24-39
42 changes: 0 additions & 42 deletions docs/user_guides/debugging/info.rst

This file was deleted.

26 changes: 18 additions & 8 deletions docs/user_guides/debugging/limitations.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
Limitations
===========

Currently Numba-dppy provides only initial support of debugging SYCL* kernels.
The following functionality is **limited** or **not supported**:

- Information about variable values may not match the actual values while debugging.
- Information about variable types is limited.
- Printing kernel arguments is not supported.
- Overwriting the value of a variable is not supported.
- Accessing elements of a complex variable type is not supported.
The following functionality is **limited** or **not supported**.

Altering arguments modified in code
-----------------------------------

Altering arguments has limitation. For it to work correctly
arguments should not be modified in code.
See `Numba issue <https://github.com/numba/numba/pull/7196>`_.

See :ref:`assignment-to-variables`.

Using Numba’s direct ``gdb`` bindings in ``nopython`` mode
----------------------------------------------------------

Using Numba’s direct ``gdb`` bindings in ``nopython`` mode is not supported in
Numba DPPY.

See `Numba documentation <https://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#using-numba-s-direct-gdb-bindings-in-nopython-mode>`_.
Loading