source: CIVL/examples/contracts/coassert_cover.c@ beab7f2

main test-branch
Last change on this file since beab7f2 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: 930 bytes
Line 
1/* Coverage test example: This example is only used for software
2 testing coverage, it may not be understandable for human beings. */
3#include <mpi.h>
4#include <stdio.h>
5#include <civl-mpi.cvh>
6
7$input int in;
8int size, rank, x;
9int root = 0;
10
11void recv(int iter) {
12 for(int i = 1; i < size; i++)
13 MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
14 $mpi_coassert(MPI_COMM_WORLD, root == in);
15 printf("rank:%d in=%d\n", rank, in);
16}
17
18void send(int msg) {
19 MPI_Send(&msg, 1, MPI_INT, root, 0, MPI_COMM_WORLD);
20 printf("Proc:%d sends %d\n", rank, msg);
21 $mpi_coassert(MPI_COMM_WORLD, $true);
22 printf("rank:%d in=%d\n", rank, in);
23}
24
25int main(int argc, char * argv[]) {
26 MPI_Init(&argc, &argv);
27 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
28 MPI_Comm_size(MPI_COMM_WORLD, &size);
29 for(int i = 0; i < 2; i++)
30 if(!rank)
31 recv(i);
32 else
33 send(i);
34 MPI_Finalize();
35 return 0;
36}
Note: See TracBrowser for help on using the repository browser.