source: CIVL/examples/messagePassing/mpi-pthreads-old.cvl@ b231753

1.23 2.0 main test-branch
Last change on this file since b231753 was c335e41, checked in by Stephen Siegel <siegel@…>, 12 years ago

Re-wrote mpi-pthreads.

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

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