Skip to content

Commit ba2452e

Browse files
Merge remote-tracking branch 'origin/master' into gold/2021
2 parents 15e4848 + 521867b commit ba2452e

18 files changed

+2053
-18
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

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ include dpctl/program/_program_api.h
1818
include dpctl/tensor/_usmarray.h
1919
include dpctl/tensor/_usmarray_api.h
2020
recursive-include dpctl/tensor/include *
21+
recursive-include dpctl/tensor/libtensor/include *
2122
include dpctl/tests/input_files/*
2223
include dpctl/tests/*.pyx

cmake/FindDpctl.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ if(NOT Dpctl_FOUND)
4040
OUTPUT_STRIP_TRAILING_WHITESPACE
4141
ERROR_QUIET
4242
)
43-
4443
endif()
4544
endif()
4645

@@ -49,6 +48,12 @@ find_path(Dpctl_INCLUDE_DIR
4948
PATHS "${_dpctl_include_dir}" "${PYTHON_INCLUDE_DIR}"
5049
PATH_SUFFIXES dpctl/include
5150
)
51+
get_filename_component(_dpctl_dir ${_dpctl_include_dir} DIRECTORY)
52+
53+
find_path(Dpctl_TENSOR_INCLUDE_DIR
54+
kernels utils
55+
PATHS "${_dpctl_dir}/tensor/libtensor/include"
56+
)
5257

5358
set(Dpctl_INCLUDE_DIRS ${Dpctl_INCLUDE_DIR})
5459

@@ -57,8 +62,9 @@ set(Dpctl_INCLUDE_DIRS ${Dpctl_INCLUDE_DIR})
5762
include(FindPackageHandleStandardArgs)
5863
find_package_handle_standard_args(Dpctl
5964
REQUIRED_VARS
60-
Dpctl_INCLUDE_DIR
65+
Dpctl_INCLUDE_DIR Dpctl_TENSOR_INCLUDE_DIR
6166
VERSION_VAR Dpctl_VERSION
6267
)
6368

6469
mark_as_advanced(Dpctl_INCLUDE_DIR)
70+
mark_as_advanced(Dpctl_TENSOR_INCLUDE_DIR)

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/__main__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ def print_includes() -> None:
3535
print("-I " + dpctl.get_include())
3636

3737

38+
def print_tensor_includes() -> None:
39+
"Prints include flags for dpctl and SyclInterface library"
40+
dpctl_dir = _dpctl_dir()
41+
libtensor_dir = os.path.join(dpctl_dir, "tensor", "libtensor", "include")
42+
print("-I " + libtensor_dir)
43+
44+
3845
def print_cmake_dir() -> None:
3946
"Prints directory with FindDpctl.cmake"
4047
dpctl_dir = _dpctl_dir()
@@ -75,7 +82,12 @@ def main() -> None:
7582
parser.add_argument(
7683
"--includes",
7784
action="store_true",
78-
help="Include flags dpctl headers.",
85+
help="Include flags for dpctl headers.",
86+
)
87+
parser.add_argument(
88+
"--tensor-includes",
89+
action="store_true",
90+
help="Include flags for dpctl libtensor headers.",
7991
)
8092
parser.add_argument(
8193
"--cmakedir",
@@ -128,6 +140,8 @@ def main() -> None:
128140
return
129141
if args.includes:
130142
print_includes()
143+
if args.tensor_includes:
144+
print_tensor_includes()
131145
if args.cmakedir:
132146
print_cmake_dir()
133147
if args.library:

dpctl/tensor/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pybind11_add_module(${python_module_name} MODULE
4747
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/boolean_reductions.cpp
4848
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/device_support_queries.cpp
4949
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/elementwise_functions.cpp
50+
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/sum_reductions.cpp
5051
)
5152
set(_clang_prefix "")
5253
if (WIN32)

dpctl/tensor/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
sqrt,
105105
subtract,
106106
)
107+
from ._reduction import sum
107108

108109
__all__ = [
109110
"Device",
@@ -191,4 +192,5 @@
191192
"multiply",
192193
"subtract",
193194
"equal",
195+
"sum",
194196
]

0 commit comments

Comments
 (0)