Skip to content

Commit 644805f

Browse files
Merge master into not_equal_impl
2 parents 9a9e3ed + 82c3223 commit 644805f

File tree

22 files changed

+1854
-737
lines changed

22 files changed

+1854
-737
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2+
# file Copyright.txt or https://cmake.org/licensing for details.
3+
4+
5+
# This module is shared by multiple languages; use include blocker.
6+
if(__WINDOWS_INTEL_LLVM)
7+
return()
8+
endif()
9+
set(__WINDOWS_INTEL_LLVM 1)
10+
11+
# Platform/Windows-MSVC adds some linking options icx/ifx do not understand,
12+
# but that need to be passed to the linker. Wrap all the linking options from
13+
# Platform/Windows-MSVC so that the compiler will hand them off to the linker
14+
# without interpreting them.
15+
16+
# Save original CMAKE_${t}_LINKER_FLAGS_INIT
17+
foreach(t EXE SHARED MODULE STATIC)
18+
set(_saved_cmake_${t}_linker_flags_init ${CMAKE_${t}_LINKER_FLAGS_INIT})
19+
set(CMAKE_${t}_LINKER_FLAGS_INIT "")
20+
endforeach()
21+
include(Platform/Windows-MSVC)
22+
# Wrap linker flags from Windows-MSVC
23+
set(_IntelLLVM_LINKER_WRAPPER_FLAG "/Qoption,link,")
24+
set(_IntelLLVM_LINKER_WRAPPER_FLAG_SEP ",")
25+
foreach(t EXE SHARED MODULE STATIC)
26+
set(_wrapped_linker_flags "")
27+
foreach(flag ${CMAKE_${t}_LINKER_FLAGS_INIT})
28+
string(STRIP ${flag} flag)
29+
list(APPEND _wrapped_linker_flags "${_IntelLLVM_LINKER_WRAPPER_FLAG}${flag}")
30+
endforeach()
31+
set(CMAKE_${t}_LINKER_FLAGS_INIT "")
32+
list(APPEND CMAKE_${t}_LINKER_FLAGS_INIT
33+
${_saved_cmake_${t}_linker_flags_init} ${_wrapped_linker_flags})
34+
endforeach()
35+
36+
macro(__windows_compiler_intel lang)
37+
__windows_compiler_msvc(${lang})
38+
39+
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "${_IntelLLVM_LINKER_WRAPPER_FLAG}")
40+
set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP "${_IntelLLVM_LINKER_WRAPPER_FLAG_SEP}")
41+
set(CMAKE_${lang}_CREATE_WIN32_EXE "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/subsystem:windows")
42+
set(CMAKE_${lang}_CREATE_CONSOLE_EXE "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/subsystem:console")
43+
set(CMAKE_LINK_DEF_FILE_FLAG "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/DEF:")
44+
set(CMAKE_LIBRARY_PATH_FLAG "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/LIBPATH:")
45+
46+
# Features for LINK_LIBRARY generator expression
47+
if(MSVC_VERSION GREATER "1900")
48+
## WHOLE_ARCHIVE: Force loading all members of an archive
49+
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:/WHOLEARCHIVE:<LIBRARY>")
50+
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
51+
endif()
52+
53+
set(CMAKE_${lang}_LINK_EXECUTABLE
54+
"${_CMAKE_VS_LINK_EXE}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <LINK_LIBRARIES> /link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}")
55+
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
56+
"${_CMAKE_VS_LINK_DLL}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -LD <LINK_FLAGS> <LINK_LIBRARIES> -link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}")
57+
set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY})
58+
if (NOT "${lang}" STREQUAL "Fortran" OR CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2022.1)
59+
# The Fortran driver does not support -fuse-ld=llvm-lib before compiler version 2022.1
60+
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
61+
"<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -fuse-ld=llvm-lib -o <TARGET> <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
62+
endif()
63+
64+
set(CMAKE_DEPFILE_FLAGS_${lang} "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
65+
set(CMAKE_${lang}_DEPFILE_FORMAT gcc)
66+
endmacro()

.github/workflows/conda-package.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: conda install conda-build
4545
- name: Build conda package
4646
run: |
47-
CHANNELS="-c dppy/label/tools -c intel -c main --override-channels"
47+
CHANNELS="-c intel -c conda-forge --override-channels"
4848
VERSIONS="--python ${{ matrix.python }}"
4949
TEST="--no-test"
5050
conda build \
@@ -72,7 +72,6 @@ jobs:
7272
fetch-depth: 0
7373
- uses: conda-incubator/setup-miniconda@v2
7474
with:
75-
use-only-tar-bz2: true
7675
auto-activate-base: true
7776
conda-build-version: "*"
7877
activate-environment: true
@@ -90,7 +89,7 @@ jobs:
9089
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
9190
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
9291
- name: Build conda package
93-
run: conda build --no-test --python ${{ matrix.python }} -c intel -c main --override-channels conda-recipe
92+
run: conda build --no-test --python ${{ matrix.python }} -c intel -c conda-forge --override-channels conda-recipe
9493
- name: Upload artifact
9594
uses: actions/upload-artifact@v3
9695
with:
@@ -108,7 +107,7 @@ jobs:
108107
runner: [ubuntu-20.04]
109108
continue-on-error: ${{ matrix.experimental }}
110109
env:
111-
CHANNELS: -c intel -c main --override-channels
110+
CHANNELS: -c intel -c conda-forge --override-channels
112111

113112
steps:
114113
- name: Download artifact
@@ -192,7 +191,7 @@ jobs:
192191
continue-on-error: ${{ matrix.experimental }}
193192
env:
194193
workdir: '${{ github.workspace }}'
195-
CHANNELS: -c intel -c main --override-channels
194+
CHANNELS: -c intel -c conda-forge --override-channels
196195

197196
steps:
198197
- name: Download artifact
@@ -201,7 +200,6 @@ jobs:
201200
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
202201
- uses: conda-incubator/setup-miniconda@v2
203202
with:
204-
use-only-tar-bz2: true
205203
auto-update-conda: true
206204
conda-build-version: '*'
207205
miniconda-version: 'latest'
@@ -355,7 +353,7 @@ jobs:
355353
runner: [ubuntu-20.04]
356354
continue-on-error: ${{ matrix.experimental }}
357355
env:
358-
CHANNELS: -c intel -c main --override-channels
356+
CHANNELS: -c intel -c conda-forge --override-channels
359357

360358
steps:
361359
- name: Install conda-build
@@ -408,12 +406,12 @@ jobs:
408406
conda install -n examples -y ninja $CHANNELS || exit 1
409407
conda install -n examples -y pybind11 cython scikit-build $CHANNELS || exit 1
410408
conda install -n examples -y mkl-dpcpp mkl-devel-dpcpp dpcpp_cpp_rt $CHANNELS || exit 1
411-
conda create -y -n build_env -c intel gcc_linux-64 gxx_linux-64 dpcpp_linux-64
409+
conda create -y -n build_env $CHANNELS gcc_linux-64 gxx_linux-64 dpcpp_linux-64 sysroot_linux-64">=2.28"
412410
- name: Install dpctl
413411
shell: bash -l {0}
414412
run: |
415413
source $CONDA/etc/profile.d/conda.sh
416-
CHANNELS="-c $GITHUB_WORKSPACE/channel -c dppy/label/dev -c intel -c main --override-channels"
414+
CHANNELS="-c $GITHUB_WORKSPACE/channel -c dppy/label/dev -c intel -c conda-forge --override-channels"
417415
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
418416
conda install -n examples -y ${CHANNELS} dpctl=${PACKAGE_VERSION} dpnp">=0.10.1" || exit 1
419417
- name: Build and run examples of pybind11 extensions
@@ -498,7 +496,7 @@ jobs:
498496
runner: [ubuntu-20.04]
499497
continue-on-error: ${{ matrix.experimental }}
500498
env:
501-
CHANNELS: -c intel -c main --override-channels
499+
CHANNELS: -c intel -c conda-forge --override-channels
502500
steps:
503501
- name: Cache array API tests
504502
id: cache-array-api-tests

conda-recipe/bld.bat

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ set "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%"
66
"%PYTHON%" setup.py clean --all
77
set "SKBUILD_ARGS=-G Ninja -- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
88

9-
FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16) DO @(
9+
FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16 17.0.0 17) DO @(
1010
REM set DIR_HINT if directory exists
1111
IF EXIST "%BUILD_PREFIX%\Library\lib\clang\%%V\" (
1212
SET "SYCL_INCLUDE_DIR_HINT=%BUILD_PREFIX%\Library\lib\clang\%%V"
1313
)
1414
)
1515

16-
set "PLATFORM_DIR=%PREFIX%\Library\share\cmake-3.22\Modules\Platform"
16+
set "PATCHED_CMAKE_VERSION=3.26"
17+
set "PLATFORM_DIR=%PREFIX%\Library\share\cmake-%PATCHED_CMAKE_VERSION%\Modules\Platform"
1718
set "FN=Windows-IntelLLVM.cmake"
1819

1920
rem Save the original file, and copy patched file to
@@ -22,7 +23,7 @@ if EXIST "%PLATFORM_DIR%" (
2223
dir "%PLATFORM_DIR%\%FN%"
2324
copy /Y "%PLATFORM_DIR%\%FN%" .
2425
if errorlevel 1 exit 1
25-
copy /Y .github\workflows\Windows-IntelLLVM.cmake "%PLATFORM_DIR%"
26+
copy /Y ".github\workflows\Windows-IntelLLVM_%PATCHED_CMAKE_VERSION%.cmake" "%PLATFORM_DIR%\%FN%"
2627
if errorlevel 1 exit 1
2728
)
2829

@@ -40,6 +41,6 @@ if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
4041

4142
if EXIST "%PLATFORM_DIR%" (
4243
rem copy back
43-
copy /Y "%FN%" "%PLATFORM_DIR%"
44+
copy /Y "%FN%" "%PLATFORM_DIR%\%FN%"
4445
if errorlevel 1 exit 1
4546
)

conda-recipe/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ requirements:
3030
- {{ pin_compatible('numpy', min_pin='x.x', max_pin='x') }}
3131
- {{ pin_compatible('dpcpp-cpp-rt', min_pin='x.x', max_pin='x') }} # [py<=39]
3232
- dpcpp-cpp-rt >=2023.1 # [py>39]
33+
- level-zero # [linux]
3334

3435
test:
3536
requires:

dpctl/tensor/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@
100100
isfinite,
101101
isinf,
102102
isnan,
103+
multiply,
103104
not_equal,
104105
sqrt,
106+
subtract,
105107
)
106108

107109
__all__ = [
@@ -187,6 +189,8 @@
187189
"isfinite",
188190
"sqrt",
189191
"divide",
192+
"multiply",
193+
"subtract",
190194
"equal",
191195
"not_equal",
192196
]

dpctl/tensor/_elementwise_funcs.py

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# B01: ===== ADD (x1, x2)
3535

3636
_add_docstring_ = """
37-
add(x1, x2, order='K')
37+
add(x1, x2, out=None, order='K')
3838
3939
Calculates the sum for each element `x1_i` of the input array `x1` with
4040
the respective element `x2_i` of the input array `x2`.
@@ -94,7 +94,7 @@
9494

9595
# U11: ==== COS (x)
9696
_cos_docstring = """
97-
cos(x, order='K')
97+
cos(x, out=None, order='K')
9898
9999
Computes cosine for each element `x_i` for input array `x`.
100100
"""
@@ -106,7 +106,7 @@
106106

107107
# B08: ==== DIVIDE (x1, x2)
108108
_divide_docstring_ = """
109-
divide(x1, x2, order='K')
109+
divide(x1, x2, out=None, order='K')
110110
111111
Calculates the ratio for each element `x1_i` of the input array `x1` with
112112
the respective element `x2_i` of the input array `x2`.
@@ -128,7 +128,7 @@
128128

129129
# B09: ==== EQUAL (x1, x2)
130130
_equal_docstring_ = """
131-
equal(x1, x2, order='K')
131+
equal(x1, x2, out=None, order='K')
132132
133133
Calculates equality test results for each element `x1_i` of the input array `x1`
134134
with the respective element `x2_i` of the input array `x2`.
@@ -172,6 +172,8 @@
172172

173173
# U17: ==== ISFINITE (x)
174174
_isfinite_docstring_ = """
175+
isfinite(x, out=None, order='K')
176+
175177
Computes if every element of input array is a finite number.
176178
"""
177179

@@ -181,6 +183,8 @@
181183

182184
# U18: ==== ISINF (x)
183185
_isinf_docstring_ = """
186+
isinf(x, out=None, order='K')
187+
184188
Computes if every element of input array is an infinity.
185189
"""
186190

@@ -190,6 +194,8 @@
190194

191195
# U19: ==== ISNAN (x)
192196
_isnan_docstring_ = """
197+
isnan(x, out=None, order='K')
198+
193199
Computes if every element of input array is a NaN.
194200
"""
195201

@@ -231,7 +237,25 @@
231237
# FIXME: implement B18
232238

233239
# B19: ==== MULTIPLY (x1, x2)
234-
# FIXME: implement B19
240+
_multiply_docstring_ = """
241+
multiply(x1, x2, out=None, order='K')
242+
243+
Calculates the product for each element `x1_i` of the input array `x1`
244+
with the respective element `x2_i` of the input array `x2`.
245+
246+
Args:
247+
x1 (usm_ndarray):
248+
First input array, expected to have numeric data type.
249+
x2 (usm_ndarray):
250+
Second input array, also expected to have numeric data type.
251+
Returns:
252+
usm_narray:
253+
an array containing the element-wise products. The data type of
254+
the returned array is determined by the Type Promotion Rules.
255+
"""
256+
multiply = BinaryElementwiseFunc(
257+
"multiply", ti._multiply_result_type, ti._multiply, _multiply_docstring_
258+
)
235259

236260
# U25: ==== NEGATIVE (x)
237261
# FIXME: implement U25
@@ -288,6 +312,8 @@
288312

289313
# U33: ==== SQRT (x)
290314
_sqrt_docstring_ = """
315+
sqrt(x, out=None, order='K')
316+
291317
Computes sqrt for each element `x_i` for input array `x`.
292318
"""
293319

@@ -296,7 +322,26 @@
296322
)
297323

298324
# B23: ==== SUBTRACT (x1, x2)
299-
# FIXME: implement B23
325+
_subtract_docstring_ = """
326+
subtract(x1, x2, out=None, order='K')
327+
328+
Calculates the difference bewteen each element `x1_i` of the input
329+
array `x1` and the respective element `x2_i` of the input array `x2`.
330+
331+
Args:
332+
x1 (usm_ndarray):
333+
First input array, expected to have numeric data type.
334+
x2 (usm_ndarray):
335+
Second input array, also expected to have numeric data type.
336+
Returns:
337+
usm_narray:
338+
an array containing the element-wise differences. The data type
339+
of the returned array is determined by the Type Promotion Rules.
340+
"""
341+
subtract = BinaryElementwiseFunc(
342+
"subtract", ti._subtract_result_type, ti._subtract, _subtract_docstring_
343+
)
344+
300345

301346
# U34: ==== TAN (x)
302347
# FIXME: implement U34

0 commit comments

Comments
 (0)