From aafc2c19dfd3ebc43e37ba3f13eda5f790376b1c Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Thu, 15 Feb 2024 15:54:36 -0600 Subject: [PATCH 1/2] 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. --- source/base/mpi.cc | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/source/base/mpi.cc b/source/base/mpi.cc index dab88e2b97..f845845764 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -100,26 +100,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) { -- 2.43.0