source: CIVL/examples/messagePassing/ring2.cvl@ 20a83c7

1.23 2.0 main test-branch
Last change on this file since 20a83c7 was c905758, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

fix ring2 and hybrid2

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

  • Property mode set to 100644
File size: 986 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<stdio.h>
7#include "mp_root2.cvh"
8
9void MPI_Process (int __rank) {
10#include "mp_proc2.cvh"
11
12// ******************* BEGIN PROGRAM SOURCE *************************
13
14 int rank, nprocs, count;
15 double x, y;
16 MPI_Status stat;
17 MPI_Comm MPI_COMM_WORLD = $comm_create($here, __MPI_Comm_World, __rank);
18
19 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
20 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
21 x = rank;
22 MPI_Send(&x, 1, MPI_DOUBLE, (rank+1)%nprocs, 0, MPI_COMM_WORLD);
23 MPI_Recv(&y, 1, MPI_DOUBLE, (rank+nprocs-1)%nprocs, 0, MPI_COMM_WORLD, &stat);
24 $assert(y == (rank+nprocs-1)%nprocs);
25 MPI_Get_count(&stat, MPI_DOUBLE, &count);
26 $assert(count == 1);
27 $assert(stat.MPI_SOURCE == (rank+nprocs-1)%nprocs);
28 $assert(stat.MPI_TAG == 0);
29
30// ******************** END PROGRAM SOURCE ***************************
31
32}
Note: See TracBrowser for help on using the repository browser.