main
test-branch
| Line | |
|---|
| 1 | /* Example of potential deadlock. Two procs each attempt to send,
|
|---|
| 2 | * then receive. Run with nprocs=2. */
|
|---|
| 3 | #include <mpi.h>
|
|---|
| 4 | #include <stdlib.h>
|
|---|
| 5 | #define comm MPI_COMM_WORLD
|
|---|
| 6 |
|
|---|
| 7 | int main(int argc, char * argv[]) {
|
|---|
| 8 | int rank;
|
|---|
| 9 |
|
|---|
| 10 | MPI_Init(&argc, &argv);
|
|---|
| 11 | MPI_Comm_rank(comm, &rank);
|
|---|
| 12 | if (rank == 0 || rank == 1)
|
|---|
| 13 | MPI_Sendrecv(NULL, 0, MPI_INT, 1-rank, 0, NULL, 0, MPI_INT, 1-rank, 0, comm, MPI_STATUS_IGNORE);
|
|---|
| 14 | MPI_Finalize();
|
|---|
| 15 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.