From 655aa8bcbf9e8c3b70cd144ffe54178b09e81c99 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Mon, 6 May 2024 16:13:33 -0500 Subject: [PATCH 1/3] Changes to gdb unit tests to enable them on Intel Max GPU - Increase the timeout value for pyexpect as spawning gdb on discrete GPU can take more time than on CPU. - Slight modifications on the regex patterns to be matched on hitting a breakpoint. The change was done based on what was observed on Intel Max GPU and gdb-oneapi. --- numba_dpex/tests/debugging/gdb.py | 8 ++++---- numba_dpex/tests/debugging/test_breakpoints.py | 2 +- numba_dpex/tests/debugging/test_info.py | 8 ++++---- numba_dpex/tests/debugging/test_stepping.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/numba_dpex/tests/debugging/gdb.py b/numba_dpex/tests/debugging/gdb.py index f47fad117b..b743507c15 100644 --- a/numba_dpex/tests/debugging/gdb.py +++ b/numba_dpex/tests/debugging/gdb.py @@ -33,8 +33,8 @@ r"layout=[A-Z],\s+" r"address_space=[0-4],\s+" r"usm_type=[a-z]+,\s+" - r"device=[a-z:0-9]+,\s+" - r"sycl_queue=[A-Za-z:0-9 ]+\)" + r"device=[a-z\_:0-9]+,\s+" + r"sycl_queue=[A-Za-z:0-9\s\_:]+\)" ) @@ -52,7 +52,7 @@ def spawn(self): env["NUMBA_DEBUGINFO"] = "1" self.child = pexpect.spawn( - "gdb-oneapi -q python", env=env, encoding="utf-8" + "gdb-oneapi -q python", env=env, encoding="utf-8", timeout=60 ) if config.TESTING_LOG_DEBUGGING: self.child.logfile = sys.stdout @@ -109,7 +109,7 @@ def expect_eol(self): self.child.expect(r"[^\n]*\n") def expect_hit_breakpoint(self, expected_location=None): - expect = r"Thread [0-9A-Za-z \"]+ hit Breakpoint [0-9\.]+" + expect = r"Breakpoint [0-9\.]+" if expected_location is not None: # function name + args could be long, so we have to assume that # the message may be splitted in multiple lines. It potentially can diff --git a/numba_dpex/tests/debugging/test_breakpoints.py b/numba_dpex/tests/debugging/test_breakpoints.py index 701d4b823b..f76411b100 100644 --- a/numba_dpex/tests/debugging/test_breakpoints.py +++ b/numba_dpex/tests/debugging/test_breakpoints.py @@ -58,7 +58,7 @@ def test_device_func_breakpoint( app.breakpoint(breakpoint, condition=condition) app.run(f"side-by-side.py --api={api}") - app.expect_hit_breakpoint("side-by-side.py:15") + app.expect_hit_breakpoint(expected_location="side-by-side.py:15") if exp_var is not None: app.print(exp_var, expected=exp_val) diff --git a/numba_dpex/tests/debugging/test_info.py b/numba_dpex/tests/debugging/test_info.py index c9f75dd102..693f487fcb 100644 --- a/numba_dpex/tests/debugging/test_info.py +++ b/numba_dpex/tests/debugging/test_info.py @@ -78,7 +78,7 @@ def test_info_args( ): app.breakpoint(breakpoint) app.run(script) - app.expect_hit_breakpoint(breakpoint) + app.expect_hit_breakpoint(expected_location=breakpoint) app.expect(expected_line, with_eol=True) if kind == "info": @@ -99,7 +99,7 @@ def test_info_args( def test_info_functions(app): app.breakpoint("simple_sum.py:12") app.run("simple_sum.py") - app.expect_hit_breakpoint("simple_sum.py:12") + app.expect_hit_breakpoint(expected_location="simple_sum.py:12") app.expect(r"12\s+i = item.get_id\(0\)", with_eol=True) app.info_functions("data_parallel_sum") @@ -119,7 +119,7 @@ def test_print_array_element(app, api): app.breakpoint("side-by-side-2.py:17", condition="param_a == 5") app.run(f"side-by-side-2.py --api={api}") - app.expect_hit_breakpoint("side-by-side-2.py:17") + app.expect_hit_breakpoint(expected_location="side-by-side-2.py:17") # We can access only c_array, not python style array app.print("b.data[5]", 5) @@ -142,7 +142,7 @@ def test_print_array_element(app, api): def test_assignment_to_variable(app, api, assign): app.breakpoint("side-by-side-2.py:17", condition="param_a == 5") app.run(f"side-by-side-2.py --api={api}") - app.expect_hit_breakpoint("side-by-side-2.py:17") + app.expect_hit_breakpoint(expected_location="side-by-side-2.py:17") app.print("param_a", expected=5) if assign == "print": diff --git a/numba_dpex/tests/debugging/test_stepping.py b/numba_dpex/tests/debugging/test_stepping.py index 71fedcab83..3e802a1db0 100644 --- a/numba_dpex/tests/debugging/test_stepping.py +++ b/numba_dpex/tests/debugging/test_stepping.py @@ -21,7 +21,7 @@ def test_next(app: gdb): app.breakpoint("simple_dpex_func.py:18") app.run("simple_dpex_func.py") - app.expect_hit_breakpoint("simple_dpex_func.py:18") + app.expect_hit_breakpoint(expected_location="simple_dpex_func.py:18") app.expect(r"18\s+i = item.get_id\(0\)", with_eol=True) app.set_scheduler_lock() app.next() @@ -37,7 +37,7 @@ def test_next(app: gdb): def test_step(app: gdb): app.breakpoint("simple_dpex_func.py:19") app.run("simple_dpex_func.py") - app.expect_hit_breakpoint("simple_dpex_func.py:19") + app.expect_hit_breakpoint(expected_location="simple_dpex_func.py:19") app.expect( r"19\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)", with_eol=True, @@ -57,7 +57,7 @@ def test_step(app: gdb): def test_stepi(app: gdb, func: str): app.breakpoint("simple_dpex_func.py:19") app.run("simple_dpex_func.py") - app.expect_hit_breakpoint("simple_dpex_func.py:19") + app.expect_hit_breakpoint(expected_location="simple_dpex_func.py:19") app.expect( r"19\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)", with_eol=True, From 40a51c78a4f113eedd445cc29e3a2d6b7a8772e5 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Mon, 6 May 2024 16:18:42 -0500 Subject: [PATCH 2/3] Updates test case verifying codegen for intenum literal args. - Allows expected regex to match even when "nonnull" qualifier was not found on retval pointer argument of a function call. --- numba_dpex/tests/codegen/test_intenum_literal_codegen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numba_dpex/tests/codegen/test_intenum_literal_codegen.py b/numba_dpex/tests/codegen/test_intenum_literal_codegen.py index 5d875f37af..ef19eb2bed 100644 --- a/numba_dpex/tests/codegen/test_intenum_literal_codegen.py +++ b/numba_dpex/tests/codegen/test_intenum_literal_codegen.py @@ -47,7 +47,7 @@ def pass_flags_to_func(a): pattern = re.compile( r"call spir_func i32 @\_Z.*bitwise\_or" - r"\_flags.*\(i64\* nonnull %.*, i64 1, i64 2\)" + r"\_flags.*\(i64\*\s(\w+)?\s*%.*, i64 1, i64 2\)" ) assert re.search(pattern, llvm_ir_mod) is not None From ab45e5dd7520ef580a24fbede24210f2a3d409ee Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Mon, 6 May 2024 16:22:05 -0500 Subject: [PATCH 3/3] The SPV_INTEL_variable_lenght_array SPIRV ext. is needed on PVC. --- numba_dpex/kernel_api_impl/spirv/spirv_generator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/numba_dpex/kernel_api_impl/spirv/spirv_generator.py b/numba_dpex/kernel_api_impl/spirv/spirv_generator.py index c731a9c75d..192311f9e0 100644 --- a/numba_dpex/kernel_api_impl/spirv/spirv_generator.py +++ b/numba_dpex/kernel_api_impl/spirv/spirv_generator.py @@ -124,6 +124,7 @@ def finalize(self): "--spirv-ext=+SPV_EXT_shader_atomic_float_add", "--spirv-ext=+SPV_EXT_shader_atomic_float_min_max", "--spirv-ext=+SPV_INTEL_arbitrary_precision_integers", + "--spirv-ext=+SPV_INTEL_variable_length_array", ] for key in list(self.context.extra_compile_options.keys()): if key == LLVM_SPIRV_ARGS: