Skip to content

Commit 58a125c

Browse files
authored
Add more parfor tests (#179)
1 parent 57f7000 commit 58a125c

File tree

2 files changed

+139
-6
lines changed

2 files changed

+139
-6
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ jobs:
126126
export OCL_ICD_FILENAMES=libintelocl.so
127127
export SYCL_DEVICE_FILTER=opencl:cpu
128128
export NUMBA_DISABLE_PERFORMANCE_WARNINGS=1
129+
export DPCOMP_ENABLE_PARFOR_TESTS=1
129130
pytest -n1 -vv --capture=tee-sys
130131
displayName: 'Tests'
131132

numba_dpcomp/numba_dpcomp/mlir/tests/test_numba_parfor.py

Lines changed: 138 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import numpy as np
2020
import types as pytypes
2121

22+
from numba_dpcomp.mlir.settings import _readenv
2223
from numba_dpcomp import njit, jit, vectorize
2324

2425
from numba_dpcomp.mlir.passes import (
@@ -31,10 +32,23 @@
3132

3233

3334
def _gen_tests():
35+
if not _readenv("DPCOMP_ENABLE_PARFOR_TESTS", int, 0):
36+
return
37+
3438
testcases = [
3539
numba.tests.test_parfors.TestPrangeBasic,
3640
numba.tests.test_parfors.TestPrangeSpecific,
3741
numba.tests.test_parfors.TestParforsVectorizer,
42+
numba.tests.test_parfors.TestParforBasic,
43+
numba.tests.test_parfors.TestParforNumericalMisc,
44+
numba.tests.test_parfors.TestParforNumPy,
45+
numba.tests.test_parfors.TestParfors,
46+
numba.tests.test_parfors.TestParforsLeaks,
47+
numba.tests.test_parfors.TestParforsSlice,
48+
# numba.tests.test_parfors.TestParforsOptions,
49+
numba.tests.test_parfors.TestParforsBitMask,
50+
numba.tests.test_parfors.TestParforsMisc,
51+
# numba.tests.test_parfors.TestParforsDiagnostics,
3852
]
3953

4054
xfail_tests = {
@@ -71,21 +85,125 @@ def _gen_tests():
7185
"test_prange_two_instances_same_reduction_var",
7286
"test_prange_conflicting_reduction_ops",
7387
"test_ssa_false_reduction",
74-
"test_prange26",
7588
"test_prange_two_conditional_reductions",
7689
"test_argument_alias_recarray_field",
7790
"test_mutable_list_param",
7891
"test_signed_vs_unsigned_vec_asm",
7992
"test_unsigned_refusal_to_vectorize",
8093
"test_vectorizer_fastmath_asm",
94+
"test_kde_example",
95+
"test_prange27",
96+
"test_simple09",
97+
"test_simple01",
98+
"test_simple10",
99+
"test_kmeans",
100+
"test_simple14",
101+
"test_simple04",
102+
"test_ndarray_fill",
103+
"test_fuse_argmin_argmax_max_min",
104+
"test_max",
105+
"test_arange",
106+
"test_min",
107+
"test_pi",
108+
"test_simple20",
109+
"test_simple24",
110+
"test_0d_array",
111+
"test_argmin",
112+
"test_simple07",
113+
"test_ndarray_fill2d",
114+
"test_argmax",
115+
"test_simple02",
116+
"test_simple18",
117+
"test_linspace",
118+
"test_std",
119+
"test_reshape_with_neg_one",
120+
"test_mvdot",
121+
"test_array_tuple_concat",
122+
"test_namedtuple1",
123+
"test_0d_broadcast",
124+
"test_var",
125+
"test_reshape_with_too_many_neg_one",
126+
"test_namedtuple2",
127+
"test_simple19",
128+
"test_no_hoisting_with_member_function_call",
129+
"test_reduction_var_reuse",
130+
"test_parfor_dtype_type",
131+
"test_tuple3",
132+
"test_parfor_array_access3",
133+
"test_np_func_direct_import",
134+
"test_preparfor_canonicalize_kws",
135+
"test_parfor_array_access4",
136+
"test_tuple_concat_with_reverse_slice",
137+
"test_reduce",
138+
"test_two_d_array_reduction",
139+
"test_tuple_concat",
140+
"test_two_d_array_reduction_with_float_sizes",
141+
"test_reduction",
142+
"test_multiple_reduction_vars",
143+
"test_two_d_array_reduction_reuse",
144+
"test_parfor_slice21",
145+
"test_parfor_array_access_lower_slice",
146+
"test_size_assertion",
147+
"test_parfor_slice19",
148+
"test_parfor_slice23",
149+
"test_parfor_slice18",
150+
"test_parfor_slice20",
151+
"test_simple12",
152+
"test_parfor_slice2",
153+
"test_parfor_slice6",
154+
"test_parfor_slice22",
155+
"test_parfor_bitmask3",
156+
"test_simple13",
157+
"test_parfor_bitmask1",
158+
"test_parfor_bitmask4",
159+
"test_issue3169",
160+
"test_parfor_bitmask5",
161+
"test_issue3748",
162+
"test_parfor_bitmask6",
163+
"test_issue5001",
164+
"test_issue6774",
165+
"test_issue5167",
166+
"test_issue6095_numpy_max",
167+
"test_issue5065",
168+
"test_no_state_change_in_gufunc_lowering_on_error",
169+
"test_namedtuple3",
170+
"test_issue6102",
171+
"test_oversized_tuple_as_arg_to_kernel",
172+
"test_issue5942_2",
173+
"test_reshape_with_large_neg",
174+
"test_parfor_ufunc_typing",
175+
"test_issue_5098",
176+
"test_parfor_slice27",
177+
"test_ufunc_expr",
178+
"test_parfor_generate_fuse",
179+
"test_parfor_slice7",
180+
"test_parfor_bitmask2",
181+
"test_parfor_alias2",
182+
"test_one_d_array_reduction",
81183
}
82184

83185
skip_tests = {
84-
"test_kde_example",
85-
"test_prange27",
86186
"test_copy_global_for_parfor",
187+
"test_high_dimension1",
188+
"test_three_d_array_reduction",
189+
"test_prange26",
87190
}
88191

192+
def countParfors(test_func, args, **kws):
193+
pytest.xfail()
194+
195+
def countArrays(test_func, args, **kws):
196+
pytest.xfail()
197+
198+
def countArrayAllocs(test_func, args, **kws):
199+
pytest.xfail()
200+
201+
def countNonParforArrayAccesses(test_func, args, **kws):
202+
pytest.xfail()
203+
204+
def get_optimized_numba_ir(test_func, args, **kws):
205+
pytest.xfail()
206+
89207
def _wrap_test_class(test_base):
90208
class _Wrapper(test_base):
91209
def _gen_normal(self, func):
@@ -125,14 +243,20 @@ def get_gufunc_asm(self, func, schedule_type, *args, **kwargs):
125243

126244
def prange_tester(self, pyfunc, *args, **kwargs):
127245
patch_instance = kwargs.pop("patch_instance", None)
246+
247+
pyfunc = self.generate_prange_func(pyfunc, patch_instance)
248+
return self._check_impl(pyfunc, *args, **kwargs)
249+
250+
def check(self, pyfunc, *args, **kwargs):
251+
return self._check_impl(pyfunc, *args, **kwargs)
252+
253+
def _check_impl(self, pyfunc, *args, **kwargs):
128254
scheduler_type = kwargs.pop("scheduler_type", None)
129255
check_fastmath = kwargs.pop("check_fastmath", False)
130256
check_fastmath_result = kwargs.pop("check_fastmath_result", False)
131257
check_scheduling = kwargs.pop("check_scheduling", True)
132258
check_args_for_equality = kwargs.pop("check_arg_equality", None)
133-
assert not kwargs, "Unhandled kwargs: " + str(kwargs)
134-
135-
pyfunc = self.generate_prange_func(pyfunc, patch_instance)
259+
# assert not kwargs, "Unhandled kwargs: " + str(kwargs)
136260

137261
cfunc = self._gen_normal(pyfunc)
138262
cpfunc = self._gen_parallel(pyfunc)
@@ -206,6 +330,14 @@ def _gen_test_func(func):
206330
_replace_global(func, "njit", njit)
207331
_replace_global(func, "vectorize", vectorize)
208332

333+
_replace_global(func, "countParfors", countParfors)
334+
_replace_global(func, "countArrays", countArrays)
335+
_replace_global(func, "countArrayAllocs", countArrayAllocs)
336+
_replace_global(
337+
func, "countNonParforArrayAccesses", countNonParforArrayAccesses
338+
)
339+
_replace_global(func, "get_optimized_numba_ir", get_optimized_numba_ir)
340+
209341
def wrapper():
210342
return func()
211343

0 commit comments

Comments
 (0)