Skip to content

Commit 4b9aacf

Browse files
author
Diptorup Deb
committed
Remove filter string parameterization from tests.
1 parent 88f5cfb commit 4b9aacf

File tree

11 files changed

+61
-103
lines changed

11 files changed

+61
-103
lines changed

numba_dpex/tests/core/types/DpctlSyclQueue/test_queue_ref_attr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_queue_equality(queue1, queue2):
7272
cq1 = dpctl._sycl_queue_manager.get_device_cached_queue(d)
7373
cq2 = dpctl._sycl_queue_manager.get_device_cached_queue(d)
7474

75-
expected = cq1 == cq2
7675
actual = test_queue_equality(cq1, cq2)
76+
expected = cq1 == cq2
7777

7878
assert expected == actual

numba_dpex/tests/core/types/USMNdArray/test_array_creation_errors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import dpctl
2-
from numba.core.types.scalars import Float
32

43
from numba_dpex.core.types import USMNdArray
54

numba_dpex/tests/dpjit_tests/parfors/test_dpnp_bitwise_ops.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pytest
1010

1111
from numba_dpex import dpjit
12-
from numba_dpex.tests._helper import filter_strings
1312

1413
list_of_binary_ops = [
1514
"bitwise_and",
@@ -51,8 +50,7 @@ def input_arrays(request):
5150
return a, b
5251

5352

54-
@pytest.mark.parametrize("filter_str", filter_strings)
55-
def test_binary_ops(filter_str, binary_op, input_arrays):
53+
def test_binary_ops(binary_op, input_arrays):
5654
a, b = input_arrays
5755
binop = getattr(dpnp, binary_op)
5856
actual = dpnp.empty(shape=a.shape, dtype=a.dtype)
@@ -73,8 +71,7 @@ def f(a, b):
7371
)
7472

7573

76-
@pytest.mark.parametrize("filter_str", filter_strings)
77-
def test_unary_ops(filter_str, unary_op, input_arrays):
74+
def test_unary_ops(unary_op, input_arrays):
7875
a = input_arrays[0]
7976
uop = getattr(dpnp, unary_op)
8077
actual = np.empty(shape=a.shape, dtype=a.dtype)

numba_dpex/tests/dpjit_tests/parfors/test_dpnp_logic_ops.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pytest
1010

1111
from numba_dpex import dpjit
12-
from numba_dpex.tests._helper import filter_strings
1312

1413
""" Following cases, dpnp raises NotImplementedError"""
1514

@@ -61,8 +60,7 @@ def input_arrays(request):
6160

6261

6362
@pytest.mark.xfail
64-
@pytest.mark.parametrize("filter_str", filter_strings)
65-
def test_binary_ops(filter_str, binary_op, input_arrays):
63+
def test_binary_ops(binary_op, input_arrays):
6664
a, b = input_arrays
6765
binop = getattr(dpnp, binary_op)
6866
actual = dpnp.empty(shape=a.shape, dtype=a.dtype)
@@ -84,8 +82,7 @@ def f(a, b):
8482

8583

8684
@pytest.mark.xfail
87-
@pytest.mark.parametrize("filter_str", filter_strings)
88-
def test_unary_ops(filter_str, unary_op, input_arrays):
85+
def test_unary_ops(unary_op, input_arrays):
8986
a = input_arrays[0]
9087
uop = getattr(dpnp, unary_op)
9188
actual = dpnp.empty(shape=a.shape, dtype=a.dtype)

numba_dpex/tests/dpjit_tests/parfors/test_dpnp_transcedental_functions.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010

1111
from numba_dpex import dpjit
12-
from numba_dpex.tests._helper import filter_strings, is_gen12
12+
from numba_dpex.tests._helper import is_gen12
1313

