Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI Broadcast Call Bugfix #424

Merged
merged 2 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions include/utilities/parallel_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace parallel {
* @return Whether all ranks coordinating status had a success/ready status value.
*/
bool mpiSyncStatusAnd(bool status, int mpi_rank, int mpi_num_procs, const std::string &taskDesc) {

// Expect 0 is good and 1 is no good for goodCode
// TODO: assert this in constructor or somewhere, or maybe just in a unit test
unsigned short codeBuffer;
Expand All @@ -75,8 +76,9 @@ namespace parallel {
// Rank 0 must also now prepare the codeBuffer value for broadcasting the global status
codeBuffer = status ? MPI_HF_SUB_CODE_GOOD : MPI_HF_SUB_CODE_BAD;
}

// Execute broadcast of global status rooted at rank 0
MPI_Bcast(&codeBuffer, mpi_num_procs - 1, MPI_UNSIGNED_SHORT, 0, MPI_COMM_WORLD);
MPI_Bcast(&codeBuffer, 1, MPI_UNSIGNED_SHORT, 0, MPI_COMM_WORLD);
return codeBuffer == MPI_HF_SUB_CODE_GOOD;
}

Expand Down Expand Up @@ -116,12 +118,13 @@ namespace parallel {
// Initialize isGood based on local state. Here, local file is "good" when it already exists.
// TODO: this isn't actually checking whether the files are right (just that they are present) so do we need to?
bool isGood = utils::FileChecker::file_is_readable(name);

if (mpiSyncStatusAnd(isGood, mpi_rank, mpi_num_procs)) {
if (printMsg) { std::cout << "Hydrofabric already subdivided in " << mpi_num_procs << " files." << std::endl; }
if (printMsg) { std::cout << "Process " << mpi_rank << ": Hydrofabric already subdivided in " << mpi_num_procs << " files." << std::endl; }
return true;
}
else {
if (printMsg) { std::cout << "Hydrofabric has not yet been subdivided." << std::endl; }
if (printMsg) { std::cout << "Process " << mpi_rank << ": Hydrofabric has not yet been subdivided." << std::endl; }
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/NGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ int main(int argc, char *argv[]) {
MPI_Init(NULL, NULL);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
MPI_Comm_size(MPI_COMM_WORLD, &mpi_num_procs);

#endif // NGEN_MPI_ACTIVE

#ifdef WRITE_PID_FILE_FOR_GDB_SERVER
Expand Down