Skip to content

Commit 7e1034f

Browse files
authored
Merge branch 'master' into nanmedian-numpy
2 parents 8124094 + 3f737be commit 7e1034f

33 files changed

+735
-108
lines changed

.github/workflows/check-mkl-interfaces.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ permissions: read-all
1111
env:
1212
CHANNELS: '-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge --override-channels'
1313
TEST_ENV_NAME: 'test_onemkl_interfaces'
14+
RERUN_TESTS_ON_FAILURE: 'true'
15+
RUN_TESTS_MAX_ATTEMPTS: 2
1416
BUILD_DEP_PKGS: >-
1517
mkl-devel-dpcpp
1618
tbb-devel
@@ -95,11 +97,29 @@ jobs:
9597
mamba install pytest ${{ env.CHANNELS }}
9698
9799
- name: Run tests
100+
if: env.RERUN_TESTS_ON_FAILURE != 'true'
98101
run: |
99102
python -m pytest -ra --pyargs dpnp.tests
100103
env:
101104
SYCL_CACHE_PERSISTENT: 1
102105

106+
- name: ReRun tests on Linux
107+
if: env.RERUN_TESTS_ON_FAILURE == 'true'
108+
id: run_tests
109+
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
110+
with:
111+
timeout_minutes: 10
112+
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
113+
retry_on: any
114+
command: |
115+
. $CONDA/etc/profile.d/conda.sh
116+
. $CONDA/etc/profile.d/mamba.sh
117+
mamba activate ${{ env.TEST_ENV_NAME }}
118+
119+
python -m pytest -ra --pyargs dpnp.tests
120+
env:
121+
SYCL_CACHE_PERSISTENT: 1
122+
103123
test_by_branch:
104124
name: Run on ['${{ matrix.os }}', python='${{ matrix.python }}'] with oneMKL develop branch
105125

@@ -185,7 +205,25 @@ jobs:
185205
mamba install pytest ${{ env.CHANNELS }}
186206
187207
- name: Run tests
208+
if: env.RERUN_TESTS_ON_FAILURE != 'true'
188209
run: |
189210
python -m pytest -ra --pyargs dpnp.tests
190211
env:
191212
SYCL_CACHE_PERSISTENT: 1
213+
214+
- name: ReRun tests on Linux
215+
if: env.RERUN_TESTS_ON_FAILURE == 'true'
216+
id: run_tests
217+
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
218+
with:
219+
timeout_minutes: 10
220+
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
221+
retry_on: any
222+
command: |
223+
. $CONDA/etc/profile.d/conda.sh
224+
. $CONDA/etc/profile.d/mamba.sh
225+
mamba activate ${{ env.TEST_ENV_NAME }}
226+
227+
python -m pytest -ra --pyargs dpnp.tests
228+
env:
229+
SYCL_CACHE_PERSISTENT: 1

.github/workflows/conda-package.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
# Follow oneAPI installation instruction for conda, since intel channel is not longer available
1414
# CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels'
1515
CHANNELS: '-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge --override-channels'
16-
CONDA_BUILD_VERSION: '24.9.0'
16+
CONDA_BUILD_VERSION: '24.11.2'
1717
CONDA_INDEX_VERSION: '0.5.0'
1818
RERUN_TESTS_ON_FAILURE: 'true'
1919
RUN_TESTS_MAX_ATTEMPTS: 2
@@ -182,14 +182,15 @@ jobs:
182182
id: run_tests_linux
183183
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
184184
with:
185-
shell: bash
186185
timeout_minutes: 10
187186
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
188187
retry_on: any
189188
command: |
190189
. $CONDA/etc/profile.d/conda.sh
191-
conda activate ${{ env.TEST_ENV_NAME }}
192-
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
190+
. $CONDA/etc/profile.d/mamba.sh
191+
mamba activate ${{ env.TEST_ENV_NAME }}
192+
193+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
193194
194195
test_windows:
195196
name: Test ['windows-2019', python='${{ matrix.python }}']
@@ -317,13 +318,11 @@ jobs:
317318
id: run_tests_win
318319
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
319320
with:
320-
shell: cmd
321321
timeout_minutes: 15
322322
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
323323
retry_on: any
324-
command: >-
325-
mamba activate ${{ env.TEST_ENV_NAME }}
326-
& pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
324+
command: |
325+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
327326
328327
upload:
329328
name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']

