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