main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 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 | * Commnad line execution:
|
|---|
| 4 | * civl verify -min mpi-pthreads.cvl
|
|---|
| 5 | */
|
|---|
| 6 | #include<civlc.h>
|
|---|
| 7 | #define TAG 0
|
|---|
| 8 | #define NPROCS 2
|
|---|
| 9 | #define NTHREADS 2
|
|---|
| 10 |
|
|---|
| 11 | $gcomm gcomm = $gcomm_create($here, NPROCS);
|
|---|
| 12 |
|
|---|
| 13 | void MPI_Process (int rank) {
|
|---|
| 14 | $comm comm = $comm_create($here, gcomm, rank);
|
|---|
| 15 | $proc threads[NTHREADS];
|
|---|
| 16 |
|
|---|
| 17 | void Thread(int tid) {
|
|---|
| 18 | int x = rank;
|
|---|
| 19 | $message in, out = $message_pack(rank, 1-rank, TAG, &x, sizeof(int));
|
|---|
| 20 |
|
|---|
| 21 | for (int j=0; j<2; j++) {
|
|---|
| 22 | if (rank == 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-rank, TAG);
|
|---|
| 25 | } else {
|
|---|
| 26 | for (int i=0; i<2; i++) in = $comm_dequeue(comm, 1-rank, TAG);
|
|---|
| 27 | for (int i=0; i<2; i++) $comm_enqueue(comm, out);
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | for (int i=0; i<NTHREADS; i++) threads[i] = $spawn Thread(i);
|
|---|
| 33 | for (int i=0; i<NTHREADS; i++) $wait(threads[i]);
|
|---|
| 34 | $comm_destroy(comm);
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | void main() {
|
|---|
| 38 | $proc procs[NPROCS];
|
|---|
| 39 |
|
|---|
| 40 | for (int i=0; i<NPROCS; i++) procs[i] = $spawn MPI_Process(i);
|
|---|
| 41 | for (int i=0; i<NPROCS; i++) $wait(procs[i]);
|
|---|
| 42 | $gcomm_destroy(gcomm);
|
|---|
| 43 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.