source: CIVL/mods/dev.civl.abc/examples/contract/wildcard_contract_bad.c

main
Last change on this file was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

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

  • Property mode set to 100644
File size: 882 bytes
Line 
1/* wildcard_coassert_bad: A root process receives messages twice from
2 every other process using a wildcard receive. This program has a
3 data race-condition. */
4#include <mpi.h>
5#pragma CIVL ACSL
6
7int size, rank, x;
8int root = 0;
9MPI_Comm comm = MPI_COMM_WORLD;
10
11/*@
12 @ requires iter >= 0 && rank == 0;
13 @ \mpi_collective(comm, P2P):
14 @ ensures \true;
15 @
16*/
17void recv(int iter)
18{
19 for(int i = 1; i < size; i++)
20 MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, 0, comm, MPI_STATUS_IGNORE);
21}
22
23/*@ \mpi_collective(comm, P2P):
24 @ ensures \on(root, x) == msg;
25 @
26*/
27void send(int msg)
28{
29 MPI_Send(&msg, 1, MPI_INT, root, 0, comm);
30}
31
32int main(int argc, char * argv[]) {
33 MPI_Init(&argc, &argv);
34 MPI_Comm_rank(comm, &rank);
35 MPI_Comm_size(comm, &size);
36 for(int i = 0; i < 2; i++)
37 if(!rank)
38 recv(i);
39 else
40 send(i);
41 MPI_Finalize();
42 return 0;
43}
Note: See TracBrowser for help on using the repository browser.