]> https://gitweb.dealii.org/ - dealii.git/commit
base/mpi.cc: remove superfluous explicit instantiations of template variable
authorMatthias Maier <tamiko@43-1.org>
Thu, 15 Feb 2024 21:54:36 +0000 (15:54 -0600)
committerMatthias Maier <tamiko@43-1.org>
Thu, 15 Feb 2024 21:54:36 +0000 (15:54 -0600)
commit137f99dc486535bd4f2449e5253dd6ea989563be
tree7baf7b8c66ec1ed1cb58a4a8e612b8ece5dd051d
parent13a8ddbeefc278283e8d2b1961c70156d083848d
base/mpi.cc: remove superfluous explicit instantiations of template variable

The `mpi.h` header already contains:
```
template <typename T>
const MPI_Datatype mpi_type_id_for_type = /* implementation detail */;
```
Meaning, the variable is known fully after including the header.
Furthermore, the `const` qualifier marks the (template) variable as
`static`. I.e., it has internal linkage.

Thus, we must not explicitly instantiate the variables (suggesting
"extern" linkage in all but the `mpi.cc` compilation unit). This
apparently not an issue with OpenMPI because `MPI_Datatype` is a
complex data structure. But it is an issue with mpich where
`MPI_Datatype` is a simple `int` - leading to a segmentation fault when
during program startup.
source/base/mpi.cc

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.