source: CIVL/examples/mpi/ring1.c@ beab7f2

main test-branch
Last change on this file since beab7f2 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
RevLine 
[8a9124e]1#include<mpi.h>
[e48510a]2//#include<stdio.h>
[8a9124e]3int myrank;
4int nprocs;
5int left;
6int right;
7
[2c1340d]8void main(int argc, char **argv) {
[8a9124e]9 int i;
10 int data = 0;
11
[2c1340d]12 MPI_Init(&argc, &argv);
[8a9124e]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 }
[e48510a]25 //printf("I'm process %d.\n", myrank);
[8a9124e]26 MPI_Finalize();
27}
Note: See TracBrowser for help on using the repository browser.