a test for CkSendMsgBranchGroup
authorGengbin Zheng <gzheng@gzheng-desktop.(none)>
Fri, 19 Feb 2010 05:46:47 +0000 (23:46 -0600)
committerGengbin Zheng <gzheng@gzheng-desktop.(none)>
Fri, 19 Feb 2010 05:46:47 +0000 (23:46 -0600)
tests/charm++/megatest/Make.depends
tests/charm++/megatest/Makefile
tests/charm++/megatest/groupmulti.C [new file with mode: 0644]
tests/charm++/megatest/groupmulti.ci [new file with mode: 0644]
tests/charm++/megatest/groupmulti.h [new file with mode: 0644]

index dfd20ef724ef0509df21958809b1aeac12ee18d4..e080a1840253d6b78250285d5388b9149de3ab40 100644 (file)
@@ -40,6 +40,13 @@ groupcast.o: \
        groupcast.decl.h \
        groupcast.def.h
        $(CHARMC) -o groupcast.o groupcast.C
+groupmulti.o: \
+       groupmulti.C \
+       groupmulti.h \
+       megatest.h \
+       groupmulti.decl.h \
+       groupmulti.def.h
+       $(CHARMC) -o groupmulti.o groupmulti.C
 groupsectiontest.o: \
        groupsectiontest.C \
        groupsectiontest.h \
index 5b4461f8752a9492f19eb63efb93a9317af3001f..ba7037dcec061f5bb0c2072841a58041616d56a9 100644 (file)
@@ -8,6 +8,7 @@ OBJS=megatest.o \
      varsizetest.o \
      varraystest.o \
      groupcast.o \
+     groupmulti.o \
      groupsectiontest.o \
      multisectiontest.o \
      nodecast.o \
@@ -56,6 +57,7 @@ OBJS_REV=megatest.o \
      synctest.o \
      nodecast.o \
      groupcast.o \
+     groupmulti.o \
      groupsectiontest.o \
      multisectiontest.o \
      varraystest.o \
@@ -73,7 +75,8 @@ CIFILES =  \
       fib.def.h        megatest.def.h       priotest.def.h   tempotest.def.h  \
       groupcast.def.h  migration.def.h      queens.def.h     varraystest.def.h\
       groupring.def.h  nodecast.def.h       reduction.def.h  varsizetest.def.h\
-      groupsectiontest.def.h multisectiontest.def.h inlineem.def.h #priolongtest.def.h
+      groupsectiontest.def.h multisectiontest.def.h inlineem.def.h \
+      groupmulti.def.h #priolongtest.def.h
 
 .SUFFIXES:
 .SUFFIXES: .o .C .def.h .decl.h .ci .h
diff --git a/tests/charm++/megatest/groupmulti.C b/tests/charm++/megatest/groupmulti.C
new file mode 100644 (file)
index 0000000..5cc8cc9
--- /dev/null
@@ -0,0 +1,53 @@
+#include "groupmulti.h"
+
+CmiGroup cgrp;
+
+void groupmulti_moduleinit(void) {}
+
+void groupmulti_init(void) 
+{
+  CProxy_groupmulti_main::ckNew(0);
+}
+
+groupmulti_main::groupmulti_main(void) 
+{
+  count = 0;
+  int npes = CkNumPes();
+  int *pes = new int[npes];
+  for (int i=0; i<npes; i++) pes[i] = i;
+  CmiEstablishGroup(npes, pes);
+  groupmulti_SimpleMsg *sm = new groupmulti_SimpleMsg;
+  sm->mainhandle = thishandle;
+  gid=CProxy_groupmulti_group::ckNew(sm);
+}
+
+void groupmulti_main::groupReady() {
+  count++;
+  if (count < 3) {
+    CProxy_groupmulti_group groupproxy(gid);
+    groupmulti_BCMsg *g_bcm = new groupmulti_BCMsg;
+//    groupproxy.doBroadcast(g_bcm); 
+      CkSendMsgBranchGroup(CkIndex_groupmulti_group::doBroadcast(NULL), g_bcm, gid, cgrp, 0);
+  } else {
+      delete this;
+      megatest_finish();
+  }
+}
+
+groupmulti_group::groupmulti_group(groupmulti_SimpleMsg *sm) {
+  myMain = sm->mainhandle;
+  CkCallback cb(CkIndex_groupmulti_main::groupReady(),myMain);
+  contribute(0,0,CkReduction::sum_int,cb);
+}
+
+void groupmulti_group::doBroadcast(groupmulti_BCMsg *bcm) {
+  if (!bcm->check()) {
+    CkAbort("Broadcasted message fails check.\n");
+  }
+  delete bcm;
+  CkCallback cb(CkIndex_groupmulti_main::groupReady(),myMain);
+  contribute(0,0,CkReduction::sum_int,cb);
+}
+
+MEGATEST_REGISTER_TEST(groupmulti,"gengbin",1)
+#include "groupmulti.def.h"
diff --git a/tests/charm++/megatest/groupmulti.ci b/tests/charm++/megatest/groupmulti.ci
new file mode 100644 (file)
index 0000000..d9b0111
--- /dev/null
@@ -0,0 +1,16 @@
+module groupmulti {
+  readonly CmiGroup cgrp;
+
+  message groupmulti_SimpleMsg;
+  message groupmulti_BCMsg;
+
+  chare groupmulti_main {
+    entry groupmulti_main(void);
+    entry void groupReady(void);
+  };
+
+  group groupmulti_group {
+    entry groupmulti_group(groupmulti_SimpleMsg *);
+    entry void doBroadcast(groupmulti_BCMsg *);
+  };
+};
diff --git a/tests/charm++/megatest/groupmulti.h b/tests/charm++/megatest/groupmulti.h
new file mode 100644 (file)
index 0000000..e8e4166
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef _GROUPCAST_H
+#define _GROUPCAST_H
+
+#include "megatest.h"
+#include "groupmulti.decl.h"
+
+class groupmulti_SimpleMsg : public CMessage_groupmulti_SimpleMsg {
+public:
+  CkGroupID gid;
+  CkChareID mainhandle;
+};
+
+class groupmulti_BCMsg : public CMessage_groupmulti_BCMsg {
+private:
+  double dval;
+  char checkString[11];
+public:
+  groupmulti_BCMsg(void) { dval = 3.145; sprintf(checkString, "Multicast!");} 
+  groupmulti_BCMsg(CkMigrateMessage *m) {}
+  int check(void) { 
+    if (strcmp("Multicast!", checkString) == 0 && dval == 3.145)
+      return 1;
+    else
+      return 0;
+  }
+};
+
+class groupmulti_main : public Chare {
+private:
+  CkGroupID gid;
+  int count;
+public:
+  groupmulti_main(void);
+  groupmulti_main(CkMigrateMessage *m) {}
+  void groupReady(void);
+};
+
+class groupmulti_group : public Group {
+private:
+  CkChareID myMain;
+public:
+  groupmulti_group(groupmulti_SimpleMsg *sm);
+  groupmulti_group(CkMigrateMessage *m) {}
+  void doBroadcast(groupmulti_BCMsg *bcm);
+};
+
+#endif