1414
"""dpnp raise error on : mod, abs and remainder(float32)"""
1515
list_of_binary_ops = [
@@ -78,8 +78,7 @@ def input_arrays(request):
7878
return a, b
7979

8080

81-
@pytest.mark.parametrize("filter_str", filter_strings)
82-
def test_binary_ops(filter_str, binary_op, input_arrays):
81+
def test_binary_ops(binary_op, input_arrays):
8382
a, b = input_arrays
8483
binop = getattr(dpnp, binary_op)
8584
actual = dpnp.empty(shape=a.shape, dtype=a.dtype)
@@ -101,10 +100,10 @@ def f(a, b):
101100
)
102101

103102

104-
@pytest.mark.parametrize("filter_str", filter_strings)
105-
def test_unary_ops(filter_str, unary_op, input_arrays):
103+
def test_unary_ops(unary_op, input_arrays):
106104
skip_ops = ["abs", "sign", "log", "log2", "log10", "expm1"]
107-
if unary_op in skip_ops and is_gen12(filter_str):
105+
device = dpctl.SyclDevice()
106+
if unary_op in skip_ops and is_gen12(device.filter_string):
108107
pytest.skip()
109108

110109
a = input_arrays[0]

numba_dpex/tests/dpjit_tests/parfors/test_dpnp_trigonometric_functions.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,7 @@
99
import pytest
1010

1111
from numba_dpex import dpjit
12-
from numba_dpex.tests._helper import filter_strings, is_gen12
13-
14-
list_of_filter_strs = [
15-
"opencl:gpu:0",
16-
"level_zero:gpu:0",
17-
"opencl:cpu:0",
18-
]
19-
20-
21-
@pytest.fixture(params=list_of_filter_strs)
22-
def filter_str(request):
23-
return request.param
24-
12+
from numba_dpex.tests._helper import is_gen12
2513

2614
list_of_trig_ops = [
2715
"sin",
@@ -70,8 +58,8 @@ def input_arrays(request):
7058
return a, b
7159

7260

73-
@pytest.mark.parametrize("filter_str", filter_strings)
74-
def test_trigonometric_fn(filter_str, trig_op, input_arrays):
61+
def test_trigonometric_fn(trig_op, input_arrays):
62+
filter_str = dpctl.SyclDevice().filter_string
7563
# FIXME: Why does archcosh fail on Gen12 discrete graphics card?
7664
if trig_op == "arccosh" and is_gen12(filter_str):
7765
pytest.skip()

numba_dpex/tests/kernel_tests/test_atomic_op.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numba_dpex as dpex
1010
from numba_dpex import config
1111
from numba_dpex.core.descriptor import dpex_kernel_target
12-
from numba_dpex.tests._helper import filter_strings, override_config
12+
from numba_dpex.tests._helper import override_config
1313

1414
global_size = 100
1515
N = global_size
@@ -38,8 +38,8 @@ def fdtype(request):
3838

3939
@pytest.fixture(params=list_of_i_dtypes + list_of_f_dtypes)
4040
def input_arrays(request):
41-
def _inpute_arrays(filter_str):
42-
a = np.array([0], request.param, device=filter_str)
41+
def _inpute_arrays():
42+
a = np.array([0], request.param)
4343
return a, request.param
4444

4545
return _inpute_arrays
@@ -72,10 +72,9 @@ def f(a):
7272
)
7373

7474

75-
@pytest.mark.parametrize("filter_str", filter_strings)
7675
@skip_no_atomic_support
77-
def test_kernel_atomic_simple(filter_str, input_arrays, kernel_result_pair):
78-
a, dtype = input_arrays(filter_str)
76+
def test_kernel_atomic_simple(input_arrays, kernel_result_pair):
77+
a, dtype = input_arrays()
7978
kernel, expected = kernel_result_pair
8079
kernel[dpex.Range(global_size)](a)
8180
assert a[0] == expected
@@ -112,10 +111,9 @@ def f(a):
112111
return f
113112

114113

