Skip to content
Snippets Groups Projects
Commit e7b4ada1 authored by Chao Zhan's avatar Chao Zhan
Browse files

Revert "add solution to round trip example"

This reverts commit 44af9246.
parent ec70034e
No related branches found
No related tags found
No related merge requests found
...@@ -13,25 +13,21 @@ int main(int argc, char** argv) { ...@@ -13,25 +13,21 @@ int main(int argc, char** argv) {
// of the special case when you are the first process to prevent deadlock. // of the special case when you are the first process to prevent deadlock.
if (rank != 0) { if (rank != 0) {
MPI_Recv(&token, 1, MPI_INT, rank - 1, 0, MPI_COMM_WORLD, // TODO: Receive the token from the previous process in the ring
MPI_STATUS_IGNORE);
printf("Process %d received token %d from process %d\n", rank, token, printf("Process %d received token %d from process %d\n", rank, token,
rank - 1); rank - 1);
} else { } else {
// Set the token's value if you are process 0 // TODO: Set the token's value if you are process 0
token = 1024;
} }
MPI_Send(&token, 1, MPI_INT, (rank + 1) % num_procs, 0, // TODO: send the token to the next process in the ring
MPI_COMM_WORLD);
// Now process 0 can receive from the last process. This makes sure that at // Now process 0 can receive from the last process. This makes sure that at
// least one MPI_Send is initialized before all MPI_Recvs (again, to prevent // least one MPI_Send is initialized before all MPI_Recvs (again, to prevent
// deadlock) // deadlock)
if (rank == 0) { if (rank == 0) {
MPI_Recv(&token, 1, MPI_INT, rank - 1, 0, MPI_COMM_WORLD, // TODO: Receive the token from the last process in the ring
MPI_STATUS_IGNORE);
printf("Process %d received token %d from process %d\n", rank, token, printf("Process %d received token %d from process %d\n", rank, token,
num_procs - 1); num_procs - 1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment