From: Matthias Maier Date: Thu, 15 Feb 2024 21:54:36 +0000 (-0600) Subject: base/mpi.cc: remove superfluous explicit instantiations of template variable X-Git-Tag: relicensing~35^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=137f99dc486535bd4f2449e5253dd6ea989563be;p=dealii.git base/mpi.cc: remove superfluous explicit instantiations of template variable The `mpi.h` header already contains: ``` template 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. --- diff --git a/source/base/mpi.cc b/source/base/mpi.cc index 39f9b92f87..95aa3021e1 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -99,26 +99,6 @@ namespace Utilities namespace MPI { -#ifdef DEAL_II_WITH_MPI - // Provide definitions of template variables for all valid instantiations. - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type; - template const MPI_Datatype mpi_type_id_for_type>; - template const MPI_Datatype mpi_type_id_for_type>; -#endif - - MinMaxAvg min_max_avg(const double my_value, const MPI_Comm mpi_communicator) {