115-
@pytest.mark.parametrize("filter_str", filter_strings)
116114
@skip_no_atomic_support
117-
def test_kernel_atomic_local(filter_str, input_arrays, return_list_of_op):
118-
a, dtype = input_arrays(filter_str)
115+
def test_kernel_atomic_local(input_arrays, return_list_of_op):
116+
a, dtype = input_arrays()
119117
op_type, expected = return_list_of_op
120118
f = get_func_local(op_type, dtype)
121119
kernel = dpex.kernel(f)
@@ -150,15 +148,14 @@ def f(a):
150148
return dpex.kernel(f)
151149

152150

153-
@pytest.mark.parametrize("filter_str", filter_strings)
154151
@skip_no_atomic_support
155152
def test_kernel_atomic_multi_dim(
156-
filter_str, return_list_of_op, return_list_of_dim, return_dtype
153+
return_list_of_op, return_list_of_dim, return_dtype
157154
):
158155
op_type, expected = return_list_of_op
159156
dim = return_list_of_dim
160157
kernel = get_kernel_multi_dim(op_type, len(dim))
161-
a = np.zeros(dim, dtype=return_dtype, device=filter_str)
158+
a = np.zeros(dim, dtype=return_dtype)
162159
kernel[dpex.Range(global_size)](a)
163160
assert a[0] == expected
164161

numba_dpex/tests/kernel_tests/test_barrier.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
import numba_dpex as dpex
1111
from numba_dpex import float32, usm_ndarray, void
12-
from numba_dpex.tests._helper import filter_strings
1312

1413
f32arrty = usm_ndarray(ndim=1, dtype=float32, layout="C")
1514

1615

17-
@pytest.mark.parametrize("filter_str", filter_strings)
18-
def test_proper_lowering(filter_str):
16+
def test_proper_lowering():
1917
# This will trigger eager compilation
2018
@dpex.kernel(void(f32arrty))
2119
def twice(A):
@@ -35,8 +33,7 @@ def twice(A):
3533
np.testing.assert_allclose(orig * 2, after)
3634

3735

38-
@pytest.mark.parametrize("filter_str", filter_strings)
39-
def test_no_arg_barrier_support(filter_str):
36+
def test_no_arg_barrier_support():
4037
@dpex.kernel(void(f32arrty))
4138
def twice(A):
4239
i = dpex.get_global_id(0)
@@ -54,8 +51,7 @@ def twice(A):
5451
np.testing.assert_allclose(orig * 2, after)
5552

5653

57-
@pytest.mark.parametrize("filter_str", filter_strings)
58-
def test_local_memory(filter_str):
54+
def test_local_memory():
5955
blocksize = 10
6056

6157
@dpex.kernel(void(f32arrty))

numba_dpex/tests/kernel_tests/test_caching.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import numba_dpex as dpex
1212
from numba_dpex.core.caching import LRUCache
1313
from numba_dpex.core.kernel_interface.dispatcher import JitKernel
14-
from numba_dpex.tests._helper import filter_strings
1514

1615

1716
def test_LRUcache_operations():
@@ -106,17 +105,14 @@ def test_LRUcache_operations():
106105
assert str(cache.evicted) == "{5: 'f', 7: 'h', 8: 'i', 9: 'j', 2: 'c'}"
107106

108107

109-
@pytest.mark.parametrize("filter_str", filter_strings)
110-
def test_caching_hit_counts(filter_str):
108+
def test_caching_hit_counts():
111109
"""Tests the correct number of cache hits.
110+
112111
If a Dispatcher is invoked 10 times and if the caching is enabled,
113112
then the total number of cache hits will be 9. Given the fact that
114113
the first time the kernel will be compiled and it will be loaded
115114
off the cache for the next time on.
116115
117-
Args:
118-
filter_str (str): The device name coming from filter_strings in
119-
._helper.py
120116
"""
121117

122118
def data_parallel_sum(x, y, z):
@@ -126,9 +122,9 @@ def data_parallel_sum(x, y, z):
126122
i = dpex.get_global_id(0)
127123
z[i] = x[i] + y[i]
128124

