Commit 98d9fa60 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Pass MPI_Comm by value in C part of library.

parent d40ac915
......@@ -108,20 +108,20 @@ PPM_abort_f(MPI_Fint *comm_f, const char *msg, const char *source, int line)
#else
comm_c = *comm_f;
#endif
PPM_abort(&comm_c, msg, source, line);
PPM_abort(comm_c, msg, source, line);
}
FCALLSCSUB4(PPM_abort_f, PPM_ABORT, ppm_abort, PVOID, STRING,
STRING, INT)
void
PPM_abort_default(MPI_Comm *comm, const char *msg, const char *source, int line)
PPM_abort_default(MPI_Comm comm, const char *msg, const char *source, int line)
{
int flag = 0;
fprintf(stderr, "Fatal error in %s, line %d: %s\n", source, line, msg);
#ifdef USE_MPI
if (MPI_Initialized(&flag) == MPI_SUCCESS && flag)
MPI_Abort(*comm, 1);
MPI_Abort(comm, 1);
else
abort();
#else
......@@ -143,7 +143,7 @@ FCALLSCSUB0(PPM_restore_default_abort_handler, PPM_RESTORE_DEFAULT_ABORT_HNDL,
static void
abort_ppm_handler_wrapper(MPI_Comm *comm, const char msg[],
abort_ppm_handler_wrapper(MPI_Comm comm, const char msg[],
const char source[], int line);
static void
......@@ -163,7 +163,7 @@ PPM_abort_default_f(MPI_Fint *comm_f, const char *msg, const char *source,
#else
MPI_Comm comm_c = *comm_f;
#endif
PPM_abort_default(&comm_c, msg, source, line);
PPM_abort_default(comm_c, msg, source, line);
}
FCALLSCSUB4(PPM_abort_default_f,PPM_ABORT_DEFAULT,ppm_abort_default,
......@@ -191,15 +191,15 @@ set_abort_ppm_handler_f(void *abort_ppm_handler)
}
static void
abort_ppm_handler_wrapper(MPI_Comm *comm, const char msg[],
abort_ppm_handler_wrapper(MPI_Comm comm, const char msg[],
const char source[], int line)
{
#if defined(USE_MPI)
int flag = 0;
MPI_Fint comm_f = (MPI_Initialized(&flag) == MPI_SUCCESS && flag)?
MPI_Comm_c2f(*comm):(MPI_Fint)0;
MPI_Comm_c2f(comm):(MPI_Fint)0;
#else
MPI_Fint comm_f = *comm;
MPI_Fint comm_f = comm;
#endif
/* cfortran.h does not understand const char * */
char *msg_arg = (char *)msg, *source_arg = (char *)source;
......
......@@ -72,7 +72,7 @@ typedef int MPI_Fint;
/**
* functions used as error handler must conform to this interface
*/
typedef void (*PPM_abort_func)(MPI_Comm *comm, const char *msg,
typedef void (*PPM_abort_func)(MPI_Comm comm, const char *msg,
const char *source, int line);
/**
* Unless modified, this function pointer will reference PPM_abort_default.
......@@ -96,7 +96,7 @@ extern MPI_Comm PPM_default_comm;
* @param line line number of caller
*/
extern void
PPM_abort_default(MPI_Comm *comm, const char *msg,
PPM_abort_default(MPI_Comm comm, const char *msg,
const char *source, int line);
/**
......
......@@ -51,9 +51,9 @@ PPM_set_mpi_abort_handler(MPI_Comm comm)
MPI_Errhandler errh;
if (MPI_Comm_create_errhandler((MPI_Comm_errhandler_fn *)abort,
&errh) != MPI_SUCCESS)
PPM_abort(&comm, "Error handler creation failed.", __FILE__, __LINE__);
PPM_abort(comm, "Error handler creation failed.", __FILE__, __LINE__);
if (MPI_Comm_set_errhandler(comm, errh) != MPI_SUCCESS)
PPM_abort(&comm, "Error handler setup failed.", __FILE__, __LINE__);
PPM_abort(comm, "Error handler setup failed.", __FILE__, __LINE__);
}
static void
......
......@@ -99,7 +99,7 @@ fIeeeValue(float x, enum ppm_ieee_class_type v)
snan.u = UINT32_C(0x7f800001);
return snan.f;
#else
PPM_abort(&PPM_default_comm, "unsupported ieee capability requested",
PPM_abort(PPM_default_comm, "unsupported ieee capability requested",
__FILE__, __LINE__);
#endif
case ieee_quiet_nan:
......@@ -132,7 +132,7 @@ fIeeeValue(float x, enum ppm_ieee_class_type v)
return INFINITY;
default:
fprintf(stderr, "v=%d\n", v);
PPM_abort(&PPM_default_comm, "invalid ieee value requested", __FILE__,
PPM_abort(PPM_default_comm, "invalid ieee value requested", __FILE__,
__LINE__);
}
}
......@@ -156,7 +156,7 @@ dIeeeValue(double x, enum ppm_ieee_class_type v)
snan.u = UINT64_C(0x7ff0000000000001);
return snan.f;
#else
PPM_abort(&PPM_default_comm, "unsupported ieee capability requested",
PPM_abort(PPM_default_comm, "unsupported ieee capability requested",
__FILE__, __LINE__);
#endif
case ieee_quiet_nan:
......@@ -189,7 +189,7 @@ dIeeeValue(double x, enum ppm_ieee_class_type v)
return INFINITY;
default:
fprintf(stderr, "v=%d\n", v);
PPM_abort(&PPM_default_comm, "invalid ieee value requested", __FILE__,
PPM_abort(PPM_default_comm, "invalid ieee value requested", __FILE__,
__LINE__);
}
}
......
......@@ -448,7 +448,7 @@ initIRand_f(MPI_Fint *comm_f, int *random_seed)
#else
comm_c = *comm_f;
#endif
*random_seed = PPM_ya_rand_init(&comm_c, *random_seed);
*random_seed = PPM_ya_rand_init(comm_c, *random_seed);
}
FCALLSCSUB2(initIRand_f,PPM_INITIALIZE_IRAND,ppm_initialize_irand,PVOID,PINT)
......
......@@ -144,7 +144,7 @@ PPM_ya_random64(void)
}
unsigned
PPM_ya_rand_init(MPI_Comm *comm, int seed_arg)
PPM_ya_rand_init(MPI_Comm comm, int seed_arg)
{
unsigned seed = (unsigned)seed_arg;
int i, tid;
......
......@@ -26,7 +26,7 @@
uint32_t PPM_ya_random (void);
uint64_t PPM_ya_random64(void);
unsigned int PPM_ya_rand_init(MPI_Comm *comm, int);
unsigned int PPM_ya_rand_init(MPI_Comm comm, int);
#define RAND_MAX 0x7FFFFFFFL
#define random() ((long)PPM_ya_random() & RAND_MAX)
......
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