source: CIVL/examples/messagePassing/ring2.cvl@ e51fd2f

1.23 2.0 main test-branch
Last change on this file since e51fd2f was e51fd2f, checked in by Stephen Siegel <siegel@…>, 12 years ago

Improvements to MPI example ring2.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@479 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 889 bytes
Line 
1/* Create nprocs processes. Have them exchange data in a cycle.
2 * Commandline example:
3 * civl verify -input_NP=3 ring2.cvl -simplify=false
4 */
5#include<civlc.h>
6#include "mp_root2.cvh"
7
8void MPI_Process (int __rank) {
9#include "mp_proc2.cvh"
10
11// ******************* BEGIN PROGRAM SOURCE *************************
12
13 int rank, nprocs, count;
14 double x, y;
15 MPI_Status stat;
16
17 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
18 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
19 x = rank;
20 MPI_Send(&x, 1, MPI_DOUBLE, (rank+1)%nprocs, 0, MPI_COMM_WORLD);
21 MPI_Recv(&y, 1, MPI_DOUBLE, (rank+nprocs-1)%nprocs, 0, MPI_COMM_WORLD, &stat);
22 $assert y == (rank+nprocs-1)%nprocs;
23 MPI_Get_count(&stat, MPI_DOUBLE, &count);
24 $assert count == 1;
25 $assert stat.MPI_SOURCE == (rank+nprocs-1)%nprocs;
26 $assert stat.MPI_TAG == 0;
27
28// ******************** END PROGRAM SOURCE ***************************
29
30}
Note: See TracBrowser for help on using the repository browser.