source: CIVL/examples/contracts/contractsMPI/simpleMpiTest.c@ bb03188

main test-branch
Last change on this file since bb03188 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: 426 bytes
Line 
1#include<mpi.h>
2#include<assert.h>
3
4/*@
5 @ \mpi_collective(MPI_COMM_WORLD, P2P):
6 @ requires \mpi_comm_rank == x;
7 @*/
8void exchange(int x) {
9 int y, nprocs;
10 int right, left;
11
12 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
13 right = (x + 1) % nprocs;
14 left = (x - 1) % nprocs;
15 MPI_Sendrecv(&x, 1, MPI_INT, right, 0, &y,
16 1, MPI_INT, right, 0,
17 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
18 assert(y == left);
19}
20
Note: See TracBrowser for help on using the repository browser.