1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | /* Example illustrating that a deadlock can occur along the path resulting
|
|---|
| 2 | * from one choice at MPI_ANY_SOURCE, but not along the path resulting from
|
|---|
| 3 | * a different choice. Mopper will not detect the deadlock.
|
|---|
| 4 | */
|
|---|
| 5 | #include <mpi.h>
|
|---|
| 6 | #include <stdlib.h>
|
|---|
| 7 | #define comm MPI_COMM_WORLD
|
|---|
| 8 |
|
|---|
| 9 | int main(int argc, char * argv[]) {
|
|---|
| 10 | int data = 0, rank;
|
|---|
| 11 | MPI_Status status;
|
|---|
| 12 |
|
|---|
| 13 | MPI_Init(&argc, &argv);
|
|---|
| 14 | MPI_Comm_rank(comm, &rank);
|
|---|
| 15 | if (rank == 0) {
|
|---|
| 16 | MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, 0, comm, &status);
|
|---|
| 17 | if (status.MPI_SOURCE == 2)
|
|---|
| 18 | MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, 0, comm, MPI_STATUS_IGNORE);
|
|---|
| 19 | else
|
|---|
| 20 | MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, MPI_STATUS_IGNORE);
|
|---|
| 21 | } else if (rank == 1 || rank == 2) {
|
|---|
| 22 | MPI_Send(NULL, 0, MPI_INT, 0, 0, comm);
|
|---|
| 23 | }
|
|---|
| 24 | MPI_Finalize();
|
|---|
| 25 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.