source: CIVL/examples/concurrency/wildcard.cvl

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
RevLine 
[3ff27cf]1#include <civlc.cvh>
[82d7b5f]2#include <stdio.h>
[e936ca5]3#include <comm.cvh>
[a96092d]4#include <assert.h>
[e936ca5]5#include <seq.cvh>
[82d7b5f]6
[e936ca5]7#define ANY_SRC -1
[a3da6fb]8#define NPROCS 3
[d66b03b]9$scope root = $here;
[e936ca5]10$gcomm gcomm;
11
12void 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);
[82d7b5f]26 }
[e936ca5]27 } else {
28 int size = sizeof(int);
29
30 msg = $message_pack(place, 0, 0, &place, size);
31 $comm_enqueue(comm, msg);
[82d7b5f]32 }
[e936ca5]33 $comm_destroy(comm);
[82d7b5f]34}
35
36void main(){
[e936ca5]37 $message junkMsgs[];
[82d7b5f]38
[e936ca5]39 $seq_init(&junkMsgs, 0, NULL);
40 gcomm = $gcomm_create(root, NPROCS);
41 $parfor(int i : 0 .. (NPROCS-1))
42 process(i);
[1776869]43 $gcomm_destroy(gcomm, &junkMsgs);
[82d7b5f]44}
Note: See TracBrowser for help on using the repository browser.