129-
a = dpt.arange(0, 100, device=filter_str)
130-
b = dpt.arange(0, 100, device=filter_str)
131-
c = dpt.zeros_like(a, device=filter_str)
125+
a = dpt.arange(0, 100)
126+
b = dpt.arange(0, 100)
127+
c = dpt.zeros_like(a)
132128

133129
expected = dpt.asnumpy(a) + dpt.asnumpy(b)
134130

numba_dpex/tests/test_array_utils.py

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import dpctl.memory as dpctl_mem
99
import dpctl.tensor as dpt
1010
import numpy as np
11-
import pytest
1211

13-
from numba_dpex.tests._helper import filter_strings
1412
from numba_dpex.utils import (
1513
as_usm_obj,
1614
copy_to_numpy_from_usm_obj,
@@ -20,38 +18,34 @@
2018
from . import _helper
2119

2220

23-
@pytest.mark.parametrize("filter_str", filter_strings)
24-
def test_has_usm_memory(filter_str):
21+
def test_has_usm_memory():
2522
a = np.ones(1023, dtype=np.float32)
23+
q = dpctl.SyclQueue()
24+
# test usm_ndarray
25+
da = dpt.usm_ndarray(a.shape, dtype=a.dtype, buffer="shared")
26+
usm_mem = has_usm_memory(da)
27+
assert da.usm_data._pointer == usm_mem._pointer
2628

27-
with dpctl.device_context(filter_str) as q:
28-
# test usm_ndarray
29-
da = dpt.usm_ndarray(a.shape, dtype=a.dtype, buffer="shared")
30-
usm_mem = has_usm_memory(da)
31-
assert da.usm_data._pointer == usm_mem._pointer
29+
# test usm allocated numpy.ndarray
30+
buf = dpctl_mem.MemoryUSMShared(a.size * a.dtype.itemsize, queue=q)
31+
ary_buf = np.ndarray(a.shape, buffer=buf, dtype=a.dtype)
32+
usm_mem = has_usm_memory(ary_buf)
33+
assert buf._pointer == usm_mem._pointer
3234

33-
# test usm allocated numpy.ndarray
34-
buf = dpctl_mem.MemoryUSMShared(a.size * a.dtype.itemsize, queue=q)
35-
ary_buf = np.ndarray(a.shape, buffer=buf, dtype=a.dtype)
36-
usm_mem = has_usm_memory(ary_buf)
37-
assert buf._pointer == usm_mem._pointer
35+
usm_mem = has_usm_memory(a)
36+
assert usm_mem is None
3837

39-
usm_mem = has_usm_memory(a)
40-
assert usm_mem is None
4138

42-
43-
@pytest.mark.parametrize("filter_str", filter_strings)
44-
def test_as_usm_obj(filter_str):
39+
def test_as_usm_obj():
4540
a = np.ones(1023, dtype=np.float32)
4641
b = a * 3
47-
48-
with dpctl.device_context(filter_str) as queue:
49-
a_copy = np.empty_like(a)
50-
usm_mem = as_usm_obj(a, queue=queue)
51-
copy_to_numpy_from_usm_obj(usm_mem, a_copy)
52-
assert np.all(a == a_copy)
53-
54-
b_copy = np.empty_like(b)
55-
usm_mem = as_usm_obj(b, queue=queue, copy=False)
56-
copy_to_numpy_from_usm_obj(usm_mem, b_copy)
57-
assert np.any(np.not_equal(b, b_copy))
42+
queue = dpctl.SyclQueue()
43+
a_copy = np.empty_like(a)
44+
usm_mem = as_usm_obj(a, queue=queue)
45+
copy_to_numpy_from_usm_obj(usm_mem, a_copy)
46+
assert np.all(a == a_copy)
47+
48+
b_copy = np.empty_like(b)
49+
usm_mem = as_usm_obj(b, queue=queue, copy=False)
50+
copy_to_numpy_from_usm_obj(usm_mem, b_copy)
51+
assert np.any(np.not_equal(b, b_copy))

0 commit comments

Comments
 (0)