From a3a78416a918cb4a998b012f43f2576544234a64 Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Wed, 15 Nov 2023 11:31:36 -0600 Subject: [PATCH 1/7] Require dpcpp compiler 2024.0 and runtime >=2024.0 --- .github/workflows/conda-package.yml | 4 ++-- conda-recipe/meta.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 472c0d6be9a3..22a9157cd7bd 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -9,7 +9,7 @@ on: env: PACKAGE_NAME: dpnp MODULE_NAME: dpnp - CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels' + CHANNELS: '-c dppy/label/dev -c intel/label/validation -c intel -c conda-forge --override-channels' # TODO: to add test_arraymanipulation.py back to the scope once crash on Windows is gone TEST_SCOPE: >- test_arraycreation.py @@ -328,7 +328,7 @@ jobs: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- - name: Install opencl_rt - run: conda install opencl_rt -c intel --override-channels + run: conda install opencl_rt -c intel/label/validation -c intel --override-channels - name: Install dpnp run: | diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index dd77870dee56..fd49d6ab3293 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -14,19 +14,19 @@ requirements: - ninja - git - dpctl >=0.15.0 - - mkl-devel-dpcpp {{ environ.get('MKL_VER', '>=2023.2.0') }} + - mkl-devel-dpcpp {{ environ.get('MKL_VER', '>=2024.0') }} - onedpl-devel - tbb-devel - wheel - scikit-build build: - {{ compiler('cxx') }} - - {{ compiler('dpcpp') }} >=2023.2.0 # [not osx] + - {{ compiler('dpcpp') }} >=2024.0 # [not osx] - sysroot_linux-64 >=2.28 # [linux] run: - python - dpctl >=0.15.0 - - {{ pin_compatible('dpcpp-cpp-rt', min_pin='x.x', max_pin='x') }} + - dpcpp-cpp-rt >= 2024.0 - {{ pin_compatible('mkl-dpcpp', min_pin='x.x', max_pin='x') }} - {{ pin_compatible('numpy', min_pin='x.x', max_pin='x') }} From 6579c1eb17c066cbcfa64856af25894b9be5b829 Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Wed, 15 Nov 2023 11:36:48 -0600 Subject: [PATCH 2/7] fix build error --- conda-recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index fd49d6ab3293..c7bf634a811d 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -26,7 +26,7 @@ requirements: run: - python - dpctl >=0.15.0 - - dpcpp-cpp-rt >= 2024.0 + - dpcpp-cpp-rt >=2024.0 - {{ pin_compatible('mkl-dpcpp', min_pin='x.x', max_pin='x') }} - {{ pin_compatible('numpy', min_pin='x.x', max_pin='x') }} From bc07077bc43de6badd7f722bbc49bcad04ee2a23 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 20 Nov 2023 21:34:32 +0100 Subject: [PATCH 3/7] Pinned compiler and dpctl versions --- .github/workflows/build-sphinx.yml | 2 +- conda-recipe/meta.yaml | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-sphinx.yml b/.github/workflows/build-sphinx.yml index 8dc54185f0ae..a35480e25eee 100644 --- a/.github/workflows/build-sphinx.yml +++ b/.github/workflows/build-sphinx.yml @@ -91,7 +91,7 @@ jobs: - name: Install dpnp dependencies run: | - conda install numpy"<1.24" dpctl">=0.15.0" mkl-devel-dpcpp onedpl-devel tbb-devel dpcpp_linux-64 \ + conda install numpy"<1.24" dpctl">=0.15.1dev1" mkl-devel-dpcpp onedpl-devel tbb-devel dpcpp_linux-64 \ cmake cython pytest ninja scikit-build sysroot_linux-64">=2.28" ${{ env.CHANNELS }} - name: Install cuPy dependencies diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index c7bf634a811d..d866ecb9fde5 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -1,3 +1,6 @@ +{% set required_compiler_and_mkl_version = "2024.0" %} +{% set required_dpctl_version = "0.15.1dev1" %} + package: name: dpnp version: {{ GIT_DESCRIBE_TAG }} @@ -13,21 +16,21 @@ requirements: - cmake >=3.21 - ninja - git - - dpctl >=0.15.0 - - mkl-devel-dpcpp {{ environ.get('MKL_VER', '>=2024.0') }} + - dpctl >={{ required_dpctl_version }} + - mkl-devel-dpcpp >={{ required_compiler_and_mkl_version }} - onedpl-devel - tbb-devel - wheel - scikit-build build: - {{ compiler('cxx') }} - - {{ compiler('dpcpp') }} >=2024.0 # [not osx] + - {{ compiler('dpcpp') }} >={{ required_compiler_and_mkl_version }} # [not osx] - sysroot_linux-64 >=2.28 # [linux] run: - python - - dpctl >=0.15.0 - - dpcpp-cpp-rt >=2024.0 - - {{ pin_compatible('mkl-dpcpp', min_pin='x.x', max_pin='x') }} + - dpctl >={{ required_dpctl_version }} + - {{ pin_compatible('dpcpp-cpp-rt', min_pin='x.x') }} + - {{ pin_compatible('mkl-dpcpp', min_pin='x.x') }} - {{ pin_compatible('numpy', min_pin='x.x', max_pin='x') }} build: From c1260ccecf5f653bdceb300be979a2664a7a1394 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 20 Nov 2023 21:36:03 +0100 Subject: [PATCH 4/7] Rolled back to intel channel for conda build --- .github/workflows/conda-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 22a9157cd7bd..472c0d6be9a3 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -9,7 +9,7 @@ on: env: PACKAGE_NAME: dpnp MODULE_NAME: dpnp - CHANNELS: '-c dppy/label/dev -c intel/label/validation -c intel -c conda-forge --override-channels' + CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels' # TODO: to add test_arraymanipulation.py back to the scope once crash on Windows is gone TEST_SCOPE: >- test_arraycreation.py @@ -328,7 +328,7 @@ jobs: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- - name: Install opencl_rt - run: conda install opencl_rt -c intel/label/validation -c intel --override-channels + run: conda install opencl_rt -c intel --override-channels - name: Install dpnp run: | From 89000a2cba343a55aad463d1d75188d564e7ade7 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 21 Nov 2023 10:21:04 +0100 Subject: [PATCH 5/7] Power is properly working for complex types with latest dpctl --- tests/test_mathematical.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/test_mathematical.py b/tests/test_mathematical.py index 89a09a7dc294..e7e7250c2603 100644 --- a/tests/test_mathematical.py +++ b/tests/test_mathematical.py @@ -1876,13 +1876,7 @@ def test_complex_values(self): dp_arr = dpnp.array(np_arr) func = lambda x: x**2 - # Linux: ((inf + 0j) ** 2) == (Inf + NaNj) in dpnp and == (NaN + NaNj) in numpy - # Win: ((inf + 0j) ** 2) == (Inf + 0j) in dpnp and == (Inf + NaNj) in numpy - if is_win_platform(): - assert_equal(func(dp_arr)[5], numpy.inf) - else: - assert_equal(func(dp_arr)[5], (numpy.inf + 0j) * 1) - assert_allclose(func(np_arr)[:5], func(dp_arr).asnumpy()[:5], rtol=1e-6) + assert_dtype_allclose(func(dp_arr), func(np_arr)) @pytest.mark.parametrize("val", [0, 1], ids=["0", "1"]) @pytest.mark.parametrize("dtype", [dpnp.int32, dpnp.int64]) From 9f7eabbb94903f134c59ee09810709d29d5435a5 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 21 Nov 2023 11:37:30 +0100 Subject: [PATCH 6/7] Keep backward compatibility with dpctl 0.15.0 --- dpnp/dpnp_algo/dpnp_elementwise_common.py | 81 +++++++++++++++++++++-- tests/test_mathematical.py | 6 ++ 2 files changed, 81 insertions(+), 6 deletions(-) diff --git a/dpnp/dpnp_algo/dpnp_elementwise_common.py b/dpnp/dpnp_algo/dpnp_elementwise_common.py index 315b266c8032..57f7576e8d3b 100644 --- a/dpnp/dpnp_algo/dpnp_elementwise_common.py +++ b/dpnp/dpnp_algo/dpnp_elementwise_common.py @@ -167,11 +167,80 @@ def check_nd_call_func( ) +""" +Below utility functions are required to keep backward compitibility +with DPC++ 2023.2 and dpctl 0.15.0. Otherwise we can't collect coverage report, +since DPC++ 2024.0 has the reported crash issue while running for coverage +and the latest dpctl (i.e. >0.15.0) can't be installed with DPC++ 2023.2. + +TODO: remove the w/a once the above issue is resolved. +""" + + +def _get_impl_fn(dpt_fn): + if hasattr(dpt_fn, "get_implementation_function"): + return dpt_fn.get_implementation_function() + + if hasattr(dpt_fn, "__name__"): + if dpt_fn.__name__ == "UnaryElementwiseFunc": + return dpt_fn.unary_fn_ + elif dpt_fn.__name__ == "BinaryElementwiseFunc": + return dpt_fn.binary_fn_ + + raise TypeError( + "Expected an instance of elementwise func class, but got {}".format( + type(dpt_fn) + ) + ) + + +def _get_type_resolver_fn(dpt_fn): + if hasattr(dpt_fn, "get_type_result_resolver_function"): + return dpt_fn.get_type_result_resolver_function() + + if hasattr(dpt_fn, "result_type_resolver_fn_"): + return dpt_fn.result_type_resolver_fn_ + + raise TypeError( + "Expected an instance of elementwise func class, but got {}".format( + type(dpt_fn) + ) + ) + + +def _get_impl_inplace_fn(dpt_fn): + if hasattr(dpt_fn, "get_implementation_inplace_function"): + return dpt_fn.get_implementation_inplace_function() + + if hasattr(dpt_fn, "binary_inplace_fn_"): + return dpt_fn.binary_inplace_fn_ + + raise TypeError( + "Expected an instance of elementwise func class, but got {}".format( + type(dpt_fn) + ) + ) + + +def _get_type_promotion_fn(dpt_fn): + if hasattr(dpt_fn, "get_type_promotion_path_acceptance_function"): + return dpt_fn.get_type_promotion_path_acceptance_function() + + if hasattr(dpt_fn, "acceptance_fn_"): + return dpt_fn.acceptance_fn_ + + raise TypeError( + "Expected an instance of elementwise func class, but got {}".format( + type(dpt_fn) + ) + ) + + def _make_unary_func( name, dpt_unary_fn, fn_docstring, mkl_fn_to_call=None, mkl_impl_fn=None ): - impl_fn = dpt_unary_fn.get_implementation_function() - type_resolver_fn = dpt_unary_fn.get_type_result_resolver_function() + impl_fn = _get_impl_fn(dpt_unary_fn) + type_resolver_fn = _get_type_resolver_fn(dpt_unary_fn) def _call_func(src, dst, sycl_queue, depends=None): """A callback to register in UnaryElementwiseFunc class of dpctl.tensor""" @@ -193,10 +262,10 @@ def _call_func(src, dst, sycl_queue, depends=None): def _make_binary_func( name, dpt_binary_fn, fn_docstring, mkl_fn_to_call=None, mkl_impl_fn=None ): - impl_fn = dpt_binary_fn.get_implementation_function() - type_resolver_fn = dpt_binary_fn.get_type_result_resolver_function() - inplce_fn = dpt_binary_fn.get_implementation_inplace_function() - acceptance_fn = dpt_binary_fn.get_type_promotion_path_acceptance_function() + impl_fn = _get_impl_fn(dpt_binary_fn) + type_resolver_fn = _get_type_resolver_fn(dpt_binary_fn) + inplce_fn = _get_impl_inplace_fn(dpt_binary_fn) + acceptance_fn = _get_type_promotion_fn(dpt_binary_fn) def _call_func(src1, src2, dst, sycl_queue, depends=None): """A callback to register in UnaryElementwiseFunc class of dpctl.tensor""" diff --git a/tests/test_mathematical.py b/tests/test_mathematical.py index e7e7250c2603..b0c8caff3ad9 100644 --- a/tests/test_mathematical.py +++ b/tests/test_mathematical.py @@ -1876,6 +1876,12 @@ def test_complex_values(self): dp_arr = dpnp.array(np_arr) func = lambda x: x**2 + # TODO: unmute the test once it's available + if is_win_platform(): + pytest.skip( + "Until the latest dpctl is available on internal channel" + ) + assert_dtype_allclose(func(dp_arr), func(np_arr)) @pytest.mark.parametrize("val", [0, 1], ids=["0", "1"]) From ea821b98fd266cbfa5664a901d12aefcf337160c Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 22 Nov 2023 18:14:13 +0100 Subject: [PATCH 7/7] Install dpctl version compatible with DPC++ 2023.2 while collecting coverage --- .github/workflows/build-sphinx.yml | 2 +- .github/workflows/generate_coverage.yaml | 4 +- conda-recipe/meta.yaml | 8 +-- dpnp/dpnp_algo/dpnp_elementwise_common.py | 81 ++--------------------- 4 files changed, 13 insertions(+), 82 deletions(-) diff --git a/.github/workflows/build-sphinx.yml b/.github/workflows/build-sphinx.yml index a35480e25eee..90efdc044c9e 100644 --- a/.github/workflows/build-sphinx.yml +++ b/.github/workflows/build-sphinx.yml @@ -91,7 +91,7 @@ jobs: - name: Install dpnp dependencies run: | - conda install numpy"<1.24" dpctl">=0.15.1dev1" mkl-devel-dpcpp onedpl-devel tbb-devel dpcpp_linux-64 \ + conda install numpy"<1.24" dpctl">=0.15.1dev2" mkl-devel-dpcpp onedpl-devel tbb-devel dpcpp_linux-64 \ cmake cython pytest ninja scikit-build sysroot_linux-64">=2.28" ${{ env.CHANNELS }} - name: Install cuPy dependencies diff --git a/.github/workflows/generate_coverage.yaml b/.github/workflows/generate_coverage.yaml index f52d2dcb6e10..9d6b2e511f4b 100644 --- a/.github/workflows/generate_coverage.yaml +++ b/.github/workflows/generate_coverage.yaml @@ -15,7 +15,7 @@ jobs: env: python-ver: '3.10' - CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels' + CHANNELS: '-c dppy/label/coverage -c intel -c conda-forge --override-channels' steps: - name: Cancel Previous Runs @@ -44,7 +44,7 @@ jobs: run: | # use DPC++ compiler 2023.2 to work around an issue with crash conda install cython llvm cmake">=3.21" scikit-build ninja pytest pytest-cov coverage[toml] \ - dpctl dpcpp_linux-64"=2023.2" sysroot_linux-64">=2.28" mkl-devel-dpcpp tbb-devel"=2021.10" \ + dpctl">=0.15.1dev2" dpcpp_linux-64"=2023.2" sysroot_linux-64">=2.28" mkl-devel-dpcpp tbb-devel"=2021.10" \ onedpl-devel ${{ env.CHANNELS }} - name: Conda info diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index d866ecb9fde5..874f02bbae30 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -1,5 +1,5 @@ {% set required_compiler_and_mkl_version = "2024.0" %} -{% set required_dpctl_version = "0.15.1dev1" %} +{% set required_dpctl_version = "0.15.1dev2" %} package: name: dpnp @@ -28,9 +28,9 @@ requirements: - sysroot_linux-64 >=2.28 # [linux] run: - python - - dpctl >={{ required_dpctl_version }} - - {{ pin_compatible('dpcpp-cpp-rt', min_pin='x.x') }} - - {{ pin_compatible('mkl-dpcpp', min_pin='x.x') }} + - {{ pin_compatible('dpctl', min_pin='x.x.x', max_pin=None) }} + - {{ pin_compatible('dpcpp-cpp-rt', min_pin='x.x', max_pin='x') }} + - {{ pin_compatible('mkl-dpcpp', min_pin='x.x', max_pin='x') }} - {{ pin_compatible('numpy', min_pin='x.x', max_pin='x') }} build: diff --git a/dpnp/dpnp_algo/dpnp_elementwise_common.py b/dpnp/dpnp_algo/dpnp_elementwise_common.py index 57f7576e8d3b..315b266c8032 100644 --- a/dpnp/dpnp_algo/dpnp_elementwise_common.py +++ b/dpnp/dpnp_algo/dpnp_elementwise_common.py @@ -167,80 +167,11 @@ def check_nd_call_func( ) -""" -Below utility functions are required to keep backward compitibility -with DPC++ 2023.2 and dpctl 0.15.0. Otherwise we can't collect coverage report, -since DPC++ 2024.0 has the reported crash issue while running for coverage -and the latest dpctl (i.e. >0.15.0) can't be installed with DPC++ 2023.2. - -TODO: remove the w/a once the above issue is resolved. -""" - - -def _get_impl_fn(dpt_fn): - if hasattr(dpt_fn, "get_implementation_function"): - return dpt_fn.get_implementation_function() - - if hasattr(dpt_fn, "__name__"): - if dpt_fn.__name__ == "UnaryElementwiseFunc": - return dpt_fn.unary_fn_ - elif dpt_fn.__name__ == "BinaryElementwiseFunc": - return dpt_fn.binary_fn_ - - raise TypeError( - "Expected an instance of elementwise func class, but got {}".format( - type(dpt_fn) - ) - ) - - -def _get_type_resolver_fn(dpt_fn): - if hasattr(dpt_fn, "get_type_result_resolver_function"): - return dpt_fn.get_type_result_resolver_function() - - if hasattr(dpt_fn, "result_type_resolver_fn_"): - return dpt_fn.result_type_resolver_fn_ - - raise TypeError( - "Expected an instance of elementwise func class, but got {}".format( - type(dpt_fn) - ) - ) - - -def _get_impl_inplace_fn(dpt_fn): - if hasattr(dpt_fn, "get_implementation_inplace_function"): - return dpt_fn.get_implementation_inplace_function() - - if hasattr(dpt_fn, "binary_inplace_fn_"): - return dpt_fn.binary_inplace_fn_ - - raise TypeError( - "Expected an instance of elementwise func class, but got {}".format( - type(dpt_fn) - ) - ) - - -def _get_type_promotion_fn(dpt_fn): - if hasattr(dpt_fn, "get_type_promotion_path_acceptance_function"): - return dpt_fn.get_type_promotion_path_acceptance_function() - - if hasattr(dpt_fn, "acceptance_fn_"): - return dpt_fn.acceptance_fn_ - - raise TypeError( - "Expected an instance of elementwise func class, but got {}".format( - type(dpt_fn) - ) - ) - - def _make_unary_func( name, dpt_unary_fn, fn_docstring, mkl_fn_to_call=None, mkl_impl_fn=None ): - impl_fn = _get_impl_fn(dpt_unary_fn) - type_resolver_fn = _get_type_resolver_fn(dpt_unary_fn) + impl_fn = dpt_unary_fn.get_implementation_function() + type_resolver_fn = dpt_unary_fn.get_type_result_resolver_function() def _call_func(src, dst, sycl_queue, depends=None): """A callback to register in UnaryElementwiseFunc class of dpctl.tensor""" @@ -262,10 +193,10 @@ def _call_func(src, dst, sycl_queue, depends=None): def _make_binary_func( name, dpt_binary_fn, fn_docstring, mkl_fn_to_call=None, mkl_impl_fn=None ): - impl_fn = _get_impl_fn(dpt_binary_fn) - type_resolver_fn = _get_type_resolver_fn(dpt_binary_fn) - inplce_fn = _get_impl_inplace_fn(dpt_binary_fn) - acceptance_fn = _get_type_promotion_fn(dpt_binary_fn) + impl_fn = dpt_binary_fn.get_implementation_function() + type_resolver_fn = dpt_binary_fn.get_type_result_resolver_function() + inplce_fn = dpt_binary_fn.get_implementation_inplace_function() + acceptance_fn = dpt_binary_fn.get_type_promotion_path_acceptance_function() def _call_func(src1, src2, dst, sycl_queue, depends=None): """A callback to register in UnaryElementwiseFunc class of dpctl.tensor"""