diff --git a/CMakeLists.txt b/CMakeLists.txt index 4645d6419759..3e089b3503de 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/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..c60af39bf296 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) diff --git a/dpnp/backend/extensions/blas/CMakeLists.txt b/dpnp/backend/extensions/blas/CMakeLists.txt index 872dea406ed3..0980befa0c0a 100644 --- a/dpnp/backend/extensions/blas/CMakeLists.txt +++ b/dpnp/backend/extensions/blas/CMakeLists.txt @@ -36,75 +36,13 @@ 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( +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/blas" + 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_link_libraries(${python_module_name} PRIVATE ${ONEMATH_LIB}) target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMATH) @@ -114,12 +52,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