.github/workflows/cron-run-tests.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ env:
1515
PACKAGE_NAME: dpnp
1616
CHANNELS: '-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge --override-channels'
1717
TEST_ENV_NAME: test
18+
RERUN_TESTS_ON_FAILURE: 'true'
19+
RUN_TESTS_MAX_ATTEMPTS: 2
1820

1921
jobs:
2022
test:
@@ -82,7 +84,38 @@ jobs:
8284
python -c "import dpnp; print(dpnp.__version__)"
8385
8486
- name: Run tests
87+
if: env.RERUN_TESTS_ON_FAILURE != 'true'
8588
run: |
8689
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
8790
env:
8891
SYCL_CACHE_PERSISTENT: 1
92+
93+
- name: ReRun tests on Linux
94+
if: env.RERUN_TESTS_ON_FAILURE == 'true' && matrix.runner != 'windows-2019'
95+
id: run_tests_linux
96+
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
97+
with:
98+
timeout_minutes: 10
99+
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
100+
retry_on: any
101+
command: |
102+
. $CONDA/etc/profile.d/conda.sh
103+
. $CONDA/etc/profile.d/mamba.sh
104+
mamba activate ${{ env.TEST_ENV_NAME }}
105+
106+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
107+
env:
108+
SYCL_CACHE_PERSISTENT: 1
109+
110+
- name: ReRun tests on Windows
111+
if: env.RERUN_TESTS_ON_FAILURE == 'true' && matrix.runner == 'windows-2019'
112+
id: run_tests_win
113+
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
114+
with:
115+
timeout_minutes: 15
116+
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
117+
retry_on: any
118+
command: |
119+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
120+
env:
121+
SYCL_CACHE_PERSISTENT: 1

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ project(dpnp
66
DESCRIPTION "NumPy-like API accelerated by SYCL."
77
)
88

9-
option(DPNP_GENERATE_COVERAGE "Enable build DPNP with coverage instrumentation" FALSE)
10-
option(DPNP_BACKEND_TESTS "Enable building of DPNP backend test suite" FALSE)
9+
option(DPNP_GENERATE_COVERAGE "Enable build DPNP with coverage instrumentation" OFF)
10+
option(DPNP_BACKEND_TESTS "Enable building of DPNP backend test suite" OFF)
11+
option(DPNP_WITH_REDIST "Build DPNP assuming DPC++ redistributable is installed into Python prefix" OFF)
1112

1213
set(CMAKE_CXX_STANDARD 17)
1314
set(CMAKE_CXX_STANDARD_REQUIRED True)

conda-recipe/bld.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if DEFINED OVERRIDE_INTEL_IPO (
1616
set "SKBUILD_ARGS=%SKBUILD_ARGS% -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE"
1717
)
1818

