Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
75 changes: 75 additions & 0 deletions dpnp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 0 additions & 10 deletions dpnp/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
79 changes: 4 additions & 75 deletions dpnp/backend/extensions/blas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
77 changes: 3 additions & 74 deletions dpnp/backend/extensions/fft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
85 changes: 5 additions & 80 deletions dpnp/backend/extensions/indexing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Loading
Loading