Skip to content

MPI-5 ABI fix for MPI_THREAD_* constants (noncontiguous) #71

Description

@jeffhammond

MPI never required the thread constants to be a contiguous set, although that happened to be true in MPICH and Open MPI. With the MPI-5 ABI, they will not be contiguous, so the following patch is required to fix Quicksilver.

diff --git a/src/utilsMpi.cc b/src/utilsMpi.cc
index 811d892..d0e51de 100644
--- a/src/utilsMpi.cc
+++ b/src/utilsMpi.cc
@@ -11,13 +11,21 @@
 
 #ifdef HAVE_MPI
 
+static const char* mpiThreadLevelName(int level)
+{
+   if (level == MPI_THREAD_SINGLE)     return "MPI_THREAD_SINGLE";
+   if (level == MPI_THREAD_FUNNELED)   return "MPI_THREAD_FUNNELED";
+   if (level == MPI_THREAD_SERIALIZED) return "MPI_THREAD_SERIALIZED";
+   if (level == MPI_THREAD_MULTIPLE)   return "MPI_THREAD_MULTIPLE";
+
+   return "unknown MPI thread level";
+}
+
 void mpiInit( int *argc, char ***argv)
 {
 
 #ifdef HAVE_OPENMP
    { // limit scope
-      char const* const provided_string[4] = \
-         {"MPI_THREAD_SINGLE","MPI_THREAD_FUNNELED","MPI_THREAD_SERIALIZED","MPI_THREAD_MULTIPLE"};
       int provided, required = MPI_THREAD_FUNNELED;
       
       int err = MPI_Init_thread(argc, argv, required, &provided);
@@ -26,12 +34,12 @@ void mpiInit( int *argc, char ***argv)
       int rank = -1;
       mpiComm_rank(MPI_COMM_WORLD, &rank);
       if (rank == 0)
-         fprintf(stdout,"MPI Initialized         : %s\n", provided_string[provided]); 
+         fprintf(stdout,"MPI Initialized         : %s\n", mpiThreadLevelName(provided));
 
       if ((required > MPI_THREAD_SINGLE) && (required > provided))
       {
          printf("MPI-OpenMP Error.\n\tCode requires %s thread support. MPI library provides %s support.\n",
-                provided_string[required],provided_string[provided]);
+                mpiThreadLevelName(required), mpiThreadLevelName(provided));
          qs_assert(false);
       }
    } // limit scope

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions