source: CIVL/examples/mpi/dev/ring.c@ 7d77e64

main test-branch
Last change on this file since 7d77e64 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: 808 bytes
RevLine 
[69bf2e6]1#include<mpi.h>
2#pragma TASS input
3int N_BOUND;
4#pragma TASS input {0<=N && N<=N_BOUND}
5int N;
6int myrank;
7int nprocs;
8int left;
9int right;
10
11void main() {
12 int argc;
13 char **argv;
14 int i;
15
16 MPI_Init(&argc, &argv);
17 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
18 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
19 left = (myrank+nprocs-1)%nprocs;
20 right = (myrank+nprocs+1)%nprocs;
21 i=0;
22#pragma TASS collective invariant L i==PROC[right]@main.i;
23 while (i<N) {
24 if (myrank%2==0) {
25 MPI_Send(NULL, 0, MPI_INT, right, 0, MPI_COMM_WORLD);
26 MPI_Recv(NULL, 0, MPI_INT, left, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
27 } else {
28 MPI_Recv(NULL, 0, MPI_INT, left, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
29 MPI_Send(NULL, 0, MPI_INT, right, 0, MPI_COMM_WORLD);
30 }
31 i++;
32 }
33 MPI_Finalize();
34}
Note: See TracBrowser for help on using the repository browser.