From 2c3c6b065b6b434b5bf198f0431717449aa47819 Mon Sep 17 00:00:00 2001 From: Anton <100830759+antonwolfy@users.noreply.github.com> Date: Thu, 10 Nov 2022 15:54:28 +0100 Subject: [PATCH 1/5] Decrease array size for stability (#1227) --- tests/test_arraycreation.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tests/test_arraycreation.py b/tests/test_arraycreation.py index 01abce88a504..e9f703d783dc 100644 --- a/tests/test_arraycreation.py +++ b/tests/test_arraycreation.py @@ -12,7 +12,7 @@ [0, -5, 10, -2.5, 9.7], ids=['0', '-5', '10', '-2.5', '9.7']) @pytest.mark.parametrize("stop", - [None, 10, -2, 20.5, 10**5], + [None, 10, -2, 20.5, 1000], ids=['None', '10', '-2', '20.5', '10**5']) @pytest.mark.parametrize("step", [None, 1, 2.7, -1.6, 100], @@ -26,17 +26,6 @@ def test_arange(start, stop, step, dtype): # numpy casts to float32 type when computes float16 data rtol_mult = 4 - # secure there is no 'inf' elements in resulting array - max = numpy.finfo(dtype).max - if stop is not None and stop > max: - # consider comulative accuracy while generating array - # to calculate maximum allowed 'stop' value for dtype=float16 - arr_len = (max - start) / (step if step is not None else 1) - arr_ilen = int(arr_len) - arr_len = (arr_ilen + 1) if float(arr_ilen) < arr_len else arr_ilen - acc = rtol_mult * numpy.finfo(dtype).eps - stop = max - acc * arr_len - exp_array = numpy.arange(start, stop=stop, step=step, dtype=dtype) dpnp_array = dpnp.arange(start, stop=stop, step=step, dtype=dtype) From 0a19b738cfdd890bb92aa738c094aca07657a2c4 Mon Sep 17 00:00:00 2001 From: Anton <100830759+antonwolfy@users.noreply.github.com> Date: Thu, 10 Nov 2022 18:37:24 +0100 Subject: [PATCH 2/5] dpnp_array must expose usm_type (#1228) --- dpnp/dpnp_array.py | 4 ++++ tests/test_random_state.py | 26 ++++++++++++++++---------- tests/test_sycl_queue.py | 6 ++---- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 1ac50e12c381..c3d35ab0e729 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -115,6 +115,10 @@ def sycl_context(self): def device(self): return self._array_obj.device + @property + def usm_type(self): + return self._array_obj.usm_type + def __abs__(self): return dpnp.abs(self) diff --git a/tests/test_random_state.py b/tests/test_random_state.py index c09b5c17a880..9d2f14643c84 100644 --- a/tests/test_random_state.py +++ b/tests/test_random_state.py @@ -15,6 +15,12 @@ ) +def assert_cfd(data, exp_sycl_queue, exp_usm_type=None): + assert exp_sycl_queue == data.sycl_queue + if exp_usm_type: + assert exp_usm_type == data.usm_type + + class TestNormal: @pytest.mark.parametrize("dtype", [dpnp.float32, dpnp.float64, None], @@ -47,7 +53,7 @@ def test_distr(self, dtype, usm_type): assert_array_almost_equal(dpnp.asnumpy(data), desired, decimal=precision) # check if compute follows data isn't broken - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue, usm_type) @pytest.mark.parametrize("dtype", @@ -138,7 +144,7 @@ def test_fallback(self, loc, scale): assert_array_almost_equal(actual, desired, decimal=precision) # check if compute follows data isn't broken - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue) @pytest.mark.parametrize("dtype", @@ -174,17 +180,17 @@ def test_distr(self, usm_type): precision = numpy.finfo(dtype=numpy.float64).precision assert_array_almost_equal(dpnp.asnumpy(data), desired, decimal=precision) - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue, usm_type) # call with the same seed has to draw the same values data = RandomState(seed, sycl_queue=sycl_queue).rand(3, 2, usm_type=usm_type) assert_array_almost_equal(dpnp.asnumpy(data), desired, decimal=precision) - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue, usm_type) # call with omitted dimensions has to draw the first element from desired data = RandomState(seed, sycl_queue=sycl_queue).rand(usm_type=usm_type) assert_array_almost_equal(dpnp.asnumpy(data), desired[0, 0], decimal=precision) - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue, usm_type) # rand() is an alias on random_sample(), map arguments with mock.patch('dpnp.random.RandomState.random_sample') as m: @@ -245,7 +251,7 @@ def test_distr(self, dtype, usm_type): [5, 3], [5, 7]], dtype=numpy.int32) assert_array_equal(dpnp.asnumpy(data), desired) - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue, usm_type) # call with the same seed has to draw the same values data = RandomState(seed, sycl_queue=sycl_queue).randint(low=low, @@ -254,7 +260,7 @@ def test_distr(self, dtype, usm_type): dtype=dtype, usm_type=usm_type) assert_array_equal(dpnp.asnumpy(data), desired) - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue, usm_type) # call with omitted dimensions has to draw the first element from desired data = RandomState(seed, sycl_queue=sycl_queue).randint(low=low, @@ -262,7 +268,7 @@ def test_distr(self, dtype, usm_type): dtype=dtype, usm_type=usm_type) assert_array_equal(dpnp.asnumpy(data), desired[0, 0]) - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue, usm_type) # rand() is an alias on random_sample(), map arguments with mock.patch('dpnp.random.RandomState.uniform') as m: @@ -701,7 +707,7 @@ def test_distr(self, bounds, dtype, usm_type): assert_array_equal(dpnp.asnumpy(data), desired) # check if compute follows data isn't broken - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue, usm_type) @pytest.mark.parametrize("dtype", @@ -766,7 +772,7 @@ def test_fallback(self, low, high): assert_array_almost_equal(actual, desired, decimal=precision) # check if compute follows data isn't broken - assert sycl_queue == data.sycl_queue + assert_cfd(data, sycl_queue) @pytest.mark.parametrize("dtype", diff --git a/tests/test_sycl_queue.py b/tests/test_sycl_queue.py index e1d902588afe..e3e8680e6aca 100644 --- a/tests/test_sycl_queue.py +++ b/tests/test_sycl_queue.py @@ -278,8 +278,7 @@ def test_uniform(usm_type, size): high = 2.0 res = dpnp.random.uniform(low, high, size=size, usm_type=usm_type) - res_usm_type = res.get_array().usm_type - assert usm_type == res_usm_type + assert usm_type == res.usm_type @pytest.mark.parametrize("usm_type", @@ -295,8 +294,7 @@ def test_rs_uniform(usm_type, seed): rs = dpnp.random.RandomState(seed, sycl_queue=sycl_queue) res = rs.uniform(low, high, usm_type=usm_type) - res_usm_type = res.get_array().usm_type - assert usm_type == res_usm_type + assert usm_type == res.usm_type res_sycl_queue = res.get_array().sycl_queue assert_sycl_queue_equal(res_sycl_queue, sycl_queue) From 33e0da54657191fbc2bd74d4a62fe174654c6daf Mon Sep 17 00:00:00 2001 From: Anton <100830759+antonwolfy@users.noreply.github.com> Date: Fri, 11 Nov 2022 12:44:03 +0100 Subject: [PATCH 3/5] Leave is_host() call with old compiler only (#1224) * Leave is_host() call with old compiler only * Incremented 2023-SWITCHOVER timestamp --- dpnp/backend/src/dpnp_utils.hpp | 11 ++++++++++- dpnp/backend/src/dpnpc_memory_adapter.hpp | 5 ++++- dpnp/backend/src/queue_sycl.cpp | 9 +++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dpnp/backend/src/dpnp_utils.hpp b/dpnp/backend/src/dpnp_utils.hpp index f84dd3a74721..ec6a9c511c88 100644 --- a/dpnp/backend/src/dpnp_utils.hpp +++ b/dpnp/backend/src/dpnp_utils.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// Copyright (c) 2016-2020, Intel Corporation +// Copyright (c) 2016-2022, Intel Corporation // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -40,6 +40,15 @@ (__LIBSYCL_MAJOR_VERSION > major) || (__LIBSYCL_MAJOR_VERSION == major and __LIBSYCL_MINOR_VERSION > minor) || \ (__LIBSYCL_MAJOR_VERSION == major and __LIBSYCL_MINOR_VERSION == minor and __LIBSYCL_PATCH_VERSION >= patch) +/** + * Version of SYCL DPC++ 2023 compiler at which transition to SYCL 2020 occurs. + * Intel(R) oneAPI DPC++ 2022.2.1 compiler has version 20221020L on Linux and + * 20221101L on Windows. + */ +#ifndef __SYCL_COMPILER_2023_SWITCHOVER +#define __SYCL_COMPILER_2023_SWITCHOVER 20221102L +#endif + /** * @defgroup BACKEND_UTILS Backend C++ library utilities * @{ diff --git a/dpnp/backend/src/dpnpc_memory_adapter.hpp b/dpnp/backend/src/dpnpc_memory_adapter.hpp index 3b07795ed5f6..dab09622a698 100644 --- a/dpnp/backend/src/dpnpc_memory_adapter.hpp +++ b/dpnp/backend/src/dpnpc_memory_adapter.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// Copyright (c) 2016-2020, Intel Corporation +// Copyright (c) 2016-2022, Intel Corporation // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -28,6 +28,7 @@ #define DPNP_MEMORY_ADAPTER_H #include "queue_sycl.hpp" +#include "dpnp_utils.hpp" /** * @ingroup BACKEND_UTILS @@ -84,8 +85,10 @@ class DPNPC_ptr_adapter final std::cerr << "\n\t size_in_bytes=" << size_in_bytes; std::cerr << "\n\t pointer type=" << (long)src_ptr_type; std::cerr << "\n\t queue inorder=" << queue.is_in_order(); +#if (__SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER) std::cerr << "\n\t queue is_host=" << queue.is_host(); std::cerr << "\n\t queue device is_host=" << queue.get_device().is_host(); +#endif std::cerr << "\n\t queue device is_cpu=" << queue.get_device().is_cpu(); std::cerr << "\n\t queue device is_gpu=" << queue.get_device().is_gpu(); std::cerr << "\n\t queue device is_accelerator=" << queue.get_device().is_accelerator(); diff --git a/dpnp/backend/src/queue_sycl.cpp b/dpnp/backend/src/queue_sycl.cpp index 40bbd886f9dd..0810ed0aaba8 100644 --- a/dpnp/backend/src/queue_sycl.cpp +++ b/dpnp/backend/src/queue_sycl.cpp @@ -29,6 +29,7 @@ #include #include "queue_sycl.hpp" +#include "dpnp_utils.hpp" #if defined(DPNP_LOCAL_QUEUE) sycl::queue* backend_sycl::queue = nullptr; @@ -211,10 +212,14 @@ bool backend_sycl::backend_sycl_is_cpu() { sycl::queue& qptr = get_queue(); - if (qptr.is_host() || qptr.get_device().is_cpu() || qptr.get_device().is_host()) - { + if (qptr.get_device().is_cpu()) { + return true; + } +#if (__SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER) + else if (qptr.is_host() || qptr.get_device().is_host()) { return true; } +#endif return false; } From 19ed9a2538db09711fb1a0759535c89d7fd3592b Mon Sep 17 00:00:00 2001 From: Anton <100830759+antonwolfy@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:41:03 +0100 Subject: [PATCH 4/5] Exclude running upload steps for fork repo (#1230) --- .github/workflows/conda-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 870d52f1d778..89376d4bb262 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -456,7 +456,7 @@ jobs: needs: test_windows if: | - !github.event.pull_request.head.repo.fork && + !github.event.pull_request.head.repo.fork && !github.event.push.repository.fork && (github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')) runs-on: windows-latest From 97fcb85bd43962982297e87933a111327154ed88 Mon Sep 17 00:00:00 2001 From: Anton <100830759+antonwolfy@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:20:56 +0100 Subject: [PATCH 5/5] Setting version to 0.11.0 (#1231) --- doc/conf.py | 4 ++-- dpnp/backend/CMakeLists.txt | 4 ++-- dpnp/backend/doc/Doxyfile | 2 +- dpnp/version.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a3d1cd5798b9..46505fa8f6db 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -31,9 +31,9 @@ author = 'Intel' # The short X.Y version -version = '0.10' +version = '0.11' # The full version, including alpha/beta/rc tags -release = '0.10.3' +release = '0.11.0' # -- General configuration --------------------------------------------------- diff --git a/dpnp/backend/CMakeLists.txt b/dpnp/backend/CMakeLists.txt index 62456a270a96..409a29f8a310 100644 --- a/dpnp/backend/CMakeLists.txt +++ b/dpnp/backend/CMakeLists.txt @@ -27,8 +27,8 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) -# set(DPNP_VERSION 0.10.3) -# set(DPNP_API_VERSION 0.10) +# set(DPNP_VERSION 0.11.0) +# set(DPNP_API_VERSION 0.11) # set directory where the custom finders live set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules") diff --git a/dpnp/backend/doc/Doxyfile b/dpnp/backend/doc/Doxyfile index 8e9b4e3d5ec1..6c83bb0e8465 100644 --- a/dpnp/backend/doc/Doxyfile +++ b/dpnp/backend/doc/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "DPNP C++ backend kernel library" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 0.10.3 +PROJECT_NUMBER = 0.11.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/dpnp/version.py b/dpnp/version.py index 8d87f84a961c..160e8ec963a8 100644 --- a/dpnp/version.py +++ b/dpnp/version.py @@ -29,6 +29,6 @@ DPNP version module """ -__version__: str = '0.10.3' +__version__: str = '0.11.0' version: str = __version__