source: CIVL/examples/mpi/ring1.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: 744 bytes
Line 
1#include<mpi.h>
2//#include<stdio.h>
3int myrank;
4int nprocs;
5int left;
6int right;
7
8void main(int argc, char **argv) {
9 int i;
10 int data = 0;
11
12 MPI_Init(&argc, &argv);
13 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
14 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
15 left = (myrank+nprocs-1)%nprocs;
16 right = (myrank+nprocs+1)%nprocs;
17 i=0;
18 if (myrank%2==0) {
19 MPI_Send(&data, 0, MPI_INT, right, 0, MPI_COMM_WORLD);
20 MPI_Recv(&data, 0, MPI_INT, left, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
21 } else {
22 MPI_Recv(&data, 0, MPI_INT, left, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
23 MPI_Send(&data, 0, MPI_INT, right, 0, MPI_COMM_WORLD);
24 }
25 //printf("I'm process %d.\n", myrank);
26 MPI_Finalize();
27}
Note: See TracBrowser for help on using the repository browser.