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

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

implemented assert statements with printing functionality; since $assert is redefined as a function in civlc.h, the translation in FunctionTranslator is changed and all examples using $assert is updated accordingly; translates assert() which is defined in assert.h into an assert statement; fixed warnings in mpi executor.

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

  • Property mode set to 100644
File size: 911 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
18 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
19 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
20 x = rank;
21 MPI_Send(&x, 1, MPI_DOUBLE, (rank+1)%nprocs, 0, MPI_COMM_WORLD);
22 MPI_Recv(&y, 1, MPI_DOUBLE, (rank+nprocs-1)%nprocs, 0, MPI_COMM_WORLD, &stat);
23 $assert(y == (rank+nprocs-1)%nprocs);
24 MPI_Get_count(&stat, MPI_DOUBLE, &count);
25 $assert(count == 1);
26 $assert(stat.MPI_SOURCE == (rank+nprocs-1)%nprocs);
27 $assert(stat.MPI_TAG == 0);
28
29// ******************** END PROGRAM SOURCE ***************************
30
31}
Note: See TracBrowser for help on using the repository browser.