demand creation test
authorEhsan Totoni <etotoni@disneyanimation.com>
Sat, 21 Jul 2012 04:43:43 +0000 (21:43 -0700)
committerEhsan Totoni <etotoni@disneyanimation.com>
Sat, 21 Jul 2012 04:43:43 +0000 (21:43 -0700)
tests/charm++/demand_creation/Makefile [new file with mode: 0644]
tests/charm++/demand_creation/hello.C [new file with mode: 0644]
tests/charm++/demand_creation/hello.ci [new file with mode: 0644]

diff --git a/tests/charm++/demand_creation/Makefile b/tests/charm++/demand_creation/Makefile
new file mode 100644 (file)
index 0000000..774fcfa
--- /dev/null
@@ -0,0 +1,23 @@
+CHARMC=../../../bin/charmc $(OPTS)
+
+OBJS = hello.o
+
+all: hello
+
+hello: $(OBJS)
+       $(CHARMC) -language charm++ -o hello $(OBJS)
+
+hello.decl.h: hello.ci
+       $(CHARMC) hello.ci
+
+clean:
+       rm -f *.decl.h *.def.h conv-host *.o hello charmrun *.log *.sum *.sts
+
+hello.o: hello.C hello.decl.h
+       $(CHARMC) -c -O2 hello.C
+
+test: all
+       ./charmrun ./hello +p4 10 $(TESTOPTS)
+
+bgtest: all
+       ./charmrun ./hello +p4 10 +x2 +y2 +z2 +cth1 +wth1 +bglog $(TESTOPTS)
diff --git a/tests/charm++/demand_creation/hello.C b/tests/charm++/demand_creation/hello.C
new file mode 100644 (file)
index 0000000..65e54bc
--- /dev/null
@@ -0,0 +1,69 @@
+/** \file hello.C
+ *  Author: Ehsan Totoni 
+ *  Date Created: July 20, 2012
+ */
+
+#include "hello.decl.h"
+#include <stdio.h>
+
+/*readonly*/ CProxy_Main mainProxy;
+
+/** \class Main
+ *
+ */
+class Main : public CBase_Main
+{
+public:
+  CProxy_Hello arr;
+  int counter;
+
+  Main(CkArgMsg* m)
+  {
+    //Start the computation
+    CkPrintf("Running Hello on %d processors \n",
+            CkNumPes());
+    mainProxy = thisProxy;
+
+    arr = CProxy_Hello::ckNew();
+    arr.doneInserting();
+    counter = 0;
+    CkPrintf("Array created\n");
+
+    arr(0, 0, 0).SayHi(0);
+    arr(0, 4, 8).SayHi(1);
+    arr(20, 3, 7).SayHi(2);
+    arr(8, 0, 4).SayHi(3);
+  };
+
+  void done(void)
+  {
+    counter++;
+    if(counter == 4) {
+      CkPrintf("All done\n");
+      CkExit();
+    }
+  };
+};
+
+/** \class Hello
+ *
+ */
+class Hello : public CBase_Hello 
+{
+public:
+  Hello()
+  {
+    CkPrintf("Hello %d %d %d created\n", thisIndex.x, thisIndex.y, thisIndex.z);
+  }
+
+  Hello(CkMigrateMessage *m) {}
+  
+  void SayHi(int hiNo)
+  {
+    CkPrintf("Hi [%d] from element %d %d %d\n", hiNo, thisIndex.x, thisIndex.y, thisIndex.z);
+    mainProxy.done();
+  }
+
+};
+
+#include "hello.def.h"
diff --git a/tests/charm++/demand_creation/hello.ci b/tests/charm++/demand_creation/hello.ci
new file mode 100644 (file)
index 0000000..8ac7202
--- /dev/null
@@ -0,0 +1,13 @@
+mainmodule hello {
+  readonly CProxy_Main mainProxy;
+  mainchare Main {
+    entry Main(CkArgMsg *m);
+    entry void done(void);
+  };
+
+  array [3D] Hello {
+    entry Hello(void);
+    entry [createhere] void SayHi(int hiNo);
+  };
+
+};