Skip to content

Commit ca48a49

Browse files
Merge move_tensor_tests into move_compute_follows_data_utils
2 parents 06cce1b + 2897e05 commit ca48a49

File tree

9 files changed

+102
-13
lines changed

9 files changed

+102
-13
lines changed

.github/workflows/check-onemath.yaml

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
os: [ubuntu-22.04] # windows-2022 - no DFT support for Windows in oneMKL
7575

7676
runs-on: ${{ matrix.os }}
77-
timeout-minutes: 60
77+
timeout-minutes: 120
7878

7979
defaults:
8080
run:
@@ -133,6 +133,14 @@ jobs:
133133
if: env.rerun-tests-on-failure != 'true'
134134
run: |
135135
python -m pytest -ra --pyargs dpnp.tests
136+
env:
137+
SKIP_TENSOR_TESTS: 1
138+
SYCL_CACHE_PERSISTENT: 1
139+
140+
- name: Run tensor tests
141+
if: env.rerun-tests-on-failure != 'true'
142+
run: |
143+
python -m pytest -ra --pyargs dpnp.tests.tensor
136144
env:
137145
SYCL_CACHE_PERSISTENT: 1
138146

@@ -150,6 +158,24 @@ jobs:
150158
mamba activate ${{ env.test-env-name }}
151159
152160
python -m pytest -ra --pyargs dpnp.tests
161+
env:
162+
SKIP_TENSOR_TESTS: 1
163+
SYCL_CACHE_PERSISTENT: 1
164+
165+
- name: ReRun tensor tests on Linux
166+
if: env.rerun-tests-on-failure == 'true'
167+
id: run_tensor_tests
168+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
169+
with:
170+
timeout_minutes: ${{ env.rerun-tests-timeout }}
171+
max_attempts: ${{ env.rerun-tests-max-attempts }}
172+
retry_on: any
173+
command: |
174+
. $CONDA/etc/profile.d/conda.sh
175+
. $CONDA/etc/profile.d/mamba.sh
176+
mamba activate ${{ env.test-env-name }}
177+
178+
python -m pytest -ra --pyargs dpnp.tests.tensor
153179
env:
154180
SYCL_CACHE_PERSISTENT: 1
155181

@@ -239,6 +265,14 @@ jobs:
239265
if: env.rerun-tests-on-failure != 'true'
240266
run: |
241267
python -m pytest -ra --pyargs dpnp.tests
268+
env:
269+
SKIP_TENSOR_TESTS: 1
270+
SYCL_CACHE_PERSISTENT: 1
271+
272+
- name: Run tensor tests
273+
if: env.rerun-tests-on-failure != 'true'
274+
run: |
275+
python -m pytest -ra --pyargs dpnp.tests.tensor
242276
env:
243277
SYCL_CACHE_PERSISTENT: 1
244278

@@ -256,5 +290,23 @@ jobs:
256290
mamba activate ${{ env.test-env-name }}
257291
258292
python -m pytest -ra --pyargs dpnp.tests
293+
env:
294+
SKIP_TENSOR_TESTS: 1
295+
SYCL_CACHE_PERSISTENT: 1
296+
297+
- name: ReRun tensor tests on Linux
298+
if: env.rerun-tests-on-failure == 'true'
299+
id: run_tensor_tests_branch
300+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
301+
with:
302+
timeout_minutes: ${{ env.rerun-tests-timeout }}
303+
max_attempts: ${{ env.rerun-tests-max-attempts }}
304+
retry_on: any
305+
command: |
306+
. $CONDA/etc/profile.d/conda.sh
307+
. $CONDA/etc/profile.d/mamba.sh
308+
mamba activate ${{ env.test-env-name }}
309+
310+
python -m pytest -ra --pyargs dpnp.tests.tensor
259311
env:
260312
SYCL_CACHE_PERSISTENT: 1

.github/workflows/conda-package.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,12 @@ jobs:
220220
- name: Run tests
221221
if: env.rerun-tests-on-failure != 'true'
222222
run: |
223+
export SKIP_TENSOR_TESTS=1
223224
if [[ "${{ matrix.python }}" == "${{ env.python-ver-test-all-dtypes }}" ]]; then
224225
export DPNP_TEST_ALL_INT_TYPES=1
225-
python -m pytest -ra --ignore=dpnp/tests/tensor --pyargs ${{ env.package-name }}.tests
226+
python -m pytest -ra --pyargs ${{ env.package-name }}.tests
226227
else
227-
python -m pytest -n auto -ra --ignore=dpnp/tests/tensor --pyargs ${{ env.package-name }}.tests
228+
python -m pytest -n auto -ra --pyargs ${{ env.package-name }}.tests
228229
fi
229230
230231
- name: Run tests
@@ -239,12 +240,13 @@ jobs:
239240
. $CONDA/etc/profile.d/conda.sh
240241
. $CONDA/etc/profile.d/mamba.sh
241242
mamba activate ${{ env.test-env-name }}
243+
export SKIP_TENSOR_TESTS=1
242244
243245
if [[ "${{ matrix.python }}" == "${{ env.python-ver-test-all-dtypes }}" ]]; then
244246
export DPNP_TEST_ALL_INT_TYPES=1
245-
python -m pytest -ra --ignore=dpnp/tests/tensor --pyargs ${{ env.package-name }}.tests
247+
python -m pytest -ra --pyargs ${{ env.package-name }}.tests
246248
else
247-
python -m pytest -n auto -ra --ignore=dpnp/tests/tensor --pyargs ${{ env.package-name }}.tests
249+
python -m pytest -n auto -ra --pyargs ${{ env.package-name }}.tests
248250
fi
249251
250252
- name: Run tensor tests
@@ -402,11 +404,12 @@ jobs:
402404
if: env.rerun-tests-on-failure != 'true'
403405
shell: pwsh
404406
run: |
407+
$env:SKIP_TENSOR_TESTS=1
405408
if (${{ matrix.python }} -eq ${{ env.python-ver-test-all-dtypes }}) {
406409
$env:DPNP_TEST_ALL_INT_TYPES=1
407-
python -m pytest -ra --ignore=dpnp/tests/tensor --pyargs ${{ env.package-name }}.tests
410+
python -m pytest -ra --pyargs ${{ env.package-name }}.tests
408411
} else {
409-
python -m pytest -n auto -ra --ignore=dpnp/tests/tensor --pyargs ${{ env.package-name }}.tests
412+
python -m pytest -n auto -ra --pyargs ${{ env.package-name }}.tests
410413
}
411414
412415
- name: Run tests
@@ -419,11 +422,12 @@ jobs:
419422
retry_on: any
420423
shell: pwsh
421424
command: |
425+
$env:SKIP_TENSOR_TESTS=1
422426
if ( ${{ matrix.python }} -eq ${{ env.python-ver-test-all-dtypes }} ) {
423427
$env:DPNP_TEST_ALL_INT_TYPES=1
424-
python -m pytest -ra --ignore=dpnp/tests/tensor --pyargs ${{ env.package-name }}.tests
428+
python -m pytest -ra --pyargs ${{ env.package-name }}.tests
425429
} else {
426-
python -m pytest -n auto -ra --ignore=dpnp/tests/tensor --pyargs ${{ env.package-name }}.tests
430+
python -m pytest -n auto -ra --pyargs ${{ env.package-name }}.tests
427431
}
428432
429433
- name: Run tensor tests

.github/workflows/generate_coverage.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ jobs:
130130
conda activate coverage
131131
[ -f /opt/intel/oneapi/setvars.sh ] && source /opt/intel/oneapi/setvars.sh
132132
git clean -fxd
133+
export SKIP_TENSOR_TESTS=1
133134
python scripts/gen_coverage.py
134135
135136
- name: Total number of coverage attempts

dpnp/tensor/CMakeLists.txt

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

3030
find_package(Python COMPONENTS Development.Module)
3131

