Skip to content

Commit

Permalink
Check if MPI is initialized for node rank detection
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme committed May 19, 2020
1 parent 877a5c6 commit 8f4b1c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mpi/mpi_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ int get_rank_for_node()
if (gethostname(hostname, max_len) < 0)
return -1;

int initialized = 0;
PMPI_Initialized(&initialized);
if (!initialized)
return 0;

return ::get_rank_for_hash(std::hash<std::string>{}(std::string(hostname)), MPI_COMM_WORLD);
}

} // namespace mpi

} // namespace cali
} // namespace cali

0 comments on commit 8f4b1c3

Please sign in to comment.