main
test-branch
| Line | |
|---|
| 1 | #include <mpi.h>
|
|---|
| 2 |
|
|---|
| 3 | int size, rank;
|
|---|
| 4 | int root;
|
|---|
| 5 | int x;
|
|---|
| 6 |
|
|---|
| 7 | /*@ \mpi_collective(MPI_COMM_WORLD, P2P):
|
|---|
| 8 | @ requires rank == \mpi_comm_rank;
|
|---|
| 9 | @ requires size == \mpi_comm_size;
|
|---|
| 10 | @ requires 0 <= root && root < \mpi_comm_size;
|
|---|
| 11 | @ requires \mpi_agree(root);
|
|---|
| 12 | @ requires datatype == MPI_INT;
|
|---|
| 13 | @ ensures \on(root, x) == size - 1 ||
|
|---|
| 14 | @ (\on(root, x) == size - 2 && size - 1 == root);
|
|---|
| 15 | @*/
|
|---|
| 16 | int wildcard(MPI_Datatype datatype) {
|
|---|
| 17 | if (rank == root) {
|
|---|
| 18 | for (int i = 0; i < size; i++)
|
|---|
| 19 | if (i != root)
|
|---|
| 20 | MPI_Recv(&x, 1, datatype, i, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|---|
| 21 | } else
|
|---|
| 22 | MPI_Send(&rank, 1, datatype, root, 0, MPI_COMM_WORLD);
|
|---|
| 23 | return 0;
|
|---|
| 24 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.