Skip to content

Commit 33bbd1c

Browse files
roxx30198rohan11235813
authored andcommitted
Corrected gdb tests
1 parent a92e9b3 commit 33bbd1c

File tree

10 files changed

+236
-143
lines changed

10 files changed

+236
-143
lines changed

numba_dpex/examples/debug/side-by-side-2.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import argparse
66

77
import dpctl
8+
import dpnp
89
import numba
910
import numpy as np
1011

@@ -24,23 +25,31 @@ def scenario(api):
2425
print("Using API:", api)
2526

2627
global_size = 10
27-
a, b, c = arguments(global_size)
2828

2929
if api == "numba-ndpx-kernel":
30+
a, b, c = ndpx_arguments(global_size)
3031
ndpx_func_driver(a, b, c)
3132
else:
33+
a, b, c = numba_arguments(global_size)
3234
numba_func_driver(a, b, c)
3335

3436
print(a, b, c, sep="\n")
3537

3638

37-
def arguments(N, dtype=np.float32):
39+
def numba_arguments(N, dtype=np.float32):
3840
a = np.arange(N, dtype=dtype)
3941
b = np.arange(N, dtype=dtype)
4042
c = np.empty_like(a)
4143
return a, b, c
4244

4345

46+
def ndpx_arguments(N, dtype=dpnp.float32):
47+
a = dpnp.arange(N, dtype=dtype)
48+
b = dpnp.arange(N, dtype=dtype)
49+
c = dpnp.empty_like(a)
50+
return a, b, c
51+
52+
4453
@numba.njit(debug=True)
4554
def numba_func_driver(a, b, c):
4655
for i in range(len(c)):

numba_dpex/examples/debug/side-by-side.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
import argparse
66

77
import dpctl
8+
import dpnp
89
import numba
910
import numpy as np
1011

1112
import numba_dpex as ndpx
1213

1314

1415
def common_loop_body(param_a, param_b):
15-
param_c = param_a + 10 # Set breakpoint here
16-
param_d = param_b * 0.5
16+
param_c = param_a + np.float32(10) # Set breakpoint here
17+
param_d = param_b * np.float32(0.5)
1718
result = param_c + param_d
1819
return result
1920

@@ -22,23 +23,31 @@ def scenario(api):
2223
print("Using API:", api)
2324

2425
global_size = 10
25-
a, b, c = arguments(global_size)
2626

2727
if api == "numba-ndpx-kernel":
28+
a, b, c = ndpx_arguments(global_size)
2829
ndpx_func_driver(a, b, c)
2930
else:
31+
a, b, c = numba_arguments(global_size)
3032
numba_func_driver(a, b, c)
3133

3234
print(a, b, c, sep="\n")
3335

3436

35-
def arguments(N, dtype=np.float32):
37+
def numba_arguments(N, dtype=np.float32):
3638
a = np.arange(N, dtype=dtype)
3739
b = np.arange(N, dtype=dtype)
3840
c = np.empty_like(a)
3941
return a, b, c
4042

4143

44+
def ndpx_arguments(N, dtype=dpnp.float32):
45+
a = dpnp.arange(N, dtype=dtype)
46+
b = dpnp.arange(N, dtype=dtype)
47+
c = dpnp.empty_like(a)
48+
return a, b, c
49+
50+
4251
@numba.njit(debug=True)
4352
def numba_func_driver(a, b, c):
4453
for i in range(len(c)):

numba_dpex/tests/debugging/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def setup_breakpoint(
5656
script, expected_location.split(":")[-1]
5757
)
5858

59-
app.breakpoint(breakpoint)
59+
app.breakpoint(expected_location)
6060
app.run(script)
6161

6262
app.child.expect(rf"Thread .* hit Breakpoint .* at {expected_location}")

numba_dpex/tests/debugging/gdb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ def step(self):
9595
def stepi(self):
9696
self._command("stepi")
9797

98+
def set_scheduler_lock(self):
99+
self._command("set scheduler-locking step")
100+
98101
@staticmethod
99102
def script_path(script):
100103
return script_path(script)

numba_dpex/tests/debugging/test_backtraces.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,17 @@
1717
pytestmark = skip_no_gdb
1818

1919

20-
@pytest.mark.xfail # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
2120
def test_backtrace(app):
2221
"""Simple test for backtrace.
2322
2423
commands/backtrace
2524
"""
2625
setup_breakpoint(
2726
app,
28-
"simple_dpex_func.py:13",
29-
expected_line=r"13\s+result = a_in_func \+ b_in_func",
27+
"simple_dpex_func.py:12",
28+
expected_line=r"12\s+result = a_in_func \+ b_in_func",
3029
)
3130