19-
FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16 17.0.0 17) DO @(
19+
FOR %%V IN (17.0.0 17 18.0.0 18 19.0.0 19) DO @(
2020
REM set DIR_HINT if directory exists
2121
IF EXIST "%BUILD_PREFIX%\Library\lib\clang\%%V\" (
2222
SET "SYCL_INCLUDE_DIR_HINT=%BUILD_PREFIX%\Library\lib\clang\%%V"

conda-recipe/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# This is necessary to help DPC++ find Intel libraries such as SVML, IRNG, etc in build prefix
4-
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${BUILD_PREFIX}/lib"
4+
export LIBRARY_PATH="$LIBRARY_PATH:${BUILD_PREFIX}/lib"
55

66
# Intel LLVM must cooperate with compiler and sysroot from conda
77
echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot -target ${HOST}" > icpx_for_conda.cfg
@@ -18,6 +18,7 @@ export DPL_ROOT_HINT=$PREFIX
1818
export MKL_ROOT_HINT=$PREFIX
1919
SKBUILD_ARGS=(-- "-DCMAKE_C_COMPILER:PATH=icx" "-DCMAKE_CXX_COMPILER:PATH=icpx" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON")
2020
SKBUILD_ARGS=("${SKBUILD_ARGS[@]}" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON")
21+
SKBUILD_ARGS=("${SKBUILD_ARGS[@]}" "-DDPNP_WITH_REDIST:BOOL=ON")
2122

2223
# Build wheel package
2324
WHEELS_BUILD_ARGS=("-p" "manylinux_2_28_x86_64")

dpnp/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
function(build_dpnp_cython_ext _trgt _src _dest)
22
set(options SYCL)
3-
cmake_parse_arguments(BUILD_DPNP_EXT "${options}" "" "" ${ARGN})
43
add_cython_target(${_trgt} ${_src} CXX OUTPUT_VAR _generated_src)
54
message(STATUS "Using ${_trgt}")
65

@@ -41,15 +40,19 @@ function(build_dpnp_cython_ext _trgt _src _dest)
4140
VERBATIM COMMENT "Copying Cython-generated source for target ${_trgt} to dpnp source layout"
4241
)
4342
endif()
43+
44+
set(_rpath_value "$ORIGIN/..")
45+
if (DPNP_WITH_REDIST)
46+
set(_rpath_value "${_rpath_value}:$ORIGIN/../../../../")
47+
endif()
48+
set_target_properties(${_trgt} PROPERTIES INSTALL_RPATH ${_rpath_value})
49+
4450
install(TARGETS ${_trgt} LIBRARY DESTINATION ${_dest})
4551
endfunction()
4652

4753
function(build_dpnp_cython_ext_with_backend _trgt _src _dest)
4854
build_dpnp_cython_ext(${_trgt} ${_src} ${_dest})
4955
target_link_libraries(${_trgt} PRIVATE dpnp_backend_library)
50-
if (UNIX)
51-
set_target_properties(${_trgt} PROPERTIES INSTALL_RPATH "$ORIGIN/..")
52-
endif()
5356
endfunction()
5457

5558
add_subdirectory(backend)

dpnp/backend/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ add_library(dpnp_backend_library INTERFACE IMPORTED GLOBAL)
100100
target_include_directories(dpnp_backend_library BEFORE INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)
101101
target_link_libraries(dpnp_backend_library INTERFACE ${_trgt})
102102

103+
if (DPNP_WITH_REDIST)
104+
set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../")
105+
endif()
106+
103107
if (DPNP_BACKEND_TESTS)
104108
add_subdirectory(tests)
105109
endif()

dpnp/backend/extensions/blas/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ else()
9393
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::BLAS)
9494
endif()
9595

96+
if (DPNP_WITH_REDIST)
97+
set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../")
98+
endif()
99+
96100
install(TARGETS ${python_module_name}
97101
DESTINATION "dpnp/backend/extensions/blas"
98102
)

dpnp/backend/extensions/fft/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ else()
8989
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::DFT)
9090
endif()
9191

92+
if (DPNP_WITH_REDIST)
93+
set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../")
94+
endif()
95+
9296
install(TARGETS ${python_module_name}
9397
DESTINATION "dpnp/backend/extensions/fft"
9498
)

dpnp/backend/extensions/lapack/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ else()
107107
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::LAPACK)
108108
endif()
109109

110+
if (DPNP_WITH_REDIST)
111+
set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../")
112+
endif()
113+
110114
install(TARGETS ${python_module_name}
111115
DESTINATION "dpnp/backend/extensions/lapack"
112116
)

