-
Notifications
You must be signed in to change notification settings - Fork 707
/
configure_20_trilinos.cmake
502 lines (451 loc) · 17.7 KB
/
configure_20_trilinos.cmake
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
## ------------------------------------------------------------------------
##
## SPDX-License-Identifier: LGPL-2.1-or-later
## Copyright (C) 2012 - 2024 by the deal.II authors
##
## This file is part of the deal.II library.
##
## Part of the source code is dual licensed under Apache-2.0 WITH
## LLVM-exception OR LGPL-2.1-or-later. Detailed license information
## governing the source code and code contributions can be found in
## LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
##
## ------------------------------------------------------------------------
#
# Configuration for the trilinos library:
#
set(FEATURE_TRILINOS_DEPENDS MPI)
#
# A list of optional Trilinos modules we use:
#
set(_deal_ii_trilinos_optional_modules
Amesos2 Belos EpetraExt Kokkos MueLu NOX ROL Sacado SEACAS Tpetra Zoltan
)
#
# A list of optional Trilinos TPLs we use:
#
set(_deal_ii_trilinos_optional_tpls MUMPS)
macro(feature_trilinos_find_external var)
find_package(DEAL_II_TRILINOS)
if(TRILINOS_FOUND)
#
# So, we have a library. Let's see whether we can use it:
#
set(${var} TRUE)
#
# Set TRILINOS_DIR to something meaningful if empty
#
if("${TRILINOS_DIR}" STREQUAL "")
set(TRILINOS_DIR "<system location>")
endif()
#
# Check whether all required modules of trilinos are installed:
#
message(STATUS
"Checking whether the found trilinos package contains all required modules:"
)
foreach(_module
Amesos Epetra Ifpack AztecOO Teuchos ML
)
item_matches(_module_found ${_module} ${Trilinos_PACKAGE_LIST})
if(_module_found)
message(STATUS " Found ${_module}")
else()
message(STATUS " Module ${_module} not found!")
set(_modules_missing "${_modules_missing} ${_module}")
set(${var} FALSE)
endif()
endforeach()
if(NOT ${var})
message(STATUS "Could not find a sufficient Trilinos installation: "
"Missing ${_modules_missing}"
)
set(TRILINOS_ADDITIONAL_ERROR_STRING
"The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
"is missing one or more modules necessary for the deal.II Trilinos interfaces:\n"
" ${_modules_missing}\n\n"
"Please re-install Trilinos with the missing Trilinos subpackages enabled.\n\n"
)
endif()
#
# We require at least Trilinos 12.4
#
if(TRILINOS_VERSION VERSION_LESS 12.4)
message(STATUS "Could not find a sufficient Trilinos installation: "
"deal.II requires at least version 12.4, but version ${TRILINOS_VERSION} was found."
)
set(TRILINOS_ADDITIONAL_ERROR_STRING
${TRILINOS_ADDITIONAL_ERROR_STRING}
"The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
"with version ${TRILINOS_VERSION} is too old.\n"
"deal.II requires at least version 12.4.\n\n"
)
set(${var} FALSE)
endif()
#
# Trilinos has to be configured with the same MPI configuration as
# deal.II.
#
if(NOT TRILINOS_WITH_MPI)
message(STATUS "Could not find a sufficient Trilinos installation: "
"Trilinos has to have MPI support enabled."
)
set(TRILINOS_ADDITIONAL_ERROR_STRING
${TRILINOS_ADDITIONAL_ERROR_STRING}
"The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
"has to be configured with MPI support, but found:\n"
" TRILINOS_WITH_MPI = ${TRILINOS_WITH_MPI}\n"
)
set(${var} FALSE)
endif()
#
# Trilinos has to be configured with 32bit indices if deal.II uses
# unsigned int.
#
if(TRILINOS_WITH_NO_32BIT_INDICES AND NOT DEAL_II_WITH_64BIT_INDICES)
message(STATUS "Could not find a sufficient Trilinos installation: "
"deal.II was configured to use 32bit global indices but "
"Trilinos was not."
)
set(TRILINOS_ADDITIONAL_ERROR_STRING
${TRILINOS_ADDITIONAL_ERROR_STRING}
"The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
"has to be configured to use the same number of bits as deal.II, but "
"found:\n"
" DEAL_II_WITH_64BIT_INDICES = ${DEAL_II_WITH_64BIT_INDICES}\n"
" TRILINOS_WITH_NO_32BIT_INDICES = ${TRILINOS_WITH_NO_32_BIT_INDICES}\n"
)
set(${var} FALSE)
endif()
#
# Trilinos has to be configured with 64bit indices if deal.II uses
# unsigned long long int.
#
if(TRILINOS_WITH_NO_64BIT_INDICES AND DEAL_II_WITH_64BIT_INDICES)
message(STATUS "Could not find a sufficient Trilinos installation: "
"deal.II was configured to use 64bit global indices but "
"Trilinos was not."
)
set(TRILINOS_ADDITIONAL_ERROR_STRING
${TRILINOS_ADDITIONAL_ERROR_STRING}
"The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
"has to be configured to use the same number of bits as deal.II, but "
"found:\n"
" DEAL_II_WITH_64BIT_INDICES = ${DEAL_II_WITH_64BIT_INDICES}\n"
" TRILINOS_WITH_NO_64BIT_INDICES = ${TRILINOS_WITH_NO_64_BIT_INDICES}\n"
)
set(${var} FALSE)
endif()
check_mpi_interface(TRILINOS ${var})
#
# Check which optional features of trilinos are installed.
#
if(${var})
#
# Check for modules.
#
foreach(_optional_module ${_deal_ii_trilinos_optional_modules})
item_matches(_module_found ${_optional_module} ${Trilinos_PACKAGE_LIST})
if(_module_found)
message(STATUS " Found ${_optional_module}")
string(TOUPPER "${_optional_module}" _optional_module_upper)
set(TRILINOS_WITH_${_optional_module_upper} ON)
else()
message(STATUS " Module ${_optional_module} not found!")
endif()
endforeach()
#
# Check for third-party libraries (tpl).
#
foreach(_optional_tpl ${_deal_ii_trilinos_optional_tpls})
item_matches(_tpl_found ${_optional_tpl} ${Trilinos_TPL_LIST})
if(_tpl_found)
message(STATUS " Found ${_optional_tpl}")
string(TOUPPER "${_optional_tpl}" _optional_tpl_upper)
set(TRILINOS_WITH_${_optional_tpl_upper} ON)
else()
message(STATUS " Module ${_optional_tpl} not found!")
endif()
endforeach()
endif()
if(TRILINOS_WITH_KOKKOS)
if(DEAL_II_FORCE_BUNDLED_KOKKOS)
set(TRILINOS_ADDITIONAL_ERROR_STRING
${TRILINOS_ADDITIONAL_ERROR_STRING}
"The Trilinos installation (found at \"${TRILINOS_DIR}\")"
"includes Kokkos, but DEAL_II_FORCE_BUNDLED_KOKKOS=ON!\n")
set(${var} FALSE)
endif()
#
# We require at least Trilinos 12.14.1
#
if(TRILINOS_VERSION VERSION_LESS 12.14.1)
message(STATUS "Could not find a sufficient Trilinos installation: "
"deal.II requires at least version 12.14.1 if the Trilinos installation includes Kokkos, "
"but version ${TRILINOS_VERSION} was found."
)
set(TRILINOS_ADDITIONAL_ERROR_STRING
${TRILINOS_ADDITIONAL_ERROR_STRING}
"The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
"with version ${TRILINOS_VERSION} is too old.\n"
"deal.II requires at least version 12.14.1 if the Trilinos installation includes Kokkos.\n\n"
)
set(${var} FALSE)
endif()
endif()
if(TRILINOS_WITH_KOKKOS AND Kokkos_ENABLE_CUDA)
# We need to disable SIMD vectorization for CUDA device code.
# Otherwise, nvcc compilers from version 9 on will emit an error message like:
# "[...] contains a vector, which is not supported in device code". We
# would like to set the variable in check_01_cpu_feature but at that point
# we don't know if CUDA support is enabled in Kokkos
set(DEAL_II_VECTORIZATION_WIDTH_IN_BITS 0)
KOKKOS_CHECK(OPTIONS CUDA_LAMBDA)
endif()
if(TRILINOS_WITH_TPETRA)
#
# Check if Tpetra is usable in fact.
#
list(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES ${MPI_CXX_INCLUDE_PATH})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${Trilinos_LIBRARIES} ${MPI_LIBRARIES})
list(APPEND CMAKE_REQUIRED_FLAGS ${TRILINOS_CXX_FLAGS})
# For the case of Trilinos being compiled with openmp support the
# following Tpetra test needs -fopenmp to succeed. Make sure that we
# supply the correct compiler and linker flags:
add_flags(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_LINKER_FLAGS}")
if(DEAL_II_WITH_64BIT_INDICES)
set(_global_index_type "long long")
else()
set(_global_index_type "int")
endif()
CHECK_CXX_SOURCE_COMPILES(
"
#include <cstdint>
#include <Tpetra_Vector.hpp>
int main()
{
using LO = int;
using GO = ${_global_index_type};
using map_type = Tpetra::Map<LO, GO>;
Teuchos::RCP<const map_type> dummy_map = Teuchos::rcp(new map_type());
Tpetra::Vector<double, LO, GO> dummy_vector(dummy_map);
(void)dummy_vector;
return 0;
}
"
TRILINOS_TPETRA_IS_FUNCTIONAL
)
if(TRILINOS_TPETRA_IS_FUNCTIONAL)
check_cxx_symbol_exists(HAVE_TPETRA_INST_FLOAT "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INST_FLOAT)
check_cxx_symbol_exists(HAVE_TPETRA_INST_DOUBLE "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INST_DOUBLE)
check_cxx_symbol_exists(HAVE_TPETRA_INST_COMPLEX_FLOAT "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INST_COMPLEX_FLOAT)
check_cxx_symbol_exists(HAVE_TPETRA_INST_COMPLEX_DOUBLE "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INST_COMPLEX_DOUBLE)
else()
message(
STATUS
"Tpetra was found but is not usable! Disabling Tpetra support and searching for common errors."
)
set(TRILINOS_WITH_TPETRA OFF)
check_cxx_symbol_exists(HAVE_TPETRA_INT_INT "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INT_INT)
check_cxx_symbol_exists(HAVE_TPETRA_INT_LONG "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INT_LONG)
check_cxx_symbol_exists(HAVE_TPETRA_INT_LONG_LONG "TpetraCore_config.h" DEAL_II_HAVE_TPETRA_INT_LONG_LONG)
if(NOT DEAL_II_HAVE_TPETRA_INT_LONG_LONG AND DEAL_II_WITH_64BIT_INDICES)
message(
STATUS
" Tpetra wasn't configured with support for 64-bit global indices\n"
" but deal.II is configured to use 64-bit global indices.\n"
" Either reconfigure deal.II with -DDEAL_II_WITH_64BIT_INDICES=OFF\n"
" or rebuild Trilinos with -DTpetra_INST_INT_LONG_LONG=ON"
)
if(DEAL_II_HAVE_TPETRA_INT_LONG)
message(
STATUS
" and -DTpetra_INST_INT_LONG=OFF."
)
elseif(DEAL_II_HAVE_TPETRA_INT_INT)
message(
STATUS
" and -DTpetra_INST_INT_INT=OFF."
)
endif()
elseif(NOT DEAL_II_HAVE_TPETRA_INT_INT AND NOT DEAL_II_WITH_64BIT_INDICES)
message(
STATUS
" Tpetra wasn't configured with support for 32-bit global indices\n"
" but deal.II is configured to use 32-bit global indices.\n"
" Either reconfigure deal.II with -DDEAL_II_WITH_64BIT_INDICES=ON\n"
" or rebuild Trilinos with -DTpetra_INST_INT_INT=ON"
)
if(DEAL_II_HAVE_TPETRA_INT_LONG)
message(
STATUS
" and -DTpetra_INST_INT_LONG=OFF."
)
elseif(DEAL_II_HAVE_TPETRA_INT_LONG_LONG)
message(
STATUS
" and -DTpetra_INST_INT_LONG_LONG=OFF."
)
endif()
endif()
reset_cmake_required()
endif()
endif()
if(TRILINOS_WITH_MUELU)
#
# Check if MueLu is actually usable.
#
list(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES ${MPI_CXX_INCLUDE_PATH})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${Trilinos_LIBRARIES} ${MPI_LIBRARIES})
list(APPEND CMAKE_REQUIRED_FLAGS ${TRILINOS_CXX_FLAGS})
CHECK_CXX_SOURCE_COMPILES(
"
#include <MueLu_CreateEpetraPreconditioner.hpp>
int
main()
{
Epetra_CrsMatrix *matrix;
const auto teuchos_wrapped_matrix = Teuchos::rcp(matrix, false);
Teuchos::ParameterList parameters;
MueLu::CreateEpetraPreconditioner(teuchos_wrapped_matrix, parameters);
return 0;
}
"
TRILINOS_MUELU_IS_FUNCTIONAL
)
reset_cmake_required()
if(NOT TRILINOS_MUELU_IS_FUNCTIONAL)
message(
STATUS
"MueLu was found but is not usable through Epetra! Disabling MueLu support."
)
set(TRILINOS_WITH_MUELU OFF)
endif()
endif()
# the only thing we use from SEACAS right now is ExodusII, so just check
# that it works
if(${TRILINOS_WITH_SEACAS})
list(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${Trilinos_LIBRARIES})
CHECK_CXX_SOURCE_COMPILES(
"
#include <exodusII.h>
int
main()
{
int component_word_size = sizeof(double);
int floating_point_word_size = 0;
float ex_version = 0;
const int ex_id = ex_open(\"test.ex\",
EX_READ,
&component_word_size,
&floating_point_word_size,
&ex_version);
ex_close(ex_id);
return 0;
}
"
TRILINOS_SEACAS_IS_FUNCTIONAL
)
reset_cmake_required()
if(NOT TRILINOS_SEACAS_IS_FUNCTIONAL)
message(
STATUS
"SEACAS was found but doesn't seem to include ExodusII. Disabling SEACAS support."
)
set(TRILINOS_WITH_SEACAS OFF)
endif()
endif()
if(${TRILINOS_WITH_SACADO})
#
# GCC 6.3.0 has a bug that prevents the creation of complex
# numbers templated on Sacado::Rad::ADvar types:
#
# include/c++/6.3.0/complex: In instantiation of
# ‘struct std::complex<Sacado::Rad::ADvar<double> >’:
# include/c++/6.3.0/complex:206:16: error: ‘std::complex<_Tp>& std::complex<_Tp>::operator=(const std::complex<_Tp>&) [with _Tp = Sacado::Rad::ADvar<double>]’ declared to take const reference, but implicit declaration would take non-const
#
# Test whether the compiler hits this issue
#
deal_ii_find_file(SACADO_TRAD_HPP Sacado_trad.hpp
HINTS ${Trilinos_INCLUDE_DIRS}
NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH
)
if(EXISTS ${SACADO_TRAD_HPP})
list(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
CHECK_CXX_SOURCE_COMPILES(
"
#include <Sacado_trad.hpp>
#include <complex>
int main ()
{
Sacado::Rad::ADvar<double> sacado_rad_double; // Works
std::complex<Sacado::Rad::ADvar<double> > complex_sacado_rad_double; // Doesn't work
return 0;
}
"
TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD
)
reset_cmake_required()
endif()
endif()
endif()
endmacro()
macro(feature_trilinos_configure_external)
#
# Propagate optional Trilinos modules and TPLs into DEAL_II namespace:
#
foreach(_module ${_deal_ii_trilinos_optional_modules} ${_deal_ii_trilinos_optional_tpls})
string(TOUPPER "${_module}" _module_upper)
if(${TRILINOS_WITH_${_module_upper}})
set(DEAL_II_TRILINOS_WITH_${_module_upper} ON)
endif()
endforeach()
#
# Figure out all the possible instantiations we need:
#
set(DEAL_II_EXPAND_TRILINOS_SPARSITY_PATTERN "TrilinosWrappers::SparsityPattern")
set(DEAL_II_EXPAND_TRILINOS_BLOCK_SPARSITY_PATTERN "TrilinosWrappers::BlockSparsityPattern")
set(DEAL_II_EXPAND_TRILINOS_SPARSE_MATRICES "TrilinosWrappers::SparseMatrix" "TrilinosWrappers::BlockSparseMatrix")
set(DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR "TrilinosWrappers::MPI::BlockVector")
set(DEAL_II_EXPAND_TRILINOS_MPI_VECTOR "TrilinosWrappers::MPI::Vector")
set(DEAL_II_EXPAND_EPETRA_VECTOR "LinearAlgebra::EpetraWrappers::Vector")
if(${DEAL_II_TRILINOS_WITH_TPETRA})
if(DEAL_II_HAVE_TPETRA_INST_DOUBLE)
set(DEAL_II_EXPAND_TPETRA_TYPES "double")
set(DEAL_II_EXPAND_TPETRA_VECTOR_DOUBLE "LinearAlgebra::TpetraWrappers::Vector<double>")
endif()
if(DEAL_II_HAVE_TPETRA_INST_FLOAT)
set(DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT "LinearAlgebra::TpetraWrappers::Vector<float>")
endif()
if(${DEAL_II_WITH_COMPLEX_NUMBERS})
if(DEAL_II_HAVE_TPETRA_INST_COMPLEX_DOUBLE)
set(DEAL_II_EXPAND_TPETRA_VECTOR_COMPLEX_DOUBLE "LinearAlgebra::TpetraWrappers::Vector<std::complex<double>>")
endif()
if(DEAL_II_HAVE_TPETRA_INST_COMPLEX_FLOAT)
set(DEAL_II_EXPAND_TPETRA_VECTOR_COMPLEX_FLOAT "LinearAlgebra::TpetraWrappers::Vector<std::complex<float>>")
endif()
endif()
endif()
if(${DEAL_II_TRILINOS_WITH_SACADO})
set(DEAL_II_EXPAND_TRILINOS_SACADO_TYPES_FAD
"Sacado::Fad::DFad<double>"
"Sacado::Fad::DFad<float>"
"Sacado::Fad::DFad<Sacado::Fad::DFad<double>>"
"Sacado::Fad::DFad<Sacado::Fad::DFad<float>>"
)
set(DEAL_II_EXPAND_TRILINOS_SACADO_TYPES_RAD
"Sacado::Rad::ADvar<double>"
"Sacado::Rad::ADvar<float>"
"Sacado::Rad::ADvar<Sacado::Fad::DFad<double>>"
"Sacado::Rad::ADvar<Sacado::Fad::DFad<float>>"
)
if(TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD)
set(DEAL_II_TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD ${TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD})
endif()
endif()
endmacro()
configure_feature(TRILINOS)