Skip to content

Commit

Permalink
Fix gdb tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzEeKkAa committed Mar 22, 2024
1 parent d0ad17e commit c1b9071
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion numba_dpex/examples/debug/side-by-side.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def ndpx_func_driver(a, b, c):

@ndpx.kernel(debug=True)
def _kernel(item, a_in_kernel, b_in_kernel, c_in_kernel):
i = item.get_global_id(0)
i = item.get_id(0)
c_in_kernel[i] = ndpx_loop_body(a_in_kernel[i], b_in_kernel[i])


Expand Down
4 changes: 2 additions & 2 deletions numba_dpex/tests/debugging/test_breakpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@pytest.mark.parametrize(
"breakpoint",
[
"side-by-side.py:16",
"side-by-side.py:15",
"common_loop_body",
"side-by-side.py:common_loop_body",
],
Expand Down Expand Up @@ -63,7 +63,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:16")
app.expect_hit_breakpoint("side-by-side.py:15")
if exp_var is not None:
app.print(exp_var, expected=exp_val)

Expand Down
18 changes: 9 additions & 9 deletions numba_dpex/tests/debugging/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(
"simple_dpex_func.py:18",
"simple_dpex_func.py",
r"18\s+i = ndpx\.get_global_id\(0\)",
r"18\s+i = item\.get_id\(0\)",
[
(
"a_in_kernel",
Expand All @@ -47,18 +47,18 @@
],
),
(
"side-by-side.py:16",
"side-by-side.py:15",
"side-by-side.py --api=numba",
r"16\s+param_c = param_a \+ numba\.float32\(10\)",
r"15\s+param_c = param_a \+ numba\.float32\(10\)",
[
("param_a", r"[0-9]+", r"type = float32", r"type = float32"),
("param_b", r"[0-9]+", r"type = float32", r"type = float32"),
],
),
(
"side-by-side.py:16",
"side-by-side.py:15",
"side-by-side.py --api=numba-ndpx-kernel",
r"16\s+param_c = param_a \+ numba\.float32\(10\)",
r"15\s+param_c = param_a \+ numba\.float32\(10\)",
[
("param_a", r"[0-9]+", r"type = float32", r"type = float32"),
("param_b", r"[0-9]+", r"type = float32", r"type = float32"),
Expand Down Expand Up @@ -100,7 +100,7 @@ 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(r"12\s+i = ndpx.get_global_id\(0\)", with_eol=True)
app.expect(r"12\s+i = item.get_id\(0\)", with_eol=True)

app.info_functions("data_parallel_sum")

Expand All @@ -117,7 +117,7 @@ def test_info_functions(app):
def test_print_array_element(app, api):
"""Test access to array elements"""

app.breakpoint("side-by-side-2.py:17 if param_a == 5")
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")

Expand All @@ -140,9 +140,9 @@ def test_print_array_element(app, api):
],
)
def test_assignment_to_variable(app, api, assign):
app.breakpoint("side-by-side-2.py:18", condition="param_a == 5")
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:18")
app.expect_hit_breakpoint("side-by-side-2.py:17")

app.print("param_a", expected=5)
if assign == "print":
Expand Down
15 changes: 9 additions & 6 deletions numba_dpex/tests/debugging/test_stepping.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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(r"18\s+i = ndpx.get_global_id\(0\)", with_eol=True)
app.expect(r"18\s+i = item.get_id\(0\)", with_eol=True)
app.set_scheduler_lock()
app.next()
app.expect(
Expand All @@ -35,19 +35,22 @@ def test_next(app: gdb):


def test_step(app: gdb):
app.breakpoint("simple_dpex_func.py:18")
app.breakpoint("simple_dpex_func.py:19")
app.run("simple_dpex_func.py")
app.expect_hit_breakpoint("simple_dpex_func.py:18")
app.expect(r"18\s+i = ndpx.get_global_id\(0\)", with_eol=True)
app.set_scheduler_lock()
app.step()
app.expect_hit_breakpoint("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,
)
app.set_scheduler_lock()
app.step()
app.expect(r"__main__::func_sum.* at simple_dpex_func.py:12", with_eol=True)
app.expect(r"12\s+result = a_in_func \+ b_in_func", with_eol=True)
app.step()
app.expect(
r"13\s+return result",
with_eol=True,
)


@pytest.mark.parametrize("func", ["stepi", "nexti"])
Expand Down

0 comments on commit c1b9071

Please sign in to comment.