From 39d5dc89e3baf4c2f5cc79348ce68a55e61fbb40 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 7 Jul 2025 06:56:26 -0500 Subject: [PATCH 1/9] Add is_lnl() test helper function --- dpnp/tests/helper.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index a94a592ad2fa..967720cbf77f 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -455,6 +455,13 @@ def is_iris_xe(device=None): return _get_dev_mask(device) == 0x9A00 +def is_lnl(device=None): + """ + Return True if a test is running on Lunar Lake GPU device, False otherwise. + """ + return _get_dev_mask(device) == 0x6400 + + def is_lts_driver(device=None): """ Return True if a test is running on a GPU device with LTS driver version, From 5f6a98b23bd6d85090529202a13f0783c8602e66 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 9 Sep 2025 15:10:26 +0200 Subject: [PATCH 2/9] Add logging of default device ID where the tests are running --- dpnp/tests/conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dpnp/tests/conftest.py b/dpnp/tests/conftest.py index a0a76e3edb4e..2591a88ab751 100644 --- a/dpnp/tests/conftest.py +++ b/dpnp/tests/conftest.py @@ -129,6 +129,7 @@ def pytest_collection_modifyitems(config, items): test_exclude_file_cuda = os.path.join(test_path, "skipped_tests_cuda.tbl") dev = dpctl.select_default_device() + dev_id = dpctl.utils.intel_device_info(dev).get("device_id", 0) is_cpu = dev.is_cpu is_gpu = dev.is_gpu support_fp64 = dev.has_aspect_fp64 @@ -138,6 +139,7 @@ def pytest_collection_modifyitems(config, items): print( f"DPNP Test scope includes all integer dtypes: {bool(dtype_config.all_int_types)}" ) + print(f"DPNP current device ID: {dev_id}") print(f"DPNP current device is CPU: {is_cpu}") print(f"DPNP current device is GPU: {is_gpu}") print(f"DPNP current device supports fp64: {support_fp64}") From 061bc33d0b81a12215a80e423e1d3c3d51ceb459 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 9 Sep 2025 15:35:24 +0200 Subject: [PATCH 3/9] Trace device ID in the the hexadecimal representation --- dpnp/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpnp/tests/conftest.py b/dpnp/tests/conftest.py index 2591a88ab751..d0792bef885d 100644 --- a/dpnp/tests/conftest.py +++ b/dpnp/tests/conftest.py @@ -139,7 +139,7 @@ def pytest_collection_modifyitems(config, items): print( f"DPNP Test scope includes all integer dtypes: {bool(dtype_config.all_int_types)}" ) - print(f"DPNP current device ID: {dev_id}") + print(f"DPNP current device ID: {dev_id:#x}") print(f"DPNP current device is CPU: {is_cpu}") print(f"DPNP current device is GPU: {is_gpu}") print(f"DPNP current device supports fp64: {support_fp64}") From 110d80bd267332dd2ef2171070c56de8013edaf2 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 9 Sep 2025 15:52:26 +0200 Subject: [PATCH 4/9] Add device ID of Wildcat Lake to is_ptl() check --- dpnp/tests/helper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index 967720cbf77f..7c006a9b48c9 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -473,10 +473,10 @@ def is_lts_driver(device=None): def is_ptl(device=None): """ - Return True if a test is running on Panther Lake with Iris Xe3 GPU device, - False otherwise. + Return True if a test is running on Panther Lake with Iris Xe3 GPU device + (which includes PTL-U, PTL-H and WCL), False otherwise. """ - return _get_dev_mask(device) == 0xB000 + return _get_dev_mask(device) in (0xB000, 0xFD00) def is_win_platform(): From d7cd38c67d6a079c5ce27cc91888ed689966641c Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 9 Sep 2025 16:06:18 +0200 Subject: [PATCH 5/9] Add is_tgllp_iris_xe() check instead of more common is_iris_xe() which included also UHD Graphics --- dpnp/tests/helper.py | 23 ++++++++++++++--------- dpnp/tests/test_arraycreation.py | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index 7c006a9b48c9..b9526588aa7f 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -26,10 +26,14 @@ def _assert_shape(a, b): assert a.shape == (), f"{a.shape} != ()" -def _get_dev_mask(device=None): +def _get_dev_id(device=None): dev = dpctl.select_default_device() if device is None else device dev_info = dpctl.utils.intel_device_info(dev) - return dev_info.get("device_id", 0) & 0xFF00 + return dev_info.get("device_id", 0) + + +def _get_dev_mask(device=None): + return _get_dev_id(device) & 0xFF00 def assert_dtype_allclose( @@ -448,13 +452,6 @@ def is_intel_numpy(): return all(dep["name"].startswith("mkl") for dep in [blas, lapack]) -def is_iris_xe(device=None): - """ - Return True if a test is running on Iris Xe GPU device, False otherwise. - """ - return _get_dev_mask(device) == 0x9A00 - - def is_lnl(device=None): """ Return True if a test is running on Lunar Lake GPU device, False otherwise. @@ -479,6 +476,14 @@ def is_ptl(device=None): return _get_dev_mask(device) in (0xB000, 0xFD00) +def is_tgllp_iris_xe(device=None): + """ + Return True if a test is running on Tiger Lake-LP with Iris Xe GPU device, + False otherwise. + """ + return _get_dev_id(device) in (0x9A49, 0x9A40) + + def is_win_platform(): """ Return True if a test is running on Windows OS, False otherwise. diff --git a/dpnp/tests/test_arraycreation.py b/dpnp/tests/test_arraycreation.py index 336162582928..8e4553dcbe4e 100644 --- a/dpnp/tests/test_arraycreation.py +++ b/dpnp/tests/test_arraycreation.py @@ -19,8 +19,8 @@ assert_dtype_allclose, get_all_dtypes, get_array, - is_iris_xe, is_lts_driver, + is_tgllp_iris_xe, is_win_platform, ) from .third_party.cupy import testing @@ -916,7 +916,7 @@ def test_geomspace_num0(): @pytest.mark.parametrize("num", [2, 4, 8, 3, 9, 27]) @pytest.mark.parametrize("endpoint", [True, False]) def test_logspace(dtype, num, endpoint): - if not is_win_platform() and is_iris_xe() and is_lts_driver(): + if not is_win_platform() and is_tgllp_iris_xe() and is_lts_driver(): if ( dpnp.issubdtype(dtype, dpnp.integer) and num in [8, 27] From cacc0d7b267d4c9c2574a394c974bd0b6bf18091 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 9 Sep 2025 16:11:42 +0200 Subject: [PATCH 6/9] Add helper test function to obtain device ID --- dpnp/tests/conftest.py | 5 +++-- dpnp/tests/helper.py | 18 +++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dpnp/tests/conftest.py b/dpnp/tests/conftest.py index d0792bef885d..b393d14e6923 100644 --- a/dpnp/tests/conftest.py +++ b/dpnp/tests/conftest.py @@ -41,6 +41,8 @@ import dpnp +from .helper import get_dev_id + skip_mark = pytest.mark.skip(reason="Skipping test.") @@ -129,7 +131,6 @@ def pytest_collection_modifyitems(config, items): test_exclude_file_cuda = os.path.join(test_path, "skipped_tests_cuda.tbl") dev = dpctl.select_default_device() - dev_id = dpctl.utils.intel_device_info(dev).get("device_id", 0) is_cpu = dev.is_cpu is_gpu = dev.is_gpu support_fp64 = dev.has_aspect_fp64 @@ -139,7 +140,7 @@ def pytest_collection_modifyitems(config, items): print( f"DPNP Test scope includes all integer dtypes: {bool(dtype_config.all_int_types)}" ) - print(f"DPNP current device ID: {dev_id:#x}") + print(f"DPNP current device ID: {get_dev_id(dev):#x}") print(f"DPNP current device is CPU: {is_cpu}") print(f"DPNP current device is GPU: {is_gpu}") print(f"DPNP current device supports fp64: {support_fp64}") diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index b9526588aa7f..c546d08a56e7 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -26,14 +26,8 @@ def _assert_shape(a, b): assert a.shape == (), f"{a.shape} != ()" -def _get_dev_id(device=None): - dev = dpctl.select_default_device() if device is None else device - dev_info = dpctl.utils.intel_device_info(dev) - return dev_info.get("device_id", 0) - - def _get_dev_mask(device=None): - return _get_dev_id(device) & 0xFF00 + return get_dev_id(device) & 0xFF00 def assert_dtype_allclose( @@ -309,6 +303,16 @@ def get_complex_dtypes(device=None): return dtypes +def get_dev_id(device=None): + """ + Obtain Intel Device ID for a device (the default device if not provided). + """ + + dev = dpctl.select_default_device() if device is None else device + dev_info = dpctl.utils.intel_device_info(dev) + return dev_info.get("device_id", 0) + + def get_float_dtypes(no_float16=True, device=None): """ Build a list of floating types supported by DPNP based on device capabilities. From 2852c13d9fb4ed8bce0ba99050c0dcc5558697a2 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 9 Sep 2025 16:13:24 +0200 Subject: [PATCH 7/9] Move factor_to_tol to keep lex order --- dpnp/tests/helper.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index c546d08a56e7..3d630cf7360f 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -108,6 +108,19 @@ def assert_dtype_allclose( _assert_dtype(dpnp_arr.dtype, numpy_arr.dtype, check_only_type_kind) +def factor_to_tol(dtype, factor): + """ + Calculate the tolerance for comparing floating point and complex arrays. + The tolerance is based on the maximum resolution of the input dtype multiplied by the factor. + """ + + tol = 0 + if numpy.issubdtype(dtype, numpy.inexact): + tol = numpy.finfo(dtype).resolution + + return factor * tol + + def generate_random_numpy_array( shape, dtype=None, @@ -206,19 +219,6 @@ def generate_random_numpy_array( return a -def factor_to_tol(dtype, factor): - """ - Calculate the tolerance for comparing floating point and complex arrays. - The tolerance is based on the maximum resolution of the input dtype multiplied by the factor. - """ - - tol = 0 - if numpy.issubdtype(dtype, numpy.inexact): - tol = numpy.finfo(dtype).resolution - - return factor * tol - - def get_abs_array(data, dtype=None): if numpy.issubdtype(dtype, numpy.unsignedinteger): data = numpy.abs(data) From d865b5f6e3efb10dbdf0df2a7afa4dffa208573a Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 9 Sep 2025 17:36:25 +0200 Subject: [PATCH 8/9] Correct implementation of is_tgllp_iris_xe() --- dpnp/tests/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index 3d630cf7360f..28c742ed3f99 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -485,7 +485,7 @@ def is_tgllp_iris_xe(device=None): Return True if a test is running on Tiger Lake-LP with Iris Xe GPU device, False otherwise. """ - return _get_dev_id(device) in (0x9A49, 0x9A40) + return get_dev_id(device) in (0x9A49, 0x9A40) def is_win_platform(): From 21fc956a7193dd5dab9179700ec1b10dc1abc3ff Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 9 Sep 2025 18:56:31 +0200 Subject: [PATCH 9/9] Print device ID with zero-padded to 4 digits --- dpnp/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpnp/tests/conftest.py b/dpnp/tests/conftest.py index b393d14e6923..a22eff8c914b 100644 --- a/dpnp/tests/conftest.py +++ b/dpnp/tests/conftest.py @@ -140,7 +140,7 @@ def pytest_collection_modifyitems(config, items): print( f"DPNP Test scope includes all integer dtypes: {bool(dtype_config.all_int_types)}" ) - print(f"DPNP current device ID: {get_dev_id(dev):#x}") + print(f"DPNP current device ID: 0x{get_dev_id(dev):04X}") print(f"DPNP current device is CPU: {is_cpu}") print(f"DPNP current device is GPU: {is_gpu}") print(f"DPNP current device supports fp64: {support_fp64}")