source: CIVL/examples/contracts/notEmptyRecvBuf.c@ 5c19657

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since 5c19657 was c8d748e, checked in by Ziqing Luo <ziqing@…>, 11 years ago

add test casess

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2648 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 746 bytes
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);
8MPI_Comm comm = MPI_COMM_WORLD;
9
10int 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
21int 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.