source: CIVL/examples/languageFeatures/comm.cvl@ 90dd7d7

1.23 2.0 main test-branch
Last change on this file since 90dd7d7 was 6a71c30, checked in by Tim Zirkel <zirkeltk@…>, 13 years ago

Updated comm example. Fixed bug causing erroneous true being returned from verify. Fixed handling of bundleable types.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@215 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 671 bytes
Line 
1#include <civlc.h>
2
3void worker(int value) {
4 for (int i = 0; i < value; i++) {
5 ; // Do work
6 }
7}
8
9void main() {
10 int nprocs = 3;
11 $proc procs[nprocs];
12 $comm comm;
13 $message message;
14 $message message2;
15 int comm_size;
16
17 procs[0] = $self;
18 procs[1] = $spawn worker(4);
19 procs[2] = $spawn worker(5);
20 comm = $comm_create(nprocs, procs);
21 message = $message_pack(0, 1, 0, &nprocs, sizeof(int));
22 $comm_enqueue(&comm, message);
23 $comm_enqueue(&comm, message);
24 $comm_enqueue(&comm, message);
25 comm_size = $comm_total_size(&comm);
26 $assert comm_size <= 3;
27 message2 = $comm_dequeue(&comm, 0, 1, 0);
28 $assert message.source == message2.source;
29
30}
Note: See TracBrowser for help on using the repository browser.