-
Notifications
You must be signed in to change notification settings - Fork 33
Update User Guides about Debugging #380
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
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
33bba1b
Remove config html_static_path
PokhodenkoSA c39ffbd
Update debugging docs
PokhodenkoSA e4bc799
Add caption to sum.py code
PokhodenkoSA a768e40
Use :envvar: for environment variables
PokhodenkoSA 4627d12
Update docs/user_guides/debugging.rst
PokhodenkoSA f911e1d
Fix link to debugging from README
PokhodenkoSA e6af52b
Merge branch 'main' into spokhode/docs/debug
PokhodenkoSA dcb16ae
Remove extension from toctree links
PokhodenkoSA 5d00a8e
Fix link to kernel()
PokhodenkoSA c0b0b70
Add warning about debug info size
PokhodenkoSA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Debugging With GDB | ||
================== | ||
|
||
`numba-dppy` allows SYCL kernels to be debugged with the GDB debugger. | ||
Setting the debug environment variable :envvar:`NUMBA_DPPY_DEBUG` (e.g. | ||
``export NUMBA_DPPY_DEBUG=1``) enables the emission of debug information. | ||
To disable debugging, unset the variable, i.e ``unset NUMBA_DPPY_DEBUG``. | ||
|
||
Not all GDB features supported by Numba on CPUs are yet supported in `numba-dppy`. | ||
Currently, the following debugging features are available: | ||
|
||
- Source location (filename and line number). | ||
- Setting break points by the line number. | ||
- Stepping over break points. | ||
|
||
.. note:: | ||
|
||
Debug features depend heavily on optimization level. | ||
At full optimization (equivalent to O3), most of the variables are optimized out. | ||
It is recommended to debug at "no optimization" level via :envvar:`NUMBA_OPT` (e.g. ``export NUMBA_OPT=0``). | ||
For more information refer to the Numba documentation | ||
`Debugging JIT compiled code with GDB <https://numba.pydata.org/numba-doc/latest/user/troubleshoot.html?highlight=numba_opt#debugging-jit-compiled-code-with-gdb>`_. | ||
|
||
Requirements | ||
------------ | ||
|
||
Intel® Distribution for GDB is needed for `numba-dppy`'s debugging features | ||
to work. Intel® Distribution for GDB is part of Intel oneAPI and the relevant | ||
documentation can be found at | ||
`Intel® Distribution for GDB documentation <https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/distribution-for-gdb.html>`_. | ||
|
||
Example of GDB usage | ||
-------------------- | ||
|
||
For example, given the following `numba-dppy` kernel code: | ||
|
||
.. code-block:: python | ||
:caption: sum.py | ||
:linenos: | ||
|
||
import numpy as np | ||
import numba_dppy as dppy | ||
import dpctl | ||
|
||
@dppy.kernel | ||
def data_parallel_sum(a, b, c): | ||
i = dppy.get_global_id(0) | ||
c[i] = a[i] + b[i] | ||
|
||
global_size = 10 | ||
N = global_size | ||
|
||
a = np.array(np.random.random(N), dtype=np.float32) | ||
b = np.array(np.random.random(N), dtype=np.float32) | ||
c = np.ones_like(a) | ||
|
||
with dpctl.device_context("opencl:gpu") as gpu_queue: | ||
data_parallel_sum[global_size, dppy.DEFAULT_LOCAL_SIZE](a, b, c) | ||
|
||
Running GDB and creating breakpoint in kernel: | ||
|
||
.. code-block:: bash | ||
|
||
$ export NUMBA_DPPY_DEBUG=1 | ||
$ gdb-oneapi -q --args python sum.py | ||
(gdb) break sum.py:7 # Set breakpoint in kernel | ||
(gdb) run | ||
Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], dppl_py_devfn__5F__5F_main_5F__5F__2E_data_5F_parallel_5F_sum_24_1_2E_array_28_float32_2C__20_1d_2C__20_C_29__2E_array_28_float32_2C__20_1d_2C__20_C_29__2E_array_28_float32_2C__20_1d_2C__20_C_29_ () at sum.py:7 | ||
7 i = dppy.get_global_id(0) | ||
(gdb) next | ||
8 c[i] = a[i] + b[i] | ||
|
||
Limitations | ||
----------- | ||
|
||
Currently, `numba-dppy` provides only initial support of debugging SYCL kernels. | ||
The following functionalities are **not supported**: | ||
|
||
- Printing kernel local variables (e.g. ``info locals``). | ||
- Stepping over several offloaded functions. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.