1.23
2.0
main
test-branch
|
Last change
on this file since c46e702 was c46e702, checked in by Manchun Zheng <zmanchun@…>, 12 years ago |
|
implemented MPI+Threads. Now hybrid.cvl with -min, -por=new terminates in a few seconds. But hybrid2.cvl still seems to run forever, need to look into it further.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@606 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Rev | Line | |
|---|
| [b70deeb] | 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 |
|
|---|
| 9 | void MPI_Process (int __rank) {
|
|---|
| 10 | #include "mp_proc2.cvh"
|
|---|
| 11 | int rank;
|
|---|
| [c46e702] | 12 | _Bool tStart = $false;
|
|---|
| 13 |
|
|---|
| [b70deeb] | 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 |
|
|---|
| [c46e702] | 19 | $when(tStart);
|
|---|
| [b70deeb] | 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 | }
|
|---|
| [c46e702] | 34 | //$atomic {
|
|---|
| 35 | for (int i=0; i<2; i++) {
|
|---|
| 36 | threads[i] = $spawn Thread(i);
|
|---|
| 37 | $comm_add(MPI_COMM_WORLD, threads[i]);
|
|---|
| [b70deeb] | 38 | }
|
|---|
| [c46e702] | 39 | tStart = $true;
|
|---|
| 40 | for (int i=0; i<2; i++) $wait threads[i];
|
|---|
| 41 | //}
|
|---|
| [b70deeb] | 42 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.