Skip to content

Commit d7edd4f

Browse files
authored
Add new test helper functions and print the ID of the default device (#2516)
The PR adds `get_dev_id` and `is_lnl` test helper functions and rework `is_iris_xe` to `is_tgllp_iris_xe` one, because only that GPUs were tested. Also PR implements printing `Device ID` of the default device at the beginning of tests running.
1 parent 879a629 commit d7edd4f

File tree

3 files changed

+42
-23
lines changed

3 files changed

+42
-23
lines changed

dpnp/tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141

4242
import dpnp
4343

44+
from .helper import get_dev_id
45+
4446
skip_mark = pytest.mark.skip(reason="Skipping test.")
4547

4648

@@ -138,6 +140,7 @@ def pytest_collection_modifyitems(config, items):
138140
print(
139141
f"DPNP Test scope includes all integer dtypes: {bool(dtype_config.all_int_types)}"
140142
)
143+
print(f"DPNP current device ID: 0x{get_dev_id(dev):04X}")
141144
print(f"DPNP current device is CPU: {is_cpu}")
142145
print(f"DPNP current device is GPU: {is_gpu}")
143146
print(f"DPNP current device supports fp64: {support_fp64}")

dpnp/tests/helper.py

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ def _assert_shape(a, b):
2727

2828

2929
def _get_dev_mask(device=None):
30-
dev = dpctl.select_default_device() if device is None else device
31-
dev_info = dpctl.utils.intel_device_info(dev)
32-
return dev_info.get("device_id", 0) & 0xFF00
30+
return get_dev_id(device) & 0xFF00
3331

3432

3533
def assert_dtype_allclose(
@@ -110,6 +108,19 @@ def assert_dtype_allclose(
110108
_assert_dtype(dpnp_arr.dtype, numpy_arr.dtype, check_only_type_kind)
111109

112110

111+
def factor_to_tol(dtype, factor):
112+
"""
113+
Calculate the tolerance for comparing floating point and complex arrays.
114+
The tolerance is based on the maximum resolution of the input dtype multiplied by the factor.
115+
"""
116+
117+
tol = 0
118+
if numpy.issubdtype(dtype, numpy.inexact):
119+
tol = numpy.finfo(dtype).resolution
120+
121+
return factor * tol
122+
123+
113124
def generate_random_numpy_array(
114125
shape,
115126
dtype=None,
@@ -208,19 +219,6 @@ def generate_random_numpy_array(
208219
return a
209220

210221

211-
def factor_to_tol(dtype, factor):
212-
"""
213-
Calculate the tolerance for comparing floating point and complex arrays.
214-
The tolerance is based on the maximum resolution of the input dtype multiplied by the factor.
215-
"""
216-
217-
tol = 0
218-
if numpy.issubdtype(dtype, numpy.inexact):
219-
tol = numpy.finfo(dtype).resolution
220-
221-
return factor * tol
222-
223-
224222
def get_abs_array(data, dtype=None):
225223
if numpy.issubdtype(dtype, numpy.unsignedinteger):
226224
data = numpy.abs(data)
@@ -305,6 +303,16 @@ def get_complex_dtypes(device=None):
305303
return dtypes
306304

307305

306+
def get_dev_id(device=None):
307+
"""
308+
Obtain Intel Device ID for a device (the default device if not provided).
309+
"""
310+
311+
dev = dpctl.select_default_device() if device is None else device
312+
dev_info = dpctl.utils.intel_device_info(dev)
313+
return dev_info.get("device_id", 0)
314+
315+
308316
def get_float_dtypes(no_float16=True, device=None):
309317
"""
310318
Build a list of floating types supported by DPNP based on device capabilities.
@@ -456,11 +464,11 @@ def is_intel_numpy():
456464
return all(dep["name"].startswith("mkl") for dep in [blas, lapack])
457465

458466

459-
def is_iris_xe(device=None):
467+
def is_lnl(device=None):
460468
"""
461-
Return True if a test is running on Iris Xe GPU device, False otherwise.
469+
Return True if a test is running on Lunar Lake GPU device, False otherwise.
462470
"""
463-
return _get_dev_mask(device) == 0x9A00
471+
return _get_dev_mask(device) == 0x6400
464472

465473

466474
def is_lts_driver(device=None):
@@ -474,10 +482,18 @@ def is_lts_driver(device=None):
474482

475483
def is_ptl(device=None):
476484
"""
477-
Return True if a test is running on Panther Lake with Iris Xe3 GPU device,
485+
Return True if a test is running on Panther Lake with Iris Xe3 GPU device
486+
(which includes PTL-U, PTL-H and WCL), False otherwise.
487+
"""
488+
return _get_dev_mask(device) in (0xB000, 0xFD00)
489+
490+
491+
def is_tgllp_iris_xe(device=None):
492+
"""
493+
Return True if a test is running on Tiger Lake-LP with Iris Xe GPU device,
478494
False otherwise.
479495
"""
480-
return _get_dev_mask(device) == 0xB000
496+
return get_dev_id(device) in (0x9A49, 0x9A40)
481497

482498

483499
def is_win_platform():

dpnp/tests/test_arraycreation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
assert_dtype_allclose,
2020
get_all_dtypes,
2121
get_array,
22-
is_iris_xe,
2322
is_lts_driver,
23+
is_tgllp_iris_xe,
2424
is_win_platform,
2525
)
2626
from .third_party.cupy import testing
@@ -916,7 +916,7 @@ def test_geomspace_num0():
916916
@pytest.mark.parametrize("num", [2, 4, 8, 3, 9, 27])
917917
@pytest.mark.parametrize("endpoint", [True, False])
918918
def test_logspace(dtype, num, endpoint):
919-
if not is_win_platform() and is_iris_xe() and is_lts_driver():
919+
if not is_win_platform() and is_tgllp_iris_xe() and is_lts_driver():
920920
if (
921921
dpnp.issubdtype(dtype, dpnp.integer)
922922
and num in [8, 27]

0 commit comments

Comments
 (0)