Skip to content

Instantly share code, notes, and snippets.

@jsquyres
Last active November 15, 2015 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsquyres/79cfeb3666476c0ed1c8 to your computer and use it in GitHub Desktop.
Save jsquyres/79cfeb3666476c0ed1c8 to your computer and use it in GitHub Desktop.
2015-12 December MPI Forum slides: sessions
void legacy_library_init(void) {
MPI_Initialized(&init);
MPI_Finalized(&finalized);
if (init && !finalized) {
MPI_Comm_dup(MPI_COMM_WORLD, &comm);
// Do MPI things
}
}
void new_style_library_init(void) {
#if MPI_VERSION >= 4
// MPI >= v4 allows Info/Errhandler before INIT
MPI_Info_create(...);
MPI_Errhandler_create(...);
// If MPI_INIT was not already called, make me a
// session and communicator.
// Otherwise, dup MPI_COMM_WORLD.
if (MPI_Session_create(..., &session) == MPI_SUCCESS) {
MPI_Comm_create_from_session(session, &comm);
} else {
MPI_Comm_dup(MPI_COMM_WORLD, &comm);
}
#else
legacy_library_init();
#endif
// Do MPI things with comm
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment