source:
CIVL/examples/concurrency/mp_root.cvh
| Last change on this file was ea777aa, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 456 bytes | |
| Rev | Line | |
|---|---|---|
| [0be7a7ea] | 1 | |
| 2 | $input int NPROCS; | |
| 3 | $proc __procs[NPROCS]; | |
| 4 | _Bool __start = 0; | |
| [b482f11] | 5 | $gcomm COMM_WORLD; |
| [0be7a7ea] | 6 | |
| 7 | void MPI_Process (int rank); | |
| 8 | ||
| 9 | void init() { | |
| 10 | for (int i=0; i<NPROCS; i++) | |
| 11 | __procs[i] = $spawn MPI_Process(i); | |
| 12 | } | |
| 13 | ||
| 14 | void finalize() { | |
| [a3da6fb] | 15 | for (int i=0; i<NPROCS; i++) { |
| 16 | $yield(); | |
| [a82987f] | 17 | $wait(__procs[i]); |
| [a3da6fb] | 18 | } |
| [0be7a7ea] | 19 | } |
| 20 | ||
| 21 | void main() { | |
| [18cad8a] | 22 | $atomic{ |
| 23 | init(); | |
| [b482f11] | 24 | COMM_WORLD = $gcomm_create($here, NPROCS); |
| 25 | __start = 1; | |
| [18cad8a] | 26 | finalize(); |
| [07f7630] | 27 | $gcomm_destroy(COMM_WORLD, NULL); |
| [18cad8a] | 28 | } |
| [0be7a7ea] | 29 | } |
Note:
See TracBrowser
for help on using the repository browser.
