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
|
| Line | |
|---|
| 1 | /* CIVL model of simple hybrid MPI+threads program.
|
|---|
| 2 | * The program has a defect.
|
|---|
| 3 | */
|
|---|
| 4 | #include<civlc.h>
|
|---|
| 5 | #define TAG 0
|
|---|
| 6 |
|
|---|
| 7 | $comm comm;
|
|---|
| 8 | _Bool initialized = $false;
|
|---|
| 9 |
|
|---|
| 10 | void MPI_Process (int pid) {
|
|---|
| 11 | _Bool threadsInit = $false;
|
|---|
| 12 | $proc threads[2];
|
|---|
| 13 |
|
|---|
| 14 | void Thread(int tid) {
|
|---|
| 15 | int x = pid;
|
|---|
| 16 | $message in, out = $message_pack(pid, 1-pid, TAG, &x, sizeof(int));
|
|---|
| 17 |
|
|---|
| 18 | $when(threadsInit) ;
|
|---|
| 19 | for (int j=0; j<2; j++) {
|
|---|
| 20 | if (pid == 1) {
|
|---|
| 21 | for (int i=0; i<2; i++) $comm_enqueue(&comm, out);
|
|---|
| 22 | for (int i=0; i<2; i++) in = $comm_dequeue(&comm, 1-pid, pid, TAG);
|
|---|
| 23 | } else {
|
|---|
| 24 | for (int i=0; i<2; i++) in = $comm_dequeue(&comm, 1-pid, pid, TAG);
|
|---|
| 25 | for (int i=0; i<2; i++) $comm_enqueue(&comm, out);
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | $when (initialized);
|
|---|
| 31 | for (int i=0; i<2; i++) {
|
|---|
| 32 | threads[i] = $spawn Thread(i);
|
|---|
| 33 | $comm_add(&comm, threads[i]);
|
|---|
| 34 | }
|
|---|
| 35 | threadsInit = $true;
|
|---|
| 36 | for (int i=0; i<2; i++) $wait threads[i];
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | void main() {
|
|---|
| 40 | $proc procs[2];
|
|---|
| 41 |
|
|---|
| 42 | for (int i=0; i<2; i++) procs[i] = $spawn MPI_Process(i);
|
|---|
| 43 | comm = $comm_create(2, procs);
|
|---|
| 44 | initialized = $true;
|
|---|
| 45 | for (int i=0; i<2; i++) $wait procs[i];
|
|---|
| 46 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.