diff --git a/.github/workflows/Windows-IntelLLVM_3.26.cmake b/.github/workflows/Windows-IntelLLVM_3.26.cmake deleted file mode 100644 index 7f30420dc83e..000000000000 --- a/.github/workflows/Windows-IntelLLVM_3.26.cmake +++ /dev/null @@ -1,78 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -# This module is shared by multiple languages; use include blocker. -if(__WINDOWS_INTEL_LLVM) - return() -endif() -set(__WINDOWS_INTEL_LLVM 1) - -# Platform/Windows-MSVC adds some linking options icx/ifx do not understand, -# but that need to be passed to the linker. Wrap all the linking options from -# Platform/Windows-MSVC so that the compiler will hand them off to the linker -# without interpreting them. - -# Save original CMAKE_${t}_LINKER_FLAGS_INIT -foreach(t EXE SHARED MODULE STATIC) - set(_saved_cmake_${t}_linker_flags_init ${CMAKE_${t}_LINKER_FLAGS_INIT}) - set(CMAKE_${t}_LINKER_FLAGS_INIT "") -endforeach() -include(Platform/Windows-MSVC) -# Wrap linker flags from Windows-MSVC -set(_IntelLLVM_LINKER_WRAPPER_FLAG "/Qoption,link,") -set(_IntelLLVM_LINKER_WRAPPER_FLAG_SEP ",") -foreach(t EXE SHARED MODULE STATIC) - set(_wrapped_linker_flags "") - foreach(flag ${CMAKE_${t}_LINKER_FLAGS_INIT}) - string(STRIP ${flag} flag) - list(APPEND _wrapped_linker_flags "${_IntelLLVM_LINKER_WRAPPER_FLAG}${flag}") - endforeach() - set(CMAKE_${t}_LINKER_FLAGS_INIT "") - list( - APPEND CMAKE_${t}_LINKER_FLAGS_INIT - ${_saved_cmake_${t}_linker_flags_init} - ${_wrapped_linker_flags} - ) -endforeach() - -macro(__windows_compiler_intel lang) - __windows_compiler_msvc(${lang}) - - set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "${_IntelLLVM_LINKER_WRAPPER_FLAG}") - set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP "${_IntelLLVM_LINKER_WRAPPER_FLAG_SEP}") - set(CMAKE_${lang}_CREATE_WIN32_EXE - "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/subsystem:windows" - ) - set(CMAKE_${lang}_CREATE_CONSOLE_EXE - "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/subsystem:console" - ) - set(CMAKE_LINK_DEF_FILE_FLAG "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/DEF:") - set(CMAKE_LIBRARY_PATH_FLAG "${CMAKE_${lang}_LINKER_WRAPPER_FLAG}/LIBPATH:") - - # Features for LINK_LIBRARY generator expression - if(MSVC_VERSION GREATER "1900") - ## WHOLE_ARCHIVE: Force loading all members of an archive - set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:/WHOLEARCHIVE:") - set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) - endif() - - set(CMAKE_${lang}_LINK_EXECUTABLE - "${_CMAKE_VS_LINK_EXE} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /link /out: /implib: /pdb: /version:.${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}" - ) - set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "${_CMAKE_VS_LINK_DLL} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} -LD -link /out: /implib: /pdb: /version:.${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}" - ) - set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) - if( - NOT "${lang}" STREQUAL "Fortran" - OR CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2022.1 - ) - # The Fortran driver does not support -fuse-ld=llvm-lib before compiler version 2022.1 - set(CMAKE_${lang}_CREATE_STATIC_LIBRARY - " ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} -fuse-ld=llvm-lib -o ${CMAKE_END_TEMP_FILE}" - ) - endif() - - set(CMAKE_DEPFILE_FLAGS_${lang} "-QMD -QMT -QMF ") - set(CMAKE_${lang}_DEPFILE_FORMAT gcc) -endmacro() diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f41dab8fbe4..b0d46b975452 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ # THE POSSIBILITY OF SUCH DAMAGE. # ***************************************************************************** -cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR) +cmake_minimum_required(VERSION 3.27 FATAL_ERROR) project( dpnp diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat index 71d17ef976a3..4fd2b29b4d4a 100644 --- a/conda-recipe/bld.bat +++ b/conda-recipe/bld.bat @@ -16,20 +16,6 @@ FOR %%V IN (17.0.0 17 18.0.0 18 19.0.0 19 20.0.0 20 21.0.0 21 22.0.0 22) DO @( ) ) -set "PATCHED_CMAKE_VERSION=3.26" -set "PLATFORM_DIR=%PREFIX%\Library\share\cmake-%PATCHED_CMAKE_VERSION%\Modules\Platform" -set "FN=Windows-IntelLLVM.cmake" - -rem Save the original file, and copy patched file to -rem fix the issue with IntelLLVM integration with cmake on Windows -if EXIST "%PLATFORM_DIR%" ( - dir "%PLATFORM_DIR%\%FN%" - copy /Y "%PLATFORM_DIR%\%FN%" . - if errorlevel 1 exit 1 - copy /Y ".github\workflows\Windows-IntelLLVM_%PATCHED_CMAKE_VERSION%.cmake" "%PLATFORM_DIR%\%FN%" - if errorlevel 1 exit 1 -) - set "CC=icx" set "CXX=icx" diff --git a/dpnp/CMakeLists.txt b/dpnp/CMakeLists.txt index 5a93c42a6108..b2942cd6a854 100644 --- a/dpnp/CMakeLists.txt +++ b/dpnp/CMakeLists.txt @@ -188,6 +188,81 @@ function(build_dpnp_cython_ext_with_backend _trgt _src _dest) target_link_libraries(${_trgt} PRIVATE dpnp_backend_library) endfunction() +# Builds a pybind11 extension of dpnp/backend/extensions with the options all of +# them share. INCLUDE_DIRS come before the common include directories, and +# LARGE_RANGES is for modules whose kernels can be launched over more than +# INT_MAX work-items. +function(build_dpnp_pybind11_ext _trgt _dest) + cmake_parse_arguments(PARSE_ARGV 2 _arg "LARGE_RANGES" "" "SOURCES;INCLUDE_DIRS") + + pybind11_add_module(${_trgt} MODULE ${_arg_SOURCES}) + add_sycl_to_target(TARGET ${_trgt} SOURCES ${_arg_SOURCES}) + + # Ensure Cython modules build first so _usmarray.h exists + add_dependencies(${_trgt} _usmarray) + + if(_dpnp_sycl_targets) + # make fat binary + target_compile_options(${_trgt} PRIVATE ${_dpnp_sycl_target_compile_options}) + target_link_options(${_trgt} PRIVATE ${_dpnp_sycl_target_link_options}) + endif() + + set_target_properties(${_trgt} PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON) + + target_include_directories( + ${_trgt} + PRIVATE + ${_arg_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/dpnp/include + ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include + ) + + # treat below headers as system to suppress the warnings there during the build + target_include_directories( + ${_trgt} + SYSTEM + PRIVATE + ${SYCL_INCLUDE_DIR} + ${Dpctl_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR} # For generated Cython headers + ) + + if(WIN32) + target_compile_options( + ${_trgt} + PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only + ) + else() + target_compile_options(${_trgt} PRIVATE -fno-approx-func -fno-finite-math-only) + endif() + + if(_arg_LARGE_RANGES) + target_compile_options(${_trgt} PUBLIC -fno-sycl-id-queries-fit-in-int) + endif() + + target_link_options(${_trgt} PUBLIC -fsycl-device-code-split=per_kernel) + if(_arg_LARGE_RANGES) + # DPC++ 2026.2 records the ID range at link time, so pass it there too + target_link_options(${_trgt} PUBLIC -fno-sycl-id-queries-fit-in-int) + endif() + + if(DPNP_GENERATE_COVERAGE) + target_link_options( + ${_trgt} + PRIVATE -fprofile-instr-generate -fcoverage-mapping + ) + endif() + + if(DPNP_WITH_REDIST) + set_target_properties( + ${_trgt} + PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" + ) + endif() + + install(TARGETS ${_trgt} DESTINATION ${_dest}) +endfunction() + add_subdirectory(tensor) add_subdirectory(backend) diff --git a/dpnp/backend/CMakeLists.txt b/dpnp/backend/CMakeLists.txt index bdbdd8075829..5d127451d706 100644 --- a/dpnp/backend/CMakeLists.txt +++ b/dpnp/backend/CMakeLists.txt @@ -41,16 +41,6 @@ set(DPNP_SRC set(_trgt "dpnp_backend_c") -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - add_library(${_trgt} SHARED ${DPNP_SRC}) set_target_properties(${_trgt} PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -111,10 +101,7 @@ target_include_directories( target_link_libraries(dpnp_backend_library INTERFACE ${_trgt}) if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../" - ) + set_target_properties(${_trgt} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../") endif() if(DPNP_BACKEND_TESTS) diff --git a/dpnp/backend/extensions/blas/CMakeLists.txt b/dpnp/backend/extensions/blas/CMakeLists.txt index 15a98512e29a..bb0ca93390e4 100644 --- a/dpnp/backend/extensions/blas/CMakeLists.txt +++ b/dpnp/backend/extensions/blas/CMakeLists.txt @@ -36,79 +36,14 @@ set(_module_src ${CMAKE_CURRENT_SOURCE_DIR}/syrk.cpp ) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(_dpnp_sycl_targets) - # make fat binary - target_compile_options( - ${python_module_name} - PRIVATE ${_dpnp_sycl_target_compile_options} - ) - target_link_options(${python_module_name} PRIVATE ${_dpnp_sycl_target_link_options}) -endif() - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( - ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON -) - -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../common - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( - ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers -) - -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_compile_options(${python_module_name} PUBLIC -fno-sycl-id-queries-fit-in-int) -target_link_options( +build_dpnp_pybind11_ext( ${python_module_name} - PUBLIC -fsycl-device-code-split=per_kernel -fno-sycl-id-queries-fit-in-int + "dpnp/backend/extensions/blas" + SOURCES ${_module_src} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../common + LARGE_RANGES ) -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - if(_use_onemath) target_link_libraries(${python_module_name} PRIVATE ${ONEMATH_LIB}) target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMATH) @@ -118,12 +53,3 @@ if(_use_onemath) else() target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::BLAS) endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/blas") diff --git a/dpnp/backend/extensions/fft/CMakeLists.txt b/dpnp/backend/extensions/fft/CMakeLists.txt index 7c8367b467e6..b663091ff512 100644 --- a/dpnp/backend/extensions/fft/CMakeLists.txt +++ b/dpnp/backend/extensions/fft/CMakeLists.txt @@ -30,86 +30,15 @@ set(python_module_name _fft_impl) set(_module_src ${CMAKE_CURRENT_SOURCE_DIR}/fft_py.cpp) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(_dpnp_sycl_targets) - # make fat binary - target_compile_options( - ${python_module_name} - PRIVATE ${_dpnp_sycl_target_compile_options} - ) - target_link_options(${python_module_name} PRIVATE ${_dpnp_sycl_target_link_options}) -endif() - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( +build_dpnp_pybind11_ext( ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON + "dpnp/backend/extensions/fft" + SOURCES ${_module_src} ) -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( - ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers -) - -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_link_options(${python_module_name} PUBLIC -fsycl-device-code-split=per_kernel) - -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - if(_use_onemath) target_link_libraries(${python_module_name} PRIVATE ${ONEMATH_LIB}) target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMATH) else() target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::DFT) endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/fft") diff --git a/dpnp/backend/extensions/indexing/CMakeLists.txt b/dpnp/backend/extensions/indexing/CMakeLists.txt index e43d3d647529..78957a4b028f 100644 --- a/dpnp/backend/extensions/indexing/CMakeLists.txt +++ b/dpnp/backend/extensions/indexing/CMakeLists.txt @@ -34,85 +34,10 @@ set(_module_src ${CMAKE_CURRENT_SOURCE_DIR}/indexing_py.cpp ) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(_dpnp_sycl_targets) - # make fat binary - target_compile_options( - ${python_module_name} - PRIVATE ${_dpnp_sycl_target_compile_options} - ) - target_link_options(${python_module_name} PRIVATE ${_dpnp_sycl_target_link_options}) -endif() - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( +build_dpnp_pybind11_ext( ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON + "dpnp/backend/extensions/indexing" + SOURCES ${_module_src} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../ ${CMAKE_CURRENT_SOURCE_DIR}/../common + LARGE_RANGES ) - -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../ - ${CMAKE_CURRENT_SOURCE_DIR}/../common - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( - ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers -) - -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_compile_options(${python_module_name} PUBLIC -fno-sycl-id-queries-fit-in-int) -target_link_options( - ${python_module_name} - PUBLIC -fsycl-device-code-split=per_kernel -fno-sycl-id-queries-fit-in-int -) - -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/indexing") diff --git a/dpnp/backend/extensions/lapack/CMakeLists.txt b/dpnp/backend/extensions/lapack/CMakeLists.txt index ecb0c31d391f..b24065c998e1 100644 --- a/dpnp/backend/extensions/lapack/CMakeLists.txt +++ b/dpnp/backend/extensions/lapack/CMakeLists.txt @@ -53,87 +53,16 @@ set(_module_src ${CMAKE_CURRENT_SOURCE_DIR}/ungqr_batch.cpp ) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(_dpnp_sycl_targets) - # make fat binary - target_compile_options( - ${python_module_name} - PRIVATE ${_dpnp_sycl_target_compile_options} - ) - target_link_options(${python_module_name} PRIVATE ${_dpnp_sycl_target_link_options}) -endif() - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( +build_dpnp_pybind11_ext( ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON + "dpnp/backend/extensions/lapack" + SOURCES ${_module_src} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../common ) -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../common - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( - ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers -) - -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_link_options(${python_module_name} PUBLIC -fsycl-device-code-split=per_kernel) - -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - if(_use_onemath) target_link_libraries(${python_module_name} PRIVATE ${ONEMATH_LIB}) target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMATH) else() target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::LAPACK) endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/lapack") diff --git a/dpnp/backend/extensions/sparse/CMakeLists.txt b/dpnp/backend/extensions/sparse/CMakeLists.txt index 7ce0db7eece2..3355b5fe8c0f 100644 --- a/dpnp/backend/extensions/sparse/CMakeLists.txt +++ b/dpnp/backend/extensions/sparse/CMakeLists.txt @@ -33,87 +33,16 @@ set(_module_src ${CMAKE_CURRENT_SOURCE_DIR}/gemv.cpp ) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(_dpnp_sycl_targets) - # make fat binary - target_compile_options( - ${python_module_name} - PRIVATE ${_dpnp_sycl_target_compile_options} - ) - target_link_options(${python_module_name} PRIVATE ${_dpnp_sycl_target_link_options}) -endif() - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( +build_dpnp_pybind11_ext( ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON + "dpnp/backend/extensions/sparse" + SOURCES ${_module_src} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../common ) -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../common - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( - ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers -) - -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_link_options(${python_module_name} PUBLIC -fsycl-device-code-split=per_kernel) - -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - if(_use_onemath) target_link_libraries(${python_module_name} PRIVATE ${ONEMATH_LIB}) target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMATH) else() target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::SPARSE) endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/sparse") diff --git a/dpnp/backend/extensions/statistics/CMakeLists.txt b/dpnp/backend/extensions/statistics/CMakeLists.txt index b273b707059a..088b1e667338 100644 --- a/dpnp/backend/extensions/statistics/CMakeLists.txt +++ b/dpnp/backend/extensions/statistics/CMakeLists.txt @@ -38,85 +38,10 @@ set(_module_src ${CMAKE_CURRENT_SOURCE_DIR}/statistics_py.cpp ) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(_dpnp_sycl_targets) - # make fat binary - target_compile_options( - ${python_module_name} - PRIVATE ${_dpnp_sycl_target_compile_options} - ) - target_link_options(${python_module_name} PRIVATE ${_dpnp_sycl_target_link_options}) -endif() - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( +build_dpnp_pybind11_ext( ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON + "dpnp/backend/extensions/statistics" + SOURCES ${_module_src} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../ ${CMAKE_CURRENT_SOURCE_DIR}/../common + LARGE_RANGES ) - -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../ - ${CMAKE_CURRENT_SOURCE_DIR}/../common - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( - ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers -) - -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_compile_options(${python_module_name} PUBLIC -fno-sycl-id-queries-fit-in-int) -target_link_options( - ${python_module_name} - PUBLIC -fsycl-device-code-split=per_kernel -fno-sycl-id-queries-fit-in-int -) - -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/statistics") diff --git a/dpnp/backend/extensions/ufunc/CMakeLists.txt b/dpnp/backend/extensions/ufunc/CMakeLists.txt index ce7a9506ad55..7f1059bcdc85 100644 --- a/dpnp/backend/extensions/ufunc/CMakeLists.txt +++ b/dpnp/backend/extensions/ufunc/CMakeLists.txt @@ -64,85 +64,10 @@ set(_module_src ${_elementwise_sources} ) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( - ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON -) - -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../ - ${CMAKE_CURRENT_SOURCE_DIR}/../common - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( +build_dpnp_pybind11_ext( ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers + "dpnp/backend/extensions/ufunc" + SOURCES ${_module_src} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../ ${CMAKE_CURRENT_SOURCE_DIR}/../common + LARGE_RANGES ) - -if(_dpnp_sycl_targets) - # make fat binary - target_compile_options( - ${python_module_name} - PRIVATE ${_dpnp_sycl_target_compile_options} - ) - target_link_options(${python_module_name} PRIVATE ${_dpnp_sycl_target_link_options}) -endif() - -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_compile_options(${python_module_name} PUBLIC -fno-sycl-id-queries-fit-in-int) -target_link_options( - ${python_module_name} - PUBLIC -fsycl-device-code-split=per_kernel -fno-sycl-id-queries-fit-in-int -) - -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/ufunc") diff --git a/dpnp/backend/extensions/vm/CMakeLists.txt b/dpnp/backend/extensions/vm/CMakeLists.txt index 5c58136744d7..082d23c0d54d 100644 --- a/dpnp/backend/extensions/vm/CMakeLists.txt +++ b/dpnp/backend/extensions/vm/CMakeLists.txt @@ -87,77 +87,15 @@ set(_module_src set(python_module_name _vm_impl) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( - ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON -) - -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../common - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( +build_dpnp_pybind11_ext( ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers + "dpnp/backend/extensions/vm" + SOURCES ${_module_src} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../common ) -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_link_options(${python_module_name} PUBLIC -fsycl-device-code-split=per_kernel) - -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - if(_use_onemath) target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMATH) else() target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::VM) endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/vm") diff --git a/dpnp/backend/extensions/window/CMakeLists.txt b/dpnp/backend/extensions/window/CMakeLists.txt index d96160cf74a2..f25e9464ac57 100644 --- a/dpnp/backend/extensions/window/CMakeLists.txt +++ b/dpnp/backend/extensions/window/CMakeLists.txt @@ -33,85 +33,10 @@ set(_module_src ${CMAKE_CURRENT_SOURCE_DIR}/window_py.cpp ) -pybind11_add_module(${python_module_name} MODULE ${_module_src}) -add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) - -# Ensure Cython modules build first so _usmarray.h exists -add_dependencies(${python_module_name} _usmarray) - -if(_dpnp_sycl_targets) - # make fat binary - target_compile_options( - ${python_module_name} - PRIVATE ${_dpnp_sycl_target_compile_options} - ) - target_link_options(${python_module_name} PRIVATE ${_dpnp_sycl_target_link_options}) -endif() - -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - -set_target_properties( +build_dpnp_pybind11_ext( ${python_module_name} - PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON + "dpnp/backend/extensions/window" + SOURCES ${_module_src} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../ ${CMAKE_CURRENT_SOURCE_DIR}/../common + LARGE_RANGES ) - -target_include_directories( - ${python_module_name} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../ - ${CMAKE_CURRENT_SOURCE_DIR}/../common - ${CMAKE_SOURCE_DIR}/dpnp/include - ${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include -) - -# treat below headers as system to suppress the warnings there during the build -target_include_directories( - ${python_module_name} - SYSTEM - PRIVATE - ${SYCL_INCLUDE_DIR} - ${Dpctl_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} # For generated Cython headers -) - -if(WIN32) - target_compile_options( - ${python_module_name} - PRIVATE /clang:-fno-approx-func /clang:-fno-finite-math-only - ) -else() - target_compile_options( - ${python_module_name} - PRIVATE -fno-approx-func -fno-finite-math-only - ) -endif() - -target_compile_options(${python_module_name} PUBLIC -fno-sycl-id-queries-fit-in-int) -target_link_options( - ${python_module_name} - PUBLIC -fsycl-device-code-split=per_kernel -fno-sycl-id-queries-fit-in-int -) - -if(DPNP_GENERATE_COVERAGE) - target_link_options( - ${python_module_name} - PRIVATE -fprofile-instr-generate -fcoverage-mapping - ) -endif() - -if(DPNP_WITH_REDIST) - set_target_properties( - ${python_module_name} - PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../" - ) -endif() - -install(TARGETS ${python_module_name} DESTINATION "dpnp/backend/extensions/window") diff --git a/dpnp/tensor/CMakeLists.txt b/dpnp/tensor/CMakeLists.txt index 67fa250ef630..4ec0bada6104 100644 --- a/dpnp/tensor/CMakeLists.txt +++ b/dpnp/tensor/CMakeLists.txt @@ -80,16 +80,6 @@ foreach(_cy_file ${_cython_sources}) ) endforeach() -if(WIN32) - if(${CMAKE_VERSION} VERSION_LESS "3.27") - # this is a work-around for target_link_options inserting option after -link option, cause - # linker to ignore it. - set(CMAKE_CXX_LINK_FLAGS - "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel" - ) - endif() -endif() - # TODO: reuse this library for dpnp ufunc extension build set(_static_lib_sources ${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/simplify_iteration_space.cpp