SimplePUP example which uses PUP to pass a simple object along
authorEric Bohm <ebohm@illinois.edu>
Mon, 30 Jul 2012 23:07:48 +0000 (18:07 -0500)
committerEric Bohm <ebohm@illinois.edu>
Tue, 31 Jul 2012 15:58:57 +0000 (10:58 -0500)
a chare array.
Move pupDisk into PUP dir to unify PUP oriented examples hierarchically

examples/charm++/PUP/Makefile [new file with mode: 0644]
examples/charm++/PUP/SimpleObject.h [new file with mode: 0644]
examples/charm++/PUP/SimplePUP.C [new file with mode: 0644]
examples/charm++/PUP/SimplePUP.ci [new file with mode: 0644]
examples/charm++/PUP/SimplePUP.h [new file with mode: 0644]
examples/charm++/PUP/pupDisk/README [moved from examples/charm++/pupDisk/README with 100% similarity]
examples/charm++/PUP/pupDisk/pupDisk.C [moved from examples/charm++/pupDisk/pupDisk.C with 100% similarity]
examples/charm++/PUP/pupDisk/pupDisk.h [moved from examples/charm++/pupDisk/pupDisk.h with 100% similarity]
examples/charm++/PUP/pupDisk/someData.h [moved from examples/charm++/pupDisk/someData.h with 100% similarity]
examples/charm++/pupDisk/Makefile [deleted file]
examples/charm++/pupDisk/pupDisk.ci [deleted file]

diff --git a/examples/charm++/PUP/Makefile b/examples/charm++/PUP/Makefile
new file mode 100644 (file)
index 0000000..4bc5c10
--- /dev/null
@@ -0,0 +1,24 @@
+CHARMC=../../../bin/charmc $(OPTS)
+
+OBJS = SimplePUP.o
+
+all: SimplePUP
+
+SimplePUP: $(OBJS)
+       $(CHARMC) -language charm++ -o SimplePUP $(OBJS)
+
+SimplePUP.decl.h: SimplePUP.ci
+       $(CHARMC)  SimplePUP.ci
+
+clean:
+       rm -f *.decl.h *.def.h conv-host *.o SimplePUP charmrun
+
+SimplePUP.o: SimplePUP.C SimplePUP.h SimpleObject.h SimplePUP.decl.h
+       $(CHARMC) -c SimplePUP.C
+
+test: all
+       ./charmrun SimplePUP +p4  $(TESTOPTS)
+       ./charmrun SimplePUP +p4  $(TESTOPTS)
+
+bgtest: all
+       ./charmrun SimplePUP +p4 +x2 +y2 +z1
diff --git a/examples/charm++/PUP/SimpleObject.h b/examples/charm++/PUP/SimpleObject.h
new file mode 100644 (file)
index 0000000..1b4e252
--- /dev/null
@@ -0,0 +1,32 @@
+class SimpleObject
+{
+
+ public:
+
+  int publicInt;
+
+ SimpleObject(int param1, bool param2):publicInt(param1), privateBool(param2) {}
+
+ SimpleObject():publicInt(0), privateBool(false) {}
+ void pup(PUP::er &p)
+ {
+      // remember to pup your superclass if there is one
+   p|publicInt;
+   p|privateBool;
+ }
+
+ void doWork()
+ {
+   // here is where a useful object would do something
+   publicInt++;
+   privateBool=publicInt<20;
+ }
+
+ ~SimpleObject(){}
+
+ private:
+
+  // PUP is orthogonal to public vs private member choices
+  bool privateBool;
+
+};
diff --git a/examples/charm++/PUP/SimplePUP.C b/examples/charm++/PUP/SimplePUP.C
new file mode 100644 (file)
index 0000000..093dda8
--- /dev/null
@@ -0,0 +1,22 @@
+/////////////////////////////////////
+//
+//  SimplePUP.C
+//
+//  Definition of chares in SimplePUP
+//
+//  Author: Eric Bohm
+//  Date: 2012/7/30
+//
+/////////////////////////////////////
+
+#include "SimplePUP.h"
+
+main::main(CkArgMsg *m)
+{
+  
+  CProxy_SimpleArray simpleProxy= CProxy_SimpleArray::ckNew(30);
+  SimpleObject exampleObject(20,false);
+  simpleProxy[29].acceptData(exampleObject);
+}
+
+#include "SimplePUP.def.h"
diff --git a/examples/charm++/PUP/SimplePUP.ci b/examples/charm++/PUP/SimplePUP.ci
new file mode 100644 (file)
index 0000000..94b1754
--- /dev/null
@@ -0,0 +1,23 @@
+////////////////////////////////////////////////
+//
+//  SimplePUP.ci
+//
+//  Interface file for SimplePUP
+//
+//  Author: Eric Bohm
+//  Date: 2012/7/30
+//
+////////////////////////////////////////////////
+
+mainmodule SimplePUP {
+  include "SimpleObject.h";
+  mainchare main {
+    entry main(CkArgMsg *m);
+  };
+
+  array [1D] SimpleArray{
+    entry SimpleArray();
+    entry void acceptData(SimpleObject &inData);
+  };
+
+};
diff --git a/examples/charm++/PUP/SimplePUP.h b/examples/charm++/PUP/SimplePUP.h
new file mode 100644 (file)
index 0000000..bec28e6
--- /dev/null
@@ -0,0 +1,58 @@
+///////////////////////////////////////
+//
+//  SimplePUP.h  
+//
+//  Declaration of chares in SimplePUP
+//
+//  Author: Eric Bohm
+//  Date: 2012/01/23
+//
+///////////////////////////////////////
+
+#include "SimplePUP.decl.h"
+
+class main : public CBase_main {
+
+public:
+
+  main(CkMigrateMessage *m) {}
+
+  main(CkArgMsg *m);
+
+};
+
+
+class SimpleArray : public CBase_SimpleArray {
+
+ public:
+  
+  SimpleArray(CkMigrateMessage *m) {}
+
+  SimpleArray(){}
+
+  void done(){
+    CkPrintf("done int %d\n",localCopy.publicInt);
+    CkExit();
+  }
+
+  ~SimpleArray(){}
+
+  void acceptData(SimpleObject &inData){
+    localCopy=inData;
+    localCopy.doWork();
+    if(thisIndex==0) //no one lower to pass to
+      {
+       done();
+      }
+    else
+      { // pass object down one index
+       thisProxy[thisIndex-1].acceptData(localCopy);
+      }
+  }
+
+ private:
+
+  SimpleObject localCopy;
+
+};
+
diff --git a/examples/charm++/pupDisk/Makefile b/examples/charm++/pupDisk/Makefile
deleted file mode 100644 (file)
index 6de4fc8..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-CHARMC=../../../bin/charmc $(OPTS)
-
-OBJS = pupDisk.o
-
-all: pupDisk
-
-pupDisk: $(OBJS)
-       $(CHARMC) -language charm++ -o pupDisk $(OBJS)
-
-pupDisk.decl.h: pupDisk.ci
-       $(CHARMC)  pupDisk.ci
-
-clean:
-       rm -f *.decl.h *.def.h conv-host *.o pupDisk charmrun
-
-pupDisk.o: pupDisk.C pupDisk.h someData.h pupDisk.decl.h
-       $(CHARMC) -c pupDisk.C
-
-test: all
-       ./charmrun pupDisk +p4 10 20 4 $(TESTOPTS)
-       ./charmrun pupDisk +p4 10 20 4 r $(TESTOPTS)
-
-bgtest: all
-       ./charmrun pupDisk +p4 10 +x2 +y2 +z1
diff --git a/examples/charm++/pupDisk/pupDisk.ci b/examples/charm++/pupDisk/pupDisk.ci
deleted file mode 100644 (file)
index 04e1f2a..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-////////////////////////////////////////////////
-//
-//  pupDisk.ci
-//
-//  Interface file for pupDisk
-//
-//  Author: Eric Bohm
-//  Date: 2012/1/23
-//
-////////////////////////////////////////////////
-
-mainmodule pupDisk {
-  include "someData.h";
-  readonly CkCallback icb;
-  readonly CkCallback wcb;
-  readonly CkCallback rcb;
-  readonly CkCallback vcb;
-  readonly CProxy_userData userDataProxy;
-  readonly CProxy_pupDisk pupDiskProxy;
-  readonly int numElementsPer;
-  mainchare main {
-    entry main();
-    entry void done(CkReductionMsg *);
-    entry void initialized(CkReductionMsg *);
-    entry void written(CkReductionMsg *);
-    entry void read(CkReductionMsg *);
-
-  };
-  group pupDiskMap : CkArrayMap {
-          entry pupDiskMap(int maxFiles);
-  };
-
-  array [1D] userData{
-    entry userData(int howbig, int numElements, int maxFiles);
-    entry void init();
-    entry void write();
-    entry void read();
-    entry void verify();    
-    entry void acceptData(someData &inData);
-  };
-
-  array [1D] pupDisk{
-    entry pupDisk(int howbig, int numElements, int maxFiles);
-    entry void write(int sender, someData &data);
-    entry void read(int sender);
-  };
-
-};