-
Notifications
You must be signed in to change notification settings - Fork 30
/
CMakeLists.txt
131 lines (114 loc) · 4.07 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR)
project(dpctl
VERSION 0.18
LANGUAGES CXX
DESCRIPTION "Python interface for XPU programming"
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
# set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)
if (UNIX)
add_link_options("-fuse-ld=lld")
endif()
# Option to generate code coverage report using llvm-cov and lcov.
option(DPCTL_GENERATE_COVERAGE
"Build dpctl with coverage instrumentation"
OFF
)
option(DPCTL_GENERATE_COVERAGE_FOR_PYBIND11_EXTENSIONS
"Build dpctl pybind11 offloading extensions with coverage instrumentation"
OFF
)
option(DPCTL_TARGET_CUDA
"Build DPCTL to target CUDA devices"
OFF
)
set(DPCTL_TARGET_HIP
""
CACHE STRING
"Build DPCTL to target a HIP device architecture"
)
option(DPCTL_WITH_REDIST "Build DPCTL assuming DPC++ redistributable is installed into Python prefix" OFF)
find_package(IntelSYCL REQUIRED PATHS ${CMAKE_SOURCE_DIR}/cmake NO_DEFAULT_PATH)
set(_dpctl_sycl_target_compile_options)
set(_dpctl_sycl_target_link_options)
set(_dpctl_sycl_targets)
set(_dpctl_amd_targets)
if ("x${DPCTL_SYCL_TARGETS}" STREQUAL "x")
if (DPCTL_TARGET_CUDA)
set(_dpctl_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown")
else()
if (DEFINED ENV{DPCTL_TARGET_CUDA})
set(_dpctl_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown")
endif()
endif()
if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x")
set(_dpctl_amd_targets ${DPCTL_TARGET_HIP})
if(_dpctl_sycl_targets)
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,${_dpctl_sycl_targets}")
else()
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown")
endif()
else()
if (DEFINED ENV{DPCTL_TARGET_HIP})
set(_dpctl_amd_targets $ENV{DPCTL_TARGET_HIP})
if(_dpctl_sycl_targets)
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,${_dpctl_sycl_targets}")
else()
set(_dpctl_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown")
endif()
endif()
endif()
else()
set(_dpctl_sycl_targets ${DPCTL_SYCL_TARGETS})
if (NOT "x${DPCTL_TARGET_HIP}" STREQUAL "x")
set(_dpctl_amd_targets ${DPCTL_TARGET_HIP})
else()
if (DEFINED ENV{DPCTL_TARGET_HIP})
set(_dpctl_amd_targets $ENV{DPCTL_TARGET_HIP})
endif()
endif()
endif()
if (_dpctl_sycl_targets)
message(STATUS "Compiling for -fsycl-targets=${_dpctl_sycl_targets}")
list(APPEND _dpctl_sycl_target_compile_options -fsycl-targets=${_dpctl_sycl_targets})
list(APPEND _dpctl_sycl_target_link_options -fsycl-targets=${_dpctl_sycl_targets})
if(_dpctl_amd_targets)
list(APPEND _dpctl_sycl_target_compile_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpctl_amd_targets})
list(APPEND _dpctl_sycl_target_link_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpctl_amd_targets})
endif()
endif()
add_subdirectory(libsyclinterface)
add_library(DpctlCAPI INTERFACE)
target_include_directories(DpctlCAPI INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/dpctl/apis/include)
target_link_libraries(DpctlCAPI INTERFACE DPCTLSyclInterfaceHeaders)
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/dpctl/apis/include/
DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl/include
FILES_MATCHING REGEX "\\.h(pp)?$"
)
# Define CMAKE_INSTALL_xxx: LIBDIR, INCLUDEDIR
include(GNUInstallDirs)
# Fetch pybind11
include(FetchContent)
FetchContent_Declare(
pybind11
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.6.tar.gz
URL_HASH SHA256=e08cb87f4773da97fa7b5f035de8763abc656d87d5773e62f6da0587d1f0ec20
FIND_PACKAGE_ARGS NAMES pybind11
)
FetchContent_MakeAvailable(pybind11)
add_subdirectory(dpctl)
file(GLOB _cmake_scripts ${CMAKE_SOURCE_DIR}/cmake/*.cmake)
install(FILES ${_cmake_scripts}
DESTINATION dpctl/resources/cmake
)
install(FILES
${CMAKE_SOURCE_DIR}/cmake/dpctl-config.cmake
DESTINATION lib/cmake/dpctl
)
if (DPCTL_GENERATE_DOCS)
add_subdirectory(docs)
endif()