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