source: CIVL/examples/messagePassing/ring3.cvl@ b7bd088

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

cleaned up examples and tests.

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

  • Property mode set to 100644
File size: 931 bytes
Line 
1/* Create nprocs processes. Have them exchange data in a cycle.
2 * Command line execution:
3 * civl verify -por=new -inputNPROCS=3 ring3.cvl -simplify=false
4 */
5#include<civlc.h>
6#define TAG 0
7
8$input int NPROCS;
9$input int NB;
10$assume 1 < NPROCS && NPROCS <= NB;
11_Bool initialized = $false;
12$comm MPI_COMM_WORLD;
13
14void MPI_Process (int rank) {
15 double x=rank, y;
16 $message in, out;
17
18 $when (initialized);
19 out = $message_pack(rank, (rank+1)%NPROCS, TAG, &x, sizeof(double));
20 $comm_enqueue(&MPI_COMM_WORLD, out);
21 in = $comm_dequeue(&MPI_COMM_WORLD, (rank+NPROCS-1)%NPROCS, rank, TAG);
22 $message_unpack(in, &y, sizeof(double));
23
24 $assert(y==(rank+NPROCS-1)%NPROCS);
25}
26
27void main() {
28 $proc procs[NPROCS];
29
30 $atomic{
31 for (int i=0; i<NPROCS; i++)
32 procs[i] = $spawn MPI_Process(i);
33 MPI_COMM_WORLD = $comm_create(NPROCS, procs);
34 initialized = $true;
35 }
36 for (int i=0; i<NPROCS; i++)
37 $wait procs[i];
38}
Note: See TracBrowser for help on using the repository browser.