32+
# Tensor-specific flags
33+
34+
# dpctl doesn't add -fsycl globally
35+
# only to pybind11 module sources via add_sycl_to_target()
36+
string(REPLACE "-fsycl " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
37+
38+
# Use LLD linker (dpctl sets this at root level)
39+
if(UNIX)
40+
add_link_options("-fuse-ld=lld")
41+
endif()
42+
3243
# Remove global coverage flags for tensor
3344
# use link-time only approach like dpctl
3445
if(DPNP_GENERATE_COVERAGE)
@@ -55,6 +66,7 @@ if(
5566
endif()
5667
endif()
5768

69+
# Match dpctl warning flags
5870
# Suppress unused parameter warnings
5971
add_compile_options(-Wno-unused-parameter)
6072

dpnp/tensor/_usmarray.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import numpy as np
3737
from dpctl._backend cimport DPCTLSyclUSMRef
3838
from dpctl._sycl_device_factory cimport _cached_default_device
3939

40-
import dpnp.tensor
40+
import dpnp
4141

4242
from ._data_types import bool as dpt_bool
4343
from ._device import Device

dpnp/tensor/libtensor/include/utils/sycl_utils.hpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,21 @@ T custom_inclusive_scan_over_group(GroupT &&wg,
283283
const bool in_range = (lane_id < n_aggregates);
284284
const bool in_bounds = in_range && (lane_id > 0 || large_wg);
285285

286-
T __scan_val = (in_bounds)
287-
? local_mem_acc[(offset + lane_id) * max_sgSize - 1]
288-
: identity;
286+
// Here is a bug where IGC incorrectly optimized the below code:
287+
// T __scan_val = (in_bounds)
288+
// ? local_mem_acc[(offset + lane_id) * max_sgSize - 1]
289+
// : identity;
290+
// That causes `__scan_val` is not initialized with `identity` value:
291+
// wgs = 256, max_sgSize = 16 => n_aggregates = 16
292+
// wi = 0: in_range = 1, in_bounds = 0 => __scan_val = identity
293+
// The w/s adds SYCL atomic fence, since the explicit memory fence
294+
// prevents reordering/elimination, while it will add slight overhead.
295+
T __scan_val = identity;
296+
sycl::atomic_fence(sycl::memory_order::relaxed,
297+
sycl::memory_scope::work_item);
298+
if (in_bounds) {
299+
__scan_val = local_mem_acc[(offset + lane_id) * max_sgSize - 1];
300+
}
289301
for (std::uint32_t step = 1; step < sgSize; step *= 2) {
290302
const bool advanced_lane = (lane_id >= step);
291303
const std::uint32_t src_lane_id =

dpnp/tests/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
float16_types = bool(os.getenv("DPNP_TEST_FLOAT_16", 0))
55
complex_types = bool(os.getenv("DPNP_TEST_COMPLEX_TYPES", 0))
66
bool_types = bool(os.getenv("DPNP_TEST_BOOL_TYPES", 0))
7+
skip_tensor_tests = bool(int(os.getenv("SKIP_TENSOR_TESTS", 0)))
78

89

910
infra_warnings_enable = bool(os.getenv("DPNP_INFRA_WARNINGS_ENABLE", 0))

dpnp/tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def pytest_configure(config):
9797
# Equivalent to norecursedirs = tests_perf
9898
config.addinivalue_line("norecursedirs", "tests_perf")
9999

100+
# Equivalent to norecursedirs = tests/tensor (conditional)
101+
if dtype_config.skip_tensor_tests:
102+
config.addinivalue_line("norecursedirs", "tests/tensor")
103+
100104
# Register pytest markers
101105
config.addinivalue_line(
102106
"markers", "slow: marks tests as slow (deselect with '-m \"not slow\"')"

dpnp/tests/test_ndarray.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ def test_print_dpnp_special_character(character):
490490
assert result == expected
491491

492492

493+
# TODO: repr formatting is inconsistent (scientific vs integer-like output)
494+
# This is a minor issue that does not depend on compiler flags
495+
@pytest.mark.skip(reason="Flaky: repr formatting is not stable")
493496
def test_print_dpnp_1d():
494497
dtype = dpnp.default_float_type()
495498
result = repr(dpnp.arange(10000, dtype=dtype))

0 commit comments

Comments
 (0)