source: CIVL/examples/library/civlc/commTest.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: 607 bytes
Line 
1#include<comm.cvh>
2
3$input int N=2;
4$input int M=2;
5
6$gcomm gcomm=$gcomm_create($here, N);
7
8void process(int id){
9 $comm comm=$comm_create($here, gcomm, id);
10
11 void thread(int tid){
12 int size, src;
13 $message msg;
14 int data=(id+1)*(id+1);
15
16 size=$comm_size(comm);
17 src=$comm_place(comm);
18 msg=$message_pack(src, (src+1)%N, 0, &data, sizeof(int));
19 $comm_enqueue(comm, msg);
20 msg=$comm_dequeue(comm, (src-1)%N, 0);
21 }
22 $parfor(int i: 0 .. M-1)
23 thread(i);
24 $comm_destroy(comm);
25}
26
27int main(void){
28 $parfor(int i: 0 .. N-1)
29 process(i);
30 $gcomm_destroy(gcomm, NULL);
31}
Note: See TracBrowser for help on using the repository browser.