1.23
2.0
acw/focus-triggers
main
test-branch
| Line | |
|---|
| 1 | #include<assert.h>
|
|---|
| 2 | #include<mpi.h>
|
|---|
| 3 | #include<civl-mpi.cvh>
|
|---|
| 4 |
|
|---|
| 5 | $input int in;
|
|---|
| 6 | $input int _mpi_nprocs = 2;
|
|---|
| 7 | $assume(in > 0);
|
|---|
| 8 | MPI_Comm comm = MPI_COMM_WORLD;
|
|---|
| 9 |
|
|---|
| 10 | int gimmeOne(int x)
|
|---|
| 11 | $requires {$collective(comm) $mpi_isRecvBufEmpty(0)}
|
|---|
| 12 | $requires {$collective(MPI_COMM_WORLD) $true}
|
|---|
| 13 | $requires {x > 0}
|
|---|
| 14 | $ensures {$collective(MPI_COMM_WORLD) $mpi_isRecvBufEmpty(0)}
|
|---|
| 15 | $ensures {$collective(MPI_COMM_WORLD) $result == 1 + x}
|
|---|
| 16 | $ensures {x == in}
|
|---|
| 17 | {
|
|---|
| 18 | return 1 + x;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | int main(int argc, char * argv[]) {
|
|---|
| 22 | int x, rank;
|
|---|
| 23 |
|
|---|
| 24 | MPI_Init(&argc, &argv);
|
|---|
| 25 | MPI_Comm_rank(comm, &rank);
|
|---|
| 26 | if(rank == 1)
|
|---|
| 27 | MPI_Send(&rank, 1, MPI_INT, 0, 0, comm);
|
|---|
| 28 | x = gimmeOne(in);
|
|---|
| 29 | if(rank == 0)
|
|---|
| 30 | MPI_Recv(&x, 1, MPI_INT, 1, 0, comm, MPI_STATUS_IGNORE);
|
|---|
| 31 | MPI_Finalize();
|
|---|
| 32 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.