source: CIVL/examples/messagePassing/hybrid2.cvl@ cf2a996

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

added an additional parameter rank for $comm_add(). Updated hybrid.cvl to use $comm_add().

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

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/* CIVL model of simple hybrid MPI+threads program.
2 * The program has a defect.
3 */
4#include<civlc.h>
5#include<stdio.h>
6#include "mp_root2.cvh"
7#define TAG 0
8
9void MPI_Process (int __rank) {
10#include "mp_proc2.cvh"
11 int rank;
12 _Bool tStart = $false;
13
14 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
15 $proc threads[2];
16 void Thread(int tid) {
17 int x = 2*rank + tid, y;
18
19 $when(tStart);
20 for (int j=0; j<2; j++) {
21 if (rank == 1) {
22 for (int i=0; i<2; i++)
23 MPI_Send(&x, 1, MPI_INT, 1, TAG, MPI_COMM_WORLD);
24 for (int i=0; i<2; i++)
25 MPI_Recv(&y, 1, MPI_INT, 1, TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
26 } else {
27 for (int i=0; i<2; i++)
28 MPI_Recv(&y, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
29 for (int i=0; i<2; i++)
30 MPI_Send(&x, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD);
31 }
32 }
33 }
34 //$atomic {
35 for (int i=0; i<2; i++) {
36 threads[i] = $spawn Thread(i);
37 $comm_add(MPI_COMM_WORLD, threads[i], rank);
38 }
39 tStart = $true;
40 for (int i=0; i<2; i++) $wait threads[i];
41 //}
42}
Note: See TracBrowser for help on using the repository browser.