Skip to content

Commit

Permalink
Add MPI_Finalize wrapper
Browse files Browse the repository at this point in the history
When configuring APEX with MPI support, wrap the MPI_Finalize
function so that we can use MPI functions during OTF2 event
unification instead of the filesystem.
  • Loading branch information
khuck committed Aug 10, 2020
1 parent 13dbcbe commit 788ee8d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/apex/apex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ thread_instance::get_id(), __func__, __LINE__); fflush(stdout);
#define FUNCTION_EXIT
#endif

#if defined(APEX_HAVE_MPI)
#include "mpi.h"
#endif

APEX_NATIVE_TLS bool _registered = false;
APEX_NATIVE_TLS bool _exited = false;
static bool _initialized = false;
Expand Down Expand Up @@ -2051,6 +2055,18 @@ extern "C" {
return hardware_concurrency();
}

/* When running with MPI and OTF (or other event unification at the end of
* execution) we need to finalize APEX before MPI_Finalize() is called, so
* that we can use MPI for the wrap-up. We can override the weak MPI
* implementation of Finalize, and do what we need to. */
#if defined(APEX_HAVE_MPI)
int MPI_Finalize(void) {
apex::finalize();
int retval = PMPI_Finalize();
apex::cleanup();
return retval;
}
#endif

} // extern "C"

Expand Down

0 comments on commit 788ee8d

Please sign in to comment.