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
RevLine 
[4e62451]1#include<mpi.h>
[9d7c12b]2#include<assert.h>
[4e62451]3
4/*@
[9d7c12b]5 @ \mpi_collective(MPI_COMM_WORLD, P2P):
[9074a6e]6 @ requires \mpi_comm_rank == x;
[4e62451]7 @*/
[9d7c12b]8void exchange(int x) {
[ef8e46c]9 int y, nprocs;
10 int right, left;
[9d7c12b]11
[ef8e46c]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,
[9d7c12b]17 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
[ef8e46c]18 assert(y == left);
[4e62451]19}
20
Note: See TracBrowser for help on using the repository browser.