source: CIVL/examples/contracts/contractsMPI/aPossibleBug.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

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

  • Property mode set to 100644
File size: 656 bytes
Line 
1#include<mpi.h>
2#include<assert.h>
3#include<civlc.cvh>
4
5double * u;
6int nx = 10;
7
8/*@ requires \valid(x);
9 @ ensures \result == *x + 1;
10 @
11*/
12int add(int * x)
13{
14 return *x + 1;
15}
16
17/*@
18 @ \mpi_collective(MPI_COMM_WORLD, P2P):
19 @ requires \mpi_comm_size == 2;
20 @ requires \mpi_comm_rank == x;
21 @ ensures \remote(nx, 0) == 10;
22 @*/
23void exchange(int x) {
24 int y;
25 int neighbor = 1 - x;
26
27 MPI_Sendrecv(&x, 1, MPI_INT, neighbor, 0, &y,
28 1, MPI_INT, neighbor, 0,
29 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
30 y = add(&y);
31 assert(x + y == 1);
32}
33
34
35int main() {
36 int dummy = 7;
37 exchange(0);
38 dummy=8;
39 $havoc(NULL);
40 return 0;
41}
Note: See TracBrowser for help on using the repository browser.