dpnp/backend/extensions/statistics/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ if (DPNP_GENERATE_COVERAGE)
8484
target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
8585
endif()
8686

87+
if (DPNP_WITH_REDIST)
88+
set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../")
89+
endif()
90+
8791
install(TARGETS ${python_module_name}
8892
DESTINATION "dpnp/backend/extensions/statistics"
8993
)

dpnp/backend/extensions/ufunc/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ if (DPNP_GENERATE_COVERAGE)
103103
target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
104104
endif()
105105

106+
if (DPNP_WITH_REDIST)
107+
set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../")
108+
endif()
109+
106110
install(TARGETS ${python_module_name}
107111
DESTINATION "dpnp/backend/extensions/ufunc"
108112
)

dpnp/backend/extensions/vm/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ else()
120120
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::VM)
121121
endif()
122122

123+
if (DPNP_WITH_REDIST)
124+
set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../")
125+
endif()
126+
123127
install(TARGETS ${python_module_name}
124128
DESTINATION "dpnp/backend/extensions/vm"
125129
)

dpnp/backend/kernels/dpnp_krnl_common.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,23 @@
3535
#include "queue_sycl.hpp"
3636
#include <dpnp_iface.hpp>
3737

38+
/**
39+
* Version of SYCL DPC++ 2025.1 compiler where support of
40+
* sycl::ext::oneapi::experimental::properties was added.
41+
*/
42+
#ifndef __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
43+
#define __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT 20241129
44+
#endif
45+
3846
namespace mkl_blas = oneapi::mkl::blas;
3947
namespace mkl_blas_cm = oneapi::mkl::blas::column_major;
4048
namespace mkl_blas_rm = oneapi::mkl::blas::row_major;
4149
namespace mkl_lapack = oneapi::mkl::lapack;
4250

51+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
52+
namespace syclex = sycl::ext::oneapi::experimental;
53+
#endif
54+
4355
template <typename _KernelNameSpecialization1,
4456
typename _KernelNameSpecialization2,
4557
typename _KernelNameSpecialization3>
@@ -78,8 +90,13 @@ sycl::event dot(sycl::queue &queue,
7890
cgh.parallel_for(
7991
sycl::range<1>{size},
8092
sycl::reduction(
81-
result_out, std::plus<_DataType_output>(),
82-
sycl::property::reduction::initialize_to_identity{}),
93+
result_out, sycl::plus<_DataType_output>(),
94+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
95+
syclex::properties(syclex::initialize_to_identity)
96+
#else
97+
sycl::property::reduction::initialize_to_identity {}
98+
#endif
99+
),
83100
[=](sycl::id<1> idx, auto &sum) {
84101
sum += static_cast<_DataType_output>(
85102
input1_in[idx * input1_strides]) *

dpnp/dpnp_array.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,11 @@ def __isub__(self, other):
434434
dpnp.subtract(self, other, out=self)
435435
return self
436436

437-
# '__iter__',
437+
def __iter__(self):
438+
"""Return ``iter(self)``."""
439+
if self.ndim == 0:
440+
raise TypeError("iteration over a 0-d array")
441+
return (self[i] for i in range(self.shape[0]))
438442

439443
def __itruediv__(self, other):
440444
"""Return ``self/=value``."""
@@ -786,7 +790,14 @@ def clip(self, min=None, max=None, out=None, **kwargs):
786790

787791
return dpnp.clip(self, min, max, out=out, **kwargs)
788792

789-
# 'compress',
793+
def compress(self, condition, axis=None, out=None):
794+
"""
795+
Select slices of an array along a given axis.
796+
797+
Refer to :obj:`dpnp.compress` for full documentation.
798+
"""
799+
800+
return dpnp.compress(condition, self, axis=axis, out=out)
790801

791802
def conj(self):
792803
"""

0 commit comments

Comments
 (0)