Skip to content

Commit

Permalink
update example/mpi-nompi print order
Browse files Browse the repository at this point in the history
- example/mpi-nompi/hello.cc: force deterministic print order by
  sleeping after print statements.

Signed-off-by: Aiden Woodruff <[email protected]>
  • Loading branch information
bobpaw committed Feb 19, 2025
1 parent 28eaa3a commit 54dc9ce
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions example/mpi-nompi/hello.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <chrono>
#include <iostream>
#include <thread>

#include <mpi.h>
#include <PCU.h>
Expand All @@ -23,6 +25,8 @@ int main(int argc, char** argv) {
if (rank == i)
std::cout << "Hello from MPI rank: " << rank << "; PCU rank: " <<
PCUObj->Self() << std::endl;
// Print deterministically please and thank you.
std::this_thread::sleep_for(std::chrono::milliseconds(5));
MPI_Barrier(MPI_COMM_WORLD);
}
// Test SCOREC functions.
Expand All @@ -38,6 +42,8 @@ int main(int argc, char** argv) {
if (rank == i)
std::cout << "MPI(" << rank << ") sum: " << sum <<
"; PCU sum: " << psum << std::endl;
// Print deterministically please and thank you.
std::this_thread::sleep_for(std::chrono::milliseconds(5));
MPI_Barrier(MPI_COMM_WORLD);
}
// Test Allgather
Expand All @@ -53,6 +59,8 @@ int main(int argc, char** argv) {
print_array(pvals1, PCUObj->Peers());
std::cout << std::endl;
}
// Print deterministically please and thank you.
std::this_thread::sleep_for(std::chrono::milliseconds(5));
MPI_Barrier(MPI_COMM_WORLD);
}
delete vals1;
Expand All @@ -69,6 +77,8 @@ int main(int argc, char** argv) {
print_array(pvals2, 2 * PCUObj->Peers());
std::cout << std::endl;
}
// Print deterministically please and thank you.
std::this_thread::sleep_for(std::chrono::milliseconds(5));
MPI_Barrier(MPI_COMM_WORLD);
}
delete vals2;
Expand Down

0 comments on commit 54dc9ce

Please sign in to comment.