Skip to content

Commit

Permalink
Fix MPI-IO adapter init and finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHogan committed Jun 22, 2021
1 parent a42add7 commit 1df0098
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
12 changes: 3 additions & 9 deletions adapter/src/hermes/adapter/mpiio/metadata_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class MetadataManager {
char* hermes_config = getenv(kHermesConf);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
// TODO(chogan): Need a better way to distinguish between client and
// daemon. https://github.com/HDFGroup/hermes/issues/206
if (comm_size > 1) {
hermes = hermes::InitHermesClient(hermes_config);
} else {
Expand All @@ -98,15 +100,7 @@ class MetadataManager {
*/
void FinalizeHermes() {
if (ref == 1) {
if (this->comm_size > 1) {
MPI_Barrier(MPI_COMM_WORLD);
if (this->rank == 0) {
hermes->RemoteFinalize();
}
hermes->Finalize();
} else {
hermes->Finalize(true);
}
hermes->FinalizeClient();
}
ref--;
}
Expand Down
2 changes: 0 additions & 2 deletions adapter/src/hermes/adapter/mpiio/mpiio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ int simple_open(MPI_Comm &comm, const char *path, int &amode, MPI_Info &info,
}
stat.info = info;
stat.comm = comm;
mdm->InitializeHermes();
hapi::Context ctx;
stat.st_bkid = std::make_shared<hapi::Bucket>(path, mdm->GetHermes(), ctx);
mdm->Create(fh, stat);
Expand Down Expand Up @@ -612,7 +611,6 @@ int HERMES_DECL(MPI_File_close)(MPI_File *fh) {
INTERCEPTOR_LIST->hermes_flush_exclusion.erase(filename);
}
existing.first.st_bkid->Destroy(ctx);
mdm->FinalizeHermes();
if (existing.first.a_mode & MPI_MODE_DELETE_ON_CLOSE) {
fs::remove(filename);
}
Expand Down
2 changes: 2 additions & 0 deletions adapter/src/hermes/adapter/stdio/metadata_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class MetadataManager {
if (this->is_mpi) {
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
// TODO(chogan): Need a better way to distinguish between client and
// daemon. https://github.com/HDFGroup/hermes/issues/206
if (comm_size > 1) {
hermes = hermes::InitHermesClient(hermes_config);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/api/hermes.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Hermes {
int GetNumProcesses();
void *GetAppCommunicator();
void Finalize(bool force_rpc_shutdown = false);
void FinalizeClient(bool stop_daemon);
void FinalizeClient(bool stop_daemon = true);
void RemoteFinalize();
void RunDaemon();

Expand Down

0 comments on commit 1df0098

Please sign in to comment.