source: CIVL/examples/contracts/isRecvBufEmpty.c@ c8d748e

1.23 2.0 main test-branch
Last change on this file since c8d748e 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: 702 bytes
Line 
1#include<assert.h>
2#include<mpi.h>
3#include<civl-mpi.cvh>
4
5#define comm MPI_COMM_WORLD
6int rank, nprocs, left, right;
7
8int sendrecv()
9$requires {$collective(comm) $mpi_isRecvBufEmpty(left)}
10$ensures {$collective(comm) ($mpi_isRecvBufEmpty(left) && left == $result)}
11$ensures {left == $result}
12{
13 int message = rank;
14 int recvBuf;
15
16 MPI_Sendrecv(&message, 1, MPI_INT, right, 0, &recvBuf, 1, MPI_INT, left, 0, comm, MPI_STATUS_IGNORE);
17 return recvBuf;
18}
19
20int main(int argc, char * argv[]) {
21 int x;
22
23 MPI_Init(&argc, &argv);
24 MPI_Comm_size(comm, &nprocs);
25 MPI_Comm_rank(comm, &rank);
26 left = (rank-1) % nprocs;
27 right = (rank+1) % nprocs;
28 x = sendrecv();
29 MPI_Finalize();
30 return 0;
31}
Note: See TracBrowser for help on using the repository browser.