diff --git a/dpnp/tests/AGENTS.md b/dpnp/tests/AGENTS.md index a0308e92aa6..06d221f07c1 100644 --- a/dpnp/tests/AGENTS.md +++ b/dpnp/tests/AGENTS.md @@ -21,7 +21,7 @@ - Compute-follows-data error tests expect `(ValueError, ExecutionPlacementError)`: dpnp raises either, depending on the helper. - A new function is added to the matching parametrized lists in `test_sycl_queue.py` and `test_usm_type.py` (`test_1in_1out`, `test_2in_1out`, ...); elementwise ones also to `test_strides.py`. - A test that may exceed the device's maximum allocation size skips on `USMAllocationError` (from `dpnp.exceptions`), not `MemoryError`, which it does not derive from. -- Markers are strict and only `slow` and `multi_gpu` are registered. Tests that need huge allocations are `@pytest.mark.slow`; they never run in CI by design. +- Markers are strict and only `slow`, `multi_gpu` and `single_device` are registered. `test_sycl_queue.py` skips a test when only the default device is available, unless it is marked `single_device` (it uses a second queue on the same device, or an in-order or profiling one). Tests that need huge allocations are `@pytest.mark.slow`; they never run in CI by design. - Skip lists are for device- or backend-specific failures only; use the full parametrized node ID relative to `dpnp/` (`tests/test_x.py::TestY::test_z[param]`; `conftest.py` matches it exactly, so a `dpnp/tests/...` entry matches nothing), and update or drop the entries of a test you rename or remove. - The conda CI jobs run the installed package (`--pyargs dpnp.tests`), so a new test directory or data file needs a matching glob in `package_data` in `setup.py`, or they silently skip it. The oneMath, coverage and open-source LLVM SYCL jobs test an editable or in-place tree and won't catch the omission. diff --git a/dpnp/tests/conftest.py b/dpnp/tests/conftest.py index c3c615dbc66..ca58cc83654 100644 --- a/dpnp/tests/conftest.py +++ b/dpnp/tests/conftest.py @@ -110,6 +110,11 @@ def pytest_configure(config): "markers", "multi_gpu: marks tests that require a specified number of GPUs", ) + config.addinivalue_line( + "markers", + "single_device: marks test_sycl_queue.py tests that also check " + "placement when only the default device is available", + ) # NumPy arccosh # Undefined behavior depends on the backend: diff --git a/dpnp/tests/test_mathematical.py b/dpnp/tests/test_mathematical.py index 31f929e26a2..0f42cbf6c92 100644 --- a/dpnp/tests/test_mathematical.py +++ b/dpnp/tests/test_mathematical.py @@ -1178,12 +1178,18 @@ def test_complex_fp(self, dtype_x, dtype_y): @pytest.mark.parametrize("dtype", ALL_DTYPES_NO_COMPLEX) @pytest.mark.parametrize( - "left, right", [[-40, 40], [dpnp.array(-40), dpnp.array(40)]] + "left, right", + [ + [-40, 40], + [dpnp.array(-40), dpnp.array(40)], + [-40, None], + [None, 40], + ], ) def test_left_right_args(self, dtype, left, right): x = numpy.array([0, 1, 2, 3, 4, 5, 6], dtype=dtype) - xp = numpy.array([0, 3, 6], dtype=dtype) - fp = numpy.array([0, 9, 18], dtype=dtype) + xp = numpy.array([1, 3, 5], dtype=dtype) + fp = numpy.array([3, 9, 15], dtype=dtype) ix = dpnp.array(x) ixp = dpnp.array(xp) diff --git a/dpnp/tests/test_sycl_queue.py b/dpnp/tests/test_sycl_queue.py index 2c14394765e..f7e6c65e40a 100644 --- a/dpnp/tests/test_sycl_queue.py +++ b/dpnp/tests/test_sycl_queue.py @@ -35,14 +35,24 @@ pass elif device.device_type.name not in list_of_device_type_str: pass - elif device.backend.name in "opencl" and device.is_gpu: - # due to reported crash on Windows: CMPLRLLVM-55640 + elif device.backend.name == "opencl" and device.is_gpu: + # Level Zero is the GPU backend users target pass else: valid_dev.append(device) dev_ids = [device.filter_string for device in valid_dev] +# inputs on the default device share its queue, so placement goes unchecked +only_default_dev = all(d == dpctl.select_default_device() for d in valid_dev) + + +@pytest.fixture(autouse=True) +def skip_if_only_default_device(request): + marked = request.node.get_closest_marker("single_device") is not None + if only_default_dev and not marked: + pytest.skip("needs a SYCL device other than the default one") + def assert_sycl_queue_equal(result, expected): assert result.backend == expected.backend @@ -654,6 +664,7 @@ def test_2in_broadcasting(func, data1, data2, device): assert_sycl_queue_equal(result.sycl_queue, x1.sycl_queue) +@pytest.mark.single_device @pytest.mark.parametrize( "func", [ @@ -694,6 +705,7 @@ def test_flat(device): assert_sycl_queue_equal(x.flat[y].sycl_queue, x.sycl_queue) +@pytest.mark.single_device @pytest.mark.parametrize("device", valid_dev, ids=dev_ids) def test_flat_setitem_diff_queue(device): a = dpnp.arange(6, device=device) @@ -843,6 +855,7 @@ def test_vecmat(device, shape1, shape2): assert_sycl_queue_equal(result_queue, b.sycl_queue) +@pytest.mark.single_device @pytest.mark.parametrize( "func, args, kwargs", [ @@ -887,6 +900,7 @@ def test_random(func, args, kwargs, device, usm_type): assert_sycl_queue_equal(res_array.sycl_queue, sycl_queue) +@pytest.mark.single_device @pytest.mark.parametrize( "func, args, kwargs", [ @@ -1039,6 +1053,7 @@ def test_basic(self, device_from, device_to): assert y.sycl_device == device_to assert (x.asnumpy() == y.asnumpy()).all() + @pytest.mark.single_device def test_to_queue(self): x = dpnp.full(100, 2, dtype=dpnp.int64) q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling") @@ -1047,6 +1062,7 @@ def test_to_queue(self): assert (x.asnumpy() == y.asnumpy()).all() assert_sycl_queue_equal(y.sycl_queue, q_prof) + @pytest.mark.single_device def test_stream(self): x = dpnp.full(100, 2, dtype=dpnp.int64) q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling") @@ -1062,6 +1078,7 @@ def test_stream(self): assert (x.asnumpy() == y.asnumpy()).all() assert_sycl_queue_equal(y.sycl_queue, q_prof) + @pytest.mark.single_device def test_stream_no_sync(self): x = dpnp.full(100, 2, dtype=dpnp.int64) q_prof = dpctl.SyclQueue(x.sycl_device, property="enable_profiling") @@ -1071,6 +1088,7 @@ def test_stream_no_sync(self): assert (x.asnumpy() == y.asnumpy()).all() assert_sycl_queue_equal(y.sycl_queue, q_prof) + @pytest.mark.single_device @pytest.mark.parametrize( "stream", [1, dict(), dpctl.SyclDevice()], @@ -1783,6 +1801,7 @@ def test_cho_solve(self, a_data, b_data, device): assert_sycl_queue_equal(result.sycl_queue, a.sycl_queue) assert_sycl_queue_equal(result.sycl_queue, b.sycl_queue) + @pytest.mark.single_device @pytest.mark.parametrize("c_shape", [(2, 2), (1, 2, 2)]) def test_cho_solve_diff_queue(self, c_shape, device): c = dpnp.full(c_shape, 2.0, device=device)