added a reduction operation "nop" which does nothing.
[charm.git] / tests / charm++ / megatest / groupcast.C
1 #include "groupcast.h"
2
3 void groupcast_moduleinit(void) {}
4
5 void groupcast_init(void) 
6 {
7   CProxy_groupcast_main::ckNew(0);
8 }
9
10 groupcast_main::groupcast_main(void) 
11 {
12   count = 0;
13   groupcast_SimpleMsg *sm = new groupcast_SimpleMsg;
14   sm->mainhandle = thishandle;
15   gid=CProxy_groupcast_group::ckNew(sm);
16 }
17
18 void groupcast_main::groupReady() {
19   count++;
20   if (count < 3) {
21     CProxy_groupcast_group groupproxy(gid);
22     groupcast_BCMsg *g_bcm = new groupcast_BCMsg;
23     groupproxy.doBroadcast(g_bcm);
24   } else {
25       delete this;
26       megatest_finish();
27   }
28 }
29
30 groupcast_group::groupcast_group(groupcast_SimpleMsg *sm) {
31   myMain = sm->mainhandle;
32   CkCallback cb(CkIndex_groupcast_main::groupReady(),myMain);
33   contribute(0,0,CkReduction::sum_int,cb);
34 }
35
36 void groupcast_group::doBroadcast(groupcast_BCMsg *bcm) {
37   if (!bcm->check()) {
38     CkAbort("Broadcasted message fails check.\n");
39   }
40   delete bcm;
41   CkCallback cb(CkIndex_groupcast_main::groupReady(),myMain);
42   contribute(0,0,CkReduction::nop,cb);
43 }
44
45 MEGATEST_REGISTER_TEST(groupcast,"mjlang",1)
46 #include "groupcast.def.h"