Commit 68f35fae authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add protection for threaded calls to MPI_Initialized.

* This is a problem on IBM PE only, and thus only used on systems where
  __xlC__ and _AIX are set.
parent e80810fe
......@@ -66,7 +66,11 @@ SymPrefix(set_default_comm_f)(MPI_Fint *comm_f)
{
#if defined(USE_MPI)
int flag = 0;
MPI_Comm comm_c = (MPI_Initialized(&flag) == MPI_SUCCESS && flag)?
MPI_Comm comm_c;
#if defined (__xlC__) && defined (_AIX)
#pragma omp critical
#endif
comm_c = (MPI_Initialized(&flag) == MPI_SUCCESS && flag)?
MPI_Comm_f2c(*comm_f):SymPrefix(default_comm);
#else
MPI_Comm comm_c = *comm_f;
......@@ -85,6 +89,9 @@ SymPrefix(abort_f)(MPI_Fint *comm_f, const char *msg,
MPI_Comm comm_c = MPI_COMM_NULL;
#if defined(USE_MPI)
int flag = 0;
#if defined (__xlC__) && defined (_AIX)
#pragma omp critical
#endif
if (MPI_Initialized(&flag) == MPI_SUCCESS && flag)
comm_c = MPI_Comm_f2c(*comm_f);
#else
......@@ -102,6 +109,9 @@ SymPrefix(abort_default)(MPI_Comm comm, const char *msg, const char *source, int
int flag = 0;
fprintf(stderr, "Fatal error in %s, line %d: %s\n", source, line, msg);
#ifdef USE_MPI
#if defined (__xlC__) && defined (_AIX)
#pragma omp critical
#endif
if (MPI_Initialized(&flag) == MPI_SUCCESS && flag)
MPI_Abort(comm, 1);
else
......
......@@ -118,7 +118,11 @@ abort_ppm_handler_wrapper(MPI_Comm comm, const char msg[],
{
#if defined(USE_MPI)
int flag = 0;
MPI_Fint comm_f = (MPI_Initialized(&flag) == MPI_SUCCESS && flag)?
MPI_Fint comm_f;
#if defined (__xlC__) && defined (_AIX)
#pragma omp critical
#endif
comm_f = (MPI_Initialized(&flag) == MPI_SUCCESS && flag)?
MPI_Comm_c2f(comm):(MPI_Fint)0;
#else
MPI_Fint comm_f = comm;
......
......@@ -360,6 +360,9 @@ initIRand_f(MPI_Fint *comm_f, int *random_seed)
MPI_Comm comm_c = MPI_COMM_NULL;
#if defined(USE_MPI)
int flag = 0;
#if defined (__xlC__) && defined (_AIX)
#pragma omp critical
#endif
if (MPI_Initialized(&flag) == MPI_SUCCESS && flag)
comm_c = MPI_Comm_f2c((MPI_Fint)*comm_f);
#else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment