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:
993 bytes
|
| Line | |
|---|
| 1 | /* Create 2 processes. Have them exchange data in a cycle.
|
|---|
| 2 | * Command line verification example:
|
|---|
| 3 | * civl verify ring3.cvl
|
|---|
| 4 | */
|
|---|
| 5 | #include<comm.cvh>
|
|---|
| 6 | #define TAG 0
|
|---|
| 7 |
|
|---|
| 8 | $gcomm GCOMM_WORLD = $gcomm_create($here, 2); // global comm object
|
|---|
| 9 |
|
|---|
| 10 | void MPI_Process (int rank) {
|
|---|
| 11 | $comm comm = $comm_create($here, GCOMM_WORLD, rank);
|
|---|
| 12 | int dest = 1-rank;
|
|---|
| 13 | int *x, *y;
|
|---|
| 14 | $message in, out;
|
|---|
| 15 |
|
|---|
| 16 | x = (int*)$malloc($here, sizeof(int));
|
|---|
| 17 | y = (int*)$malloc($here, sizeof(int));
|
|---|
| 18 | *x = rank;
|
|---|
| 19 | out = $message_pack(rank, dest, TAG, x, sizeof(int));
|
|---|
| 20 | $choose {
|
|---|
| 21 | $when (1){
|
|---|
| 22 | $comm_enqueue(comm, out);
|
|---|
| 23 | in = $comm_dequeue(comm, dest, TAG);
|
|---|
| 24 | }
|
|---|
| 25 | $when (1){
|
|---|
| 26 | in = $comm_dequeue(comm, dest, TAG);
|
|---|
| 27 | $comm_enqueue(comm, out);
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
| 30 | $message_unpack(in, y, sizeof(int));
|
|---|
| 31 | $free(x);
|
|---|
| 32 | $free(y);
|
|---|
| 33 | $comm_destroy(comm);
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | void main() {
|
|---|
| 37 | // for (int i=0; i<2; i++) $spawn MPI_Process(i);
|
|---|
| 38 | $parfor (int i : ($domain){0 .. 1}) MPI_Process(i);
|
|---|
| 39 | $gcomm_destroy(GCOMM_WORLD, NULL);
|
|---|
| 40 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.