|
| 1 | +# ***************************************************************************** |
| 2 | +# Copyright (c) 2016-2024, Intel Corporation |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# Redistribution and use in source and binary forms, with or without |
| 6 | +# modification, are permitted provided that the following conditions are met: |
| 7 | +# - Redistributions of source code must retain the above copyright notice, |
| 8 | +# this list of conditions and the following disclaimer. |
| 9 | +# - Redistributions in binary form must reproduce the above copyright notice, |
| 10 | +# this list of conditions and the following disclaimer in the documentation |
| 11 | +# and/or other materials provided with the distribution. |
| 12 | +# |
| 13 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 14 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 16 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 17 | +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | +# THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | +# ***************************************************************************** |
| 25 | + |
| 26 | + |
| 27 | +set(python_module_name _indexing_impl) |
| 28 | +set(_module_src |
| 29 | + ${CMAKE_CURRENT_SOURCE_DIR}/choose.cpp |
| 30 | + ${CMAKE_CURRENT_SOURCE_DIR}/indexing_py.cpp |
| 31 | +) |
| 32 | + |
| 33 | +pybind11_add_module(${python_module_name} MODULE ${_module_src}) |
| 34 | +add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src}) |
| 35 | + |
| 36 | +if(_dpnp_sycl_targets) |
| 37 | + # make fat binary |
| 38 | + target_compile_options( |
| 39 | + ${python_module_name} |
| 40 | + PRIVATE |
| 41 | + -fsycl-targets=${_dpnp_sycl_targets} |
| 42 | + ) |
| 43 | + target_link_options( |
| 44 | + ${python_module_name} |
| 45 | + PRIVATE |
| 46 | + -fsycl-targets=${_dpnp_sycl_targets} |
| 47 | + ) |
| 48 | +endif() |
| 49 | + |
| 50 | +if (WIN32) |
| 51 | + if (${CMAKE_VERSION} VERSION_LESS "3.27") |
| 52 | + # this is a work-around for target_link_options inserting option after -link option, cause |
| 53 | + # linker to ignore it. |
| 54 | + set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel") |
| 55 | + endif() |
| 56 | +endif() |
| 57 | + |
| 58 | +set_target_properties(${python_module_name} PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 59 | + |
| 60 | +target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) |
| 61 | +target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../src) |
| 62 | + |
| 63 | +target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIR}) |
| 64 | +target_include_directories(${python_module_name} PUBLIC ${Dpctl_TENSOR_INCLUDE_DIR}) |
| 65 | + |
| 66 | +if (WIN32) |
| 67 | + target_compile_options(${python_module_name} PRIVATE |
| 68 | + /clang:-fno-approx-func |
| 69 | + /clang:-fno-finite-math-only |
| 70 | + ) |
| 71 | +else() |
| 72 | + target_compile_options(${python_module_name} PRIVATE |
| 73 | + -fno-approx-func |
| 74 | + -fno-finite-math-only |
| 75 | + ) |
| 76 | +endif() |
| 77 | + |
| 78 | +target_link_options(${python_module_name} PUBLIC -fsycl-device-code-split=per_kernel) |
| 79 | + |
| 80 | +if (DPNP_GENERATE_COVERAGE) |
| 81 | + target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping) |
| 82 | +endif() |
| 83 | + |
| 84 | +if (DPNP_WITH_REDIST) |
| 85 | + set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../") |
| 86 | +endif() |
| 87 | + |
| 88 | +install(TARGETS ${python_module_name} |
| 89 | + DESTINATION "dpnp/backend/extensions/indexing" |
| 90 | +) |
0 commit comments