forked from eth-cscs/DLA-Future
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
217 lines (187 loc) · 7.04 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#
# Distributed Linear Algebra with Future (DLAF)
#
# Copyright (c) 2018-2024, ETH Zurich
# All rights reserved.
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause
#
cmake_minimum_required(VERSION 3.22)
project(DLAF VERSION 0.6.0)
# ---------------------------------------------------------------------------
# CMake configurations
# ---------------------------------------------------------------------------
list(PREPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(CTest)
include(DLAF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build Type" FORCE)
endif()
include(CMakeDependentOption)
set(DLAF_WITH_OPENMP_DESCRIPTION "Enable OpenMP support")
set(DLAF_WITH_OPENMP_DEFAULT ON)
if(APPLE AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"))
set(DLAF_WITH_OPENMP_DEFAULT OFF)
endif()
option(BUILD_SHARED_LIBS "Build shared libraries." ON)
option(DLAF_WITH_OPENMP "${DLAF_WITH_OPENMP_DESCRIPTION}" ${DLAF_WITH_OPENMP_DEFAULT})
option(DLAF_WITH_CUDA "Enable CUDA support" OFF)
option(DLAF_WITH_HIP "Enable HIP support" OFF)
cmake_dependent_option(
DLAF_WITH_MPI_GPU_AWARE "Enable GPU-aware MPI" OFF "DLAF_WITH_CUDA OR DLAF_WITH_HIP" OFF
)
cmake_dependent_option(
DLAF_WITH_MPI_GPU_FORCE_CONTIGUOUS "Force GPU buffers to be contiguous before communicating" ON
"DLAF_WITH_MPI_GPU_AWARE" OFF
)
option(DLAF_WITH_HDF5 "Enable HDF5 support" OFF)
mark_as_advanced(DLAF_WITH_HDF5)
option(DLAF_WITH_COVERAGE "Enable coverage" OFF)
option(DLAF_BUILD_MINIAPPS "Build miniapps" ON)
option(DLAF_BUILD_TESTING "Build tests" ON)
option(DLAF_BUILD_TESTING_HEADER "Build header tests" OFF)
option(DLAF_BUILD_DOC "Build documentation" OFF)
option(DLAF_WITH_PRECOMPILED_HEADERS "Use precompiled headers." OFF)
option(DLAF_WITH_SCALAPACK "Build ScaLAPACK-like C API (requires ScaLAPACK)" OFF)
if(DEFINED CACHE{DLAF_WITH_MKL})
if(DLAF_WITH_MKL)
message(STATUS "Intel MKL support: Enabled by user")
else()
message(STATUS "Intel MKL support: Disabled by user")
endif()
set(DLAF_WITH_MKL_INTERNAL ${DLAF_WITH_MKL} CACHE BOOL "" FORCE)
else()
unset(DLAF_WITH_MKL_TRY_COMPILE CACHE)
try_compile(
DLAF_WITH_MKL_TRY_COMPILE "${PROJECT_BINARY_DIR}/cmake/tests"
"${PROJECT_SOURCE_DIR}/cmake/tests/mkl_set_num_threads.cpp"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${DLAF_LAPACK_INCLUDE_DIR}"
LINK_LIBRARIES ${DLAF_LAPACK_LIBRARY}
)
if(DLAF_WITH_MKL_TRY_COMPILE)
message(STATUS "Intel MKL support: Found")
else()
message(STATUS "Intel MKL support: Not found")
endif()
set(DLAF_WITH_MKL_INTERNAL ${DLAF_WITH_MKL_TRY_COMPILE} CACHE BOOL "" FORCE)
endif()
if(DLAF_WITH_MKL)
# When using MKL there is no need to set the number of threads with
# omp_set_num_threads; it's sufficient to use MKL's own mechanisms.
set(DLAF_WITH_OPENMP OFF CACHE BOOL "${DLAF_WITH_OPENMP_DESCRIPTION}" FORCE)
elseif(NOT DLAF_WITH_OPENMP)
message(
WARNING
"DLAF_WITH_OPENMP is disabled. If you are using a threaded BLAS/LAPACK implementation DLA-Future will not be able to set the number of threads to 1 for BLAS/LAPACK calls. It is your responsibility to ensure that you are either using a sequential BLAS/LAPACK implementation or that you are e.g. setting OMP_NUM_THREADS to 1."
)
endif()
if(BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE "ON" CACHE BOOL "Enable position independent code" FORCE)
endif()
# Add color to ninja output
if(CMAKE_GENERATOR MATCHES "Ninja")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
# ---------------------------------------------------------------------------
# Languages
# ---------------------------------------------------------------------------
# ----- C
enable_language(C)
# ----- CXX
enable_language(CXX)
# ---- CUDA/HIP
if(DLAF_WITH_CUDA AND DLAF_WITH_HIP)
message(FATAL_ERROR "DLAF_WITH_CUDA=ON and DLAF_WITH_HIP=ON. Only one of "
"them can be enabled at the same time."
)
endif()
if(DLAF_WITH_CUDA)
if(NOT CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "60;70;80" CACHE STRING "Cuda architectures" FORCE)
endif()
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
set(DLAF_WITH_GPU ON)
elseif(DLAF_WITH_HIP)
set(CMAKE_HIP_EXTENSIONS OFF)
enable_language(HIP)
find_package(rocblas REQUIRED)
find_package(rocsolver REQUIRED)
set(DLAF_WITH_GPU ON)
endif()
if(DLAF_WITH_GPU)
find_package(whip REQUIRED)
endif()
# ---------------------------------------------------------------------------
# Coverage
# ---------------------------------------------------------------------------
if(DLAF_WITH_COVERAGE)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-O0 -fprofile-arcs -ftest-coverage)
add_link_options(-fprofile-arcs -ftest-coverage)
else()
message(FATAL_ERROR "Coverage can be enabled only for Debug builds")
endif()
endif()
# ---------------------------------------------------------------------------
# Libraries configuration
# ---------------------------------------------------------------------------
# ----- MPI
find_package(MPI REQUIRED)
# ----- OpenMP
if(DLAF_WITH_OPENMP)
find_package(OpenMP REQUIRED)
endif()
find_package(DLAF_LAPACK REQUIRED)
if(DLAF_WITH_SCALAPACK)
find_package(DLAF_SCALAPACK REQUIRED)
endif()
# ----- pika
find_package(pika 0.19.1 REQUIRED)
# ----- BLASPP/LAPACKPP
find_package(blaspp REQUIRED)
find_package(lapackpp REQUIRED)
# ----- UMPIRE
find_package(Umpire REQUIRED)
# ----- HDF5
if(DLAF_WITH_HDF5)
find_package(HDF5 CONFIG REQUIRED COMPONENTS shared CXX)
endif()
# ----- EXTERNAL
add_subdirectory(external)
# ---------------------------------------------------------------------------
# DLAF library
# ---------------------------------------------------------------------------
add_subdirectory(src)
# ---------------------------------------------------------------------------
# mini Apps
# ---------------------------------------------------------------------------
if(DLAF_BUILD_MINIAPPS)
# Create a "do-nothing" DLAFConfig.cmake, and make it usable by find_package
# by adding it in CMAKE_PREFIX_PATH.
# In this way any call to `find_package(DLAF)` is a no-op. Indeed, nothing
# is necessary to be done, since we are in-project and targets are still
# available thanks to manually created aliases for exported targets.
set(FAKE_INSTALL_DIR ${PROJECT_BINARY_DIR}/fake)
file(MAKE_DIRECTORY ${FAKE_INSTALL_DIR})
file(TOUCH ${FAKE_INSTALL_DIR}/DLAFConfig.cmake)
list(PREPEND CMAKE_PREFIX_PATH ${FAKE_INSTALL_DIR})
add_subdirectory(miniapp)
endif()
# ---------------------------------------------------------------------------
# Test
# ---------------------------------------------------------------------------
if(DLAF_BUILD_TESTING)
add_subdirectory(test)
endif()
# ---------------------------------------------------------------------------
# Docs
# ---------------------------------------------------------------------------
if(DLAF_BUILD_DOC)
add_subdirectory(doc)
endif()