From 15ea8c7e73d6f6353e59948bccc33dfeb38f44b2 Mon Sep 17 00:00:00 2001 From: akharche Date: Tue, 24 Nov 2020 16:29:11 +0300 Subject: [PATCH 1/9] Add flags to generate debug symbols --- numba_dppy/compiler.py | 9 +++++++-- numba_dppy/target.py | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/numba_dppy/compiler.py b/numba_dppy/compiler.py index cf7bca2822..1d5f15a98e 100644 --- a/numba_dppy/compiler.py +++ b/numba_dppy/compiler.py @@ -19,16 +19,18 @@ import os from numba.core.compiler import DefaultPassBuilder, CompilerBase -DEBUG=os.environ.get('NUMBA_DPPL_DEBUG', None) +DEBUG = os.environ.get('NUMBA_DPPL_DEBUG', None) _NUMBA_DPPL_READ_ONLY = "read_only" _NUMBA_DPPL_WRITE_ONLY = "write_only" _NUMBA_DPPL_READ_WRITE = "read_write" + def _raise_no_device_found_error(): error_message = ("No OpenCL device specified. " "Usage : jit_fn[device, globalsize, localsize](...)") raise ValueError(error_message) + def _raise_invalid_kernel_enqueue_args(): error_message = ("Incorrect number of arguments for enquing dppl.kernel. " "Usage: device_env, global size, local size. " @@ -77,9 +79,11 @@ def compile_with_dppl(pyfunc, return_type, args, debug): typingctx = dppl_target.typing_context targetctx = dppl_target.target_context - # TODO handle debug flag + flags = compiler.Flags() # Do not compile (generate native code), just lower (to LLVM) + if debug: + flags.set('debuginfo') flags.set('no_compile') flags.set('no_cpython_wrapper') flags.unset('nrt') @@ -116,6 +120,7 @@ def compile_with_dppl(pyfunc, return_type, args, debug): def compile_kernel(sycl_queue, pyfunc, args, access_types, debug=False): if DEBUG: print("compile_kernel", args) + debug = True if not sycl_queue: # This will be get_current_queue sycl_queue = dpctl.get_current_queue() diff --git a/numba_dppy/target.py b/numba_dppy/target.py index aac4efcd4b..505a8c47a5 100644 --- a/numba_dppy/target.py +++ b/numba_dppy/target.py @@ -254,7 +254,10 @@ def sub_gen_with_global(lty): def declare_function(self, module, fndesc): fnty = self.call_conv.get_function_type(fndesc.restype, fndesc.argtypes) fn = module.get_or_insert_function(fnty, name=fndesc.mangled_name) - fn.attributes.add('alwaysinline') + + if not self.enable_debuginfo: + fn.attributes.add('alwaysinline') + ret = super(DPPLTargetContext, self).declare_function(module, fndesc) # XXX: Refactor fndesc instead of this special case if fndesc.llvm_func_name.startswith('dppl_py_devfn'): From 41fc3c1b21051400ac312dbb1948cc0da96461b7 Mon Sep 17 00:00:00 2001 From: Angelina Kharchevnikova Date: Wed, 9 Dec 2020 19:36:07 +0300 Subject: [PATCH 2/9] Merge main to akharche/enable_kernel_debug --- numba_dppy/compiler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/numba_dppy/compiler.py b/numba_dppy/compiler.py index 1bec7cc4c5..b93f29801a 100644 --- a/numba_dppy/compiler.py +++ b/numba_dppy/compiler.py @@ -21,10 +21,10 @@ from numba.core.compiler import DefaultPassBuilder, CompilerBase -DEBUG = os.environ.get('NUMBA_DPPL_DEBUG', None) -_NUMBA_DPPL_READ_ONLY = "read_only" -_NUMBA_DPPL_WRITE_ONLY = "write_only" -_NUMBA_DPPL_READ_WRITE = "read_write" +DEBUG = os.environ.get('NUMBA_DPPY_DEBUG', None) +_NUMBA_DPPY_READ_ONLY = "read_only" +_NUMBA_DPPY_WRITE_ONLY = "write_only" +_NUMBA_DPPY_READ_WRITE = "read_write" def _raise_no_device_found_error(): From 3e7afed7fb73542ca66cb369ef305c8a465f5842 Mon Sep 17 00:00:00 2001 From: Angelina Kharchevnikova Date: Wed, 9 Dec 2020 20:07:50 +0300 Subject: [PATCH 3/9] Add documentation about how to use gdb --- CONTRIBUTING.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..fc85f81839 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,19 @@ +## Debugging with GDB + +Setting the debug environment variable NUMBA_DPPY_DEBUG (e.g. export NUMBA_DPPY_DEBUG=True) enables the emission of debug info to +the llvm and spirv IR. To disable debugging set this variable to None: (e.g. export NUMBA_DPPL_DEBUG= ). +Currently, the following debug info is available: +- Source location (filename and line number) is available. +- Setting break points by the line number. +- Stepping over break points. + +### Requirements +Intel GDB installed to the system +follow the instruction: https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/distribution-for-gdb.html + +### Example debug usage +~~~ +$ gdb -q python +(gdb) break sum.py:13 # Assumes the kernel is in file sum.py, at line 13 +(gdb) run sum.py +~~~ From b1fc25fdcc56f7a9f8a0407af886adb66b5d0e64 Mon Sep 17 00:00:00 2001 From: akharche Date: Thu, 10 Dec 2020 13:24:31 +0300 Subject: [PATCH 4/9] Moved debug instructions --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 92c61fc1bd..7a43028117 100644 --- a/README.md +++ b/README.md @@ -63,3 +63,7 @@ examples, supported functionalities, and known issues. ## Reporting issues Please use https://github.com/IntelPython/numba-dppy/issues to report issues and bugs. + +## Debugging + +Please follow instructions in the [DEBUGGING.md](DEBUGGING.md) From fca6d114ae4e384bb645c238bfe64121104aa373 Mon Sep 17 00:00:00 2001 From: akharche Date: Thu, 10 Dec 2020 13:26:31 +0300 Subject: [PATCH 5/9] Moved debug instructions --- CONTRIBUTING.md => DEBUGGING.md | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) rename CONTRIBUTING.md => DEBUGGING.md (96%) diff --git a/CONTRIBUTING.md b/DEBUGGING.md similarity index 96% rename from CONTRIBUTING.md rename to DEBUGGING.md index fc85f81839..4a21fdb9f6 100644 --- a/CONTRIBUTING.md +++ b/DEBUGGING.md @@ -1,19 +1,19 @@ -## Debugging with GDB - -Setting the debug environment variable NUMBA_DPPY_DEBUG (e.g. export NUMBA_DPPY_DEBUG=True) enables the emission of debug info to -the llvm and spirv IR. To disable debugging set this variable to None: (e.g. export NUMBA_DPPL_DEBUG= ). -Currently, the following debug info is available: -- Source location (filename and line number) is available. -- Setting break points by the line number. -- Stepping over break points. - -### Requirements -Intel GDB installed to the system -follow the instruction: https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/distribution-for-gdb.html - -### Example debug usage -~~~ -$ gdb -q python -(gdb) break sum.py:13 # Assumes the kernel is in file sum.py, at line 13 -(gdb) run sum.py -~~~ +## Debugging with GDB + +Setting the debug environment variable NUMBA_DPPY_DEBUG (e.g. export NUMBA_DPPY_DEBUG=True) enables the emission of debug info to +the llvm and spirv IR. To disable debugging set this variable to None: (e.g. export NUMBA_DPPL_DEBUG= ). +Currently, the following debug info is available: +- Source location (filename and line number) is available. +- Setting break points by the line number. +- Stepping over break points. + +### Requirements +Intel GDB installed to the system +follow the instruction: https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/distribution-for-gdb.html + +### Example debug usage +```bash +$ gdb -q python +(gdb) break sum.py:13 # Assumes the kernel is in file sum.py, at line 13 +(gdb) run sum.py +``` From e78513336f915a01f04ecdfe2dea18448e040377 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 11 Dec 2020 16:51:51 +0300 Subject: [PATCH 6/9] Update DEBUGGING.md --- DEBUGGING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DEBUGGING.md b/DEBUGGING.md index 4a21fdb9f6..b5e06e0cbb 100644 --- a/DEBUGGING.md +++ b/DEBUGGING.md @@ -1,7 +1,7 @@ ## Debugging with GDB -Setting the debug environment variable NUMBA_DPPY_DEBUG (e.g. export NUMBA_DPPY_DEBUG=True) enables the emission of debug info to -the llvm and spirv IR. To disable debugging set this variable to None: (e.g. export NUMBA_DPPL_DEBUG= ). +Setting the debug environment variable `NUMBA_DPPY_DEBUG` (e.g. `export NUMBA_DPPY_DEBUG=True`) enables the emission of debug info to +the llvm and spirv IR. To disable debugging set this variable to None: (e.g. `export NUMBA_DPPL_DEBUG=`). Currently, the following debug info is available: - Source location (filename and line number) is available. - Setting break points by the line number. From 8d48f3a24d02ac35ae43cdb8b9e6936a41e3d0ee Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 11 Dec 2020 16:52:23 +0300 Subject: [PATCH 7/9] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7a43028117..467012663f 100644 --- a/README.md +++ b/README.md @@ -60,10 +60,10 @@ python numba_dppy/examples/sum.py Refer the HowTo.rst guide for an overview of the programming semantics, examples, supported functionalities, and known issues. -## Reporting issues - -Please use https://github.com/IntelPython/numba-dppy/issues to report issues and bugs. - ## Debugging Please follow instructions in the [DEBUGGING.md](DEBUGGING.md) + +## Reporting issues + +Please use https://github.com/IntelPython/numba-dppy/issues to report issues and bugs. From da1aedfd6034079ee987c540afc93958da0c0d37 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 11 Dec 2020 16:53:04 +0300 Subject: [PATCH 8/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 467012663f..483ad7bdad 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ python numba_dppy/examples/sum.py ## How Tos -Refer the HowTo.rst guide for an overview of the programming semantics, +Refer the [HowTo.rst](HowTo.rst) guide for an overview of the programming semantics, examples, supported functionalities, and known issues. ## Debugging From 3101de62bc4b986b5aac24131b84c7c74f29e0ec Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 11 Dec 2020 16:53:43 +0300 Subject: [PATCH 9/9] Update DEBUGGING.md --- DEBUGGING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DEBUGGING.md b/DEBUGGING.md index b5e06e0cbb..44027b318d 100644 --- a/DEBUGGING.md +++ b/DEBUGGING.md @@ -8,10 +8,12 @@ Currently, the following debug info is available: - Stepping over break points. ### Requirements + Intel GDB installed to the system follow the instruction: https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/distribution-for-gdb.html ### Example debug usage + ```bash $ gdb -q python (gdb) break sum.py:13 # Assumes the kernel is in file sum.py, at line 13