main
test-branch
| Line | |
|---|
| 1 | /* Example where the deadlock depends on a (command line) input.
|
|---|
| 2 | * It deadlocks when the commandline input equals to two.
|
|---|
| 3 | * Run with nprocs=2.
|
|---|
| 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 rank;
|
|---|
| 11 |
|
|---|
| 12 | MPI_Init(&argc, &argv);
|
|---|
| 13 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 14 |
|
|---|
| 15 | if (rank == 0)
|
|---|
| 16 | if (atoi(argv[1]) != 2) {
|
|---|
| 17 | MPI_Send(NULL, 0, MPI_INT, 1, 0, comm);
|
|---|
| 18 | } else {
|
|---|
| 19 | MPI_Send(NULL, 0, MPI_INT, 1, 0, comm);
|
|---|
| 20 | }
|
|---|
| 21 | if (rank == 1)
|
|---|
| 22 | MPI_Recv(NULL, 0, MPI_INT, 0, 0, comm, MPI_STATUS_IGNORE);
|
|---|
| 23 | MPI_Finalize();
|
|---|
| 24 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.