source: CIVL/examples/contracts/cycle.c@ 397ae5f

main test-branch
Last change on this file since 397ae5f 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: 627 bytes
Line 
1/* cycle: Each process send its rank to its right neighbor and
2 receives message from the left neighbor.
3 */
4#include<mpi.h>
5#include<civl-mpi.cvh>
6
7int main(int argc, char * argv[]) {
8 int x, rank, nprocs;
9 int left, right;
10 MPI_Comm comm = MPI_COMM_WORLD;
11
12 MPI_Init(&argc, &argv);
13 MPI_Comm_rank(comm, &rank);
14 MPI_Comm_size(comm, &nprocs);
15 left = (rank + 1)%nprocs;
16 right = (rank - 1)%nprocs;
17 for(int i = 0; i < nprocs; i++) {
18 MPI_Sendrecv(&rank, 1, MPI_INT, right, 0,
19 &x, 1, MPI_INT, left, 0, comm,
20 MPI_STATUS_IGNORE);
21 $mpi_coassert(comm, rank == x@right);
22 }
23 MPI_Finalize();
24 return 0;
25}
Note: See TracBrowser for help on using the repository browser.