source: CIVL/examples/contracts/isRecvBufEmpty_BAD.c@ 5bc08d6

1.23 2.0 main test-branch
Last change on this file since 5bc08d6 was 024184a, checked in by Ziqing Luo <ziqing@…>, 11 years ago

renaming examples

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

  • Property mode set to 100644
File size: 766 bytes
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);
9MPI_Comm comm = MPI_COMM_WORLD;
10int rank;
11
12int 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
23int 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.