3231
app.backtrace()
3332

34-
app.child.expect(r"#0.*__main__::func_sum .* at simple_dpex_func.py:13")
35-
36-
37-
# app.child.expect(r"#1.*__main__::kernel_sum .* at simple_dpex_func.py:20")
33+
app.child.expect(r"#0.*__main__::func_sum.* at simple_dpex_func.py:12")

numba_dpex/tests/debugging/test_breakpoints.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929

3030
common_loop_body_native_function_name = {
3131
"numba": "common_loop_body",
32-
"numba-dpex-kernel": "common_loop_body",
32+
"numba-ndpx-kernel": "common_loop_body",
3333
}
3434

3535
breakpoint_api_cases = [
3636
(side_by_side_breakpoint, "numba"),
37-
(side_by_side_breakpoint, "numba-dpex-kernel"),
37+
(side_by_side_breakpoint, "numba-ndpx-kernel"),
3838
*((fn, api) for api, fn in common_loop_body_native_function_name.items()),
3939
*(
4040
(f"side-by-side.py:{fn}", api)
@@ -51,16 +51,16 @@ def test_breakpoint_with_condition_by_function_argument(app, breakpoint, api):
5151
Test that it is possible to set conditional breakpoint at the beginning
5252
of the function and use a function argument in the condition.
5353
54-
It is important that breakpoint by function name hits at the firts line in
54+
It is important that breakpoint by function name hits at the first line in
5555
the function body and not at the function definition line.
5656
5757
Test for https://github.com/numba/numba/issues/7415
5858
SAT-4449
5959
"""
60-
if api == "numba-dpex-kernel":
60+
if api == "numba-ndpx-kernel":
6161
pytest.xfail(
62-
"Wrong name for kernel api."
63-
) # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
62+
"Conditional breakpoints for numba-ndpx-kernel doesn't work." # TODO: https://github.com/IntelPython/numba-dpex/issues/1221
63+
)
6464

6565
variable_name = "param_a"
6666
variable_value = "3"
@@ -78,7 +78,6 @@ def test_breakpoint_with_condition_by_function_argument(app, breakpoint, api):
7878
app.child.expect(rf"\$1 = {variable_value}")
7979

8080

81-
@pytest.mark.xfail # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
8281
@pytest.mark.parametrize(
8382
"breakpoint, script",
8483
[
@@ -98,11 +97,16 @@ def test_breakpoint_common(app, breakpoint, script):
9897
setup_breakpoint(app, breakpoint, script=script)
9998

10099

100+
@pytest.mark.xfail # TODO: https://github.com/IntelPython/numba-dpex/issues/1221
101101
@pytest.mark.parametrize(
102102
"breakpoint, variable_name, variable_value",
103103
[
104104
# commands/break_conditional # noqa: E800
105-
(f"{simple_sum_condition_breakpoint} if i == 1", "i", "1"),
105+
(
106+
f"{simple_sum_condition_breakpoint} --api=numba-ndpx-kernel if i == 1",
107+
"i",
108+
"1",
109+
),
106110
],
107111
)
108112
def test_breakpoint_with_condition_common(

numba_dpex/tests/debugging/test_common.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717

1818
@pytest.mark.parametrize(
1919
"file_name, mark, expected",
20-
[("side-by-side.py", "Set breakpoint here", "side-by-side.py:15")],
20+
[("side-by-side.py", "Set breakpoint here", "side-by-side.py:16")],
2121
)
2222
def test_breakpoint_by_mark(file_name, mark, expected):
2323
assert expected == breakpoint_by_mark(file_name, mark)
2424

2525

2626
@pytest.mark.parametrize(
2727
"file_name, function, expected",
28-
[("side-by-side.py", "common_loop_body", "side-by-side.py:15")],
28+
[("side-by-side.py", "common_loop_body", "side-by-side.py:16")],
2929
)
3030
def test_breakpoint_by_function(file_name, function, expected):
3131
assert expected == breakpoint_by_function(file_name, function)
@@ -50,12 +50,4 @@ def test_breakpoint_by_function(file_name, function, expected):
5050
def test_setup_breakpoint(
5151
app, breakpoint, script, expected_location, expected_line
5252
):
53-
if (
54-
breakpoint == "simple_sum.py:data_parallel_sum"
55-
or breakpoint == "data_parallel_sum"
56-
):
57-
pytest.xfail(
58-
"Expected failures for these files."
59-
) # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
60-
6153
setup_breakpoint(app, breakpoint, script, expected_location, expected_line)

0 commit comments

Comments
 (0)