Skip to content

Commit

Permalink
Changes to gdb unit tests to enable them on Intel Max GPU
Browse files Browse the repository at this point in the history
    - 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.
  • Loading branch information
diptorupd committed May 7, 2024
1 parent 84acdea commit 655aa8b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions numba_dpex/tests/debugging/gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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\_:]+\)"
)


Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion numba_dpex/tests/debugging/test_breakpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions numba_dpex/tests/debugging/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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":
Expand Down
6 changes: 3 additions & 3 deletions numba_dpex/tests/debugging/test_stepping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 655aa8b

Please sign in to comment.