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:
918 bytes
|
| Line | |
|---|
| 1 | #include <civlc.cvh>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 | #include <comm.cvh>
|
|---|
| 4 | #include <assert.h>
|
|---|
| 5 | #include <seq.cvh>
|
|---|
| 6 |
|
|---|
| 7 | #define ANY_SRC -1
|
|---|
| 8 | #define NPROCS 3
|
|---|
| 9 | $scope root = $here;
|
|---|
| 10 | $gcomm gcomm;
|
|---|
| 11 |
|
|---|
| 12 | void process(int place){
|
|---|
| 13 | $comm comm = $comm_create($here, gcomm, place);
|
|---|
| 14 | $message msg;
|
|---|
| 15 |
|
|---|
| 16 | if (place == 0){
|
|---|
| 17 | for (int i = 1; i < NPROCS; i++) {
|
|---|
| 18 | int msg_size;
|
|---|
| 19 | int buf;
|
|---|
| 20 |
|
|---|
| 21 | msg = $comm_dequeue(comm, ANY_SRC, 0);
|
|---|
| 22 | msg_size = $message_size(msg);
|
|---|
| 23 | $message_unpack(msg, &buf, msg_size);
|
|---|
| 24 | assert(buf >= 1 && buf < NPROCS);
|
|---|
| 25 | printf("root get %d\n", buf);
|
|---|
| 26 | }
|
|---|
| 27 | } else {
|
|---|
| 28 | int size = sizeof(int);
|
|---|
| 29 |
|
|---|
| 30 | msg = $message_pack(place, 0, 0, &place, size);
|
|---|
| 31 | $comm_enqueue(comm, msg);
|
|---|
| 32 | }
|
|---|
| 33 | $comm_destroy(comm);
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | void main(){
|
|---|
| 37 | $message junkMsgs[];
|
|---|
| 38 |
|
|---|
| 39 | $seq_init(&junkMsgs, 0, NULL);
|
|---|
| 40 | gcomm = $gcomm_create(root, NPROCS);
|
|---|
| 41 | $parfor(int i : 0 .. (NPROCS-1))
|
|---|
| 42 | process(i);
|
|---|
| 43 | $gcomm_destroy(gcomm, &junkMsgs);
|
|---|
| 44 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.