Adding PHOLD Benchmark for PDES.
authorTerry L. Wilmarth <wilmarth@uiuc.edu>
Thu, 28 Jul 2005 22:33:16 +0000 (22:33 +0000)
committerTerry L. Wilmarth <wilmarth@uiuc.edu>
Thu, 28 Jul 2005 22:33:16 +0000 (22:33 +0000)
Task: POSE

examples/pose/PHOLD/Makefile [new file with mode: 0644]
examples/pose/PHOLD/Worker.C [new file with mode: 0644]
examples/pose/PHOLD/Worker.ci [new file with mode: 0644]
examples/pose/PHOLD/Worker.h [new file with mode: 0644]
examples/pose/PHOLD/phold.C [new file with mode: 0644]
examples/pose/PHOLD/phold.ci [new file with mode: 0644]
examples/pose/PHOLD/phold.h [new file with mode: 0644]

diff --git a/examples/pose/PHOLD/Makefile b/examples/pose/PHOLD/Makefile
new file mode 100644 (file)
index 0000000..abd89e0
--- /dev/null
@@ -0,0 +1,124 @@
+# NOTE: This is the basic Makefile template that includes the additional
+#       Makefile.simulation makefile that is found in the location of the
+#       current installation of POSE.
+#
+#      The Makefile.simulation set of rules allows the compilation of
+#       a SINGLE simulation module. If multiple simulation modules are
+#      desired, some "surgery" of Makefile.simulation (and this file)
+#      will be required. 
+#
+# ***********************************************************************
+
+OPTS=-O#-DCMK_OPTIMIZE=1 -DCMK_MEMCHECKS_OFF=1
+
+CHARMBASE=../../..
+CHARMBIN=$(CHARMBASE)/bin
+CHARMINC=$(CHARMBASE)/include
+
+CHARMC=$(CHARMBIN)/charmc -I$(CHARMINC)/pose $(OPTS)
+
+# Default Location variables
+# **************************
+#POSE_ROOT=$(HOME)/charm/net-linux/lib
+
+# Default module names
+# - MAKE MODIFICATIONS HERE
+# *************************
+PGM_MODULE=PHOLD
+PGM=phold
+OTHER=
+LIBS=-Lstdc++ -lm
+
+# Simulation object definitions 
+# *****************************
+SIM_OBJECTS=Worker_sim.o $(PGM).o 
+
+# EXECUTABLE GENERATION RULES 
+# - DO NOT MODIFY
+#****************************
+base:  $(PGM)
+       @echo "Simulation compiled."
+
+pure:   $(PGM).pure
+       @echo "Simulation (w purify) compiled."
+
+proj:   $(PGM).proj
+       @echo "Simulation (w projections log traces) compiled."
+
+summary:    $(PGM).summary
+       @echo "Simulation (w summary log traces) compiled."
+
+$(PGM):        $(SIM_OBJECTS) 
+       $(CHARMC) $(SIM_OBJECTS) $(OTHER) $(LIBS) -o $(PGM) \
+       -module pose -language charm++
+
+$(PGM).seq:    $(SIM_OBJECTS) 
+       $(CHARMC) $(SIM_OBJECTS) $(OTHER) $(LIBS) -o $(PGM).seq \
+       -module seqpose -language charm++
+
+$(PGM).seq.proj:       $(SIM_OBJECTS) 
+       $(CHARMC) $(SIM_OBJECTS) $(OTHER) $(LIBS) -o $(PGM).seq.proj \
+       -module seqpose -language charm++ -tracemode projections
+
+$(PGM).alt:    $(SIM_OBJECTS) 
+       $(CHARMC) $(SIM_OBJECTS) $(OTHER) $(LIBS) -o $(PGM).alt \
+       -module pose -language charm++
+
+$(PGM).comm:   $(SIM_OBJECTS) 
+       $(CHARMC) $(SIM_OBJECTS) $(OTHER) $(LIBS) -o $(PGM).comm \
+       -lpose -language charm++ -module commlib
+
+$(PGM).pure:   $(SIM_OBJECTS)
+       $(CHARMC) $(SIM_OBJECTS) $(OTHER) $(LIBS) -o $(PGM).pure \
+       -lpose -language charm++ -purify
+
+$(PGM).proj:   $(SIM_OBJECTS)
+       $(CHARMC) $(SIM_OBJECTS) $(OTHER) $(LIBS) -o $(PGM).proj \
+       -module pose -language charm++ -tracemode projections
+
+$(PGM).summary:        $(SIM_OBJECTS)
+       $(CHARMC) $(SIM_OBJECTS) $(OTHER) $(LIBS) -o $(PGM).summary \
+       -lpose -language charm++ -tracemode summary
+
+# HOUSE-KEEPING RULES
+# - DO NOT MODIFY
+#********************
+
+# clean removes everything
+clean: clear rm_logs ;
+
+# clear removes only binaries and generated files
+clear:
+       rm -f charmrun conv-host *.o
+       rm -f *.def.h *.decl.h
+       rm -f $(PGM) $(PGM).pure $(PGM).proj $(PGM).summary
+       rm -f gmon.out #*#
+       rm -f core *~
+       rm -f TAGS *.headers
+       rm -f *_sim.*
+
+# rm_logs removes projections/summary log traces
+rm_logs:
+       rm -f [^j]*.log *.sum [^j]*.sts
+       rm -f *-bg.*.log *-bg.sts
+
+# SIMULATION COMPILATION RULES
+# - DO NOT MODIFY 
+#*****************************
+$(PGM).o :     $(PGM).C $(PGM).h $(PGM_MODULE).def.h $(PGM_MODULE).decl.h
+       $(CHARMC) -c -I$(CHARMINC) $(INCLUDES) $(LIBS) $(PGM).C
+
+$(PGM_MODULE).def.h $(PGM_MODULE).decl.h : $(PGM).ci
+       $(CHARMC) $(INCLUDES) $(LIBS) $(PGM).ci
+
+Worker_sim.o : Worker_sim.C Worker_sim.h Worker.def.h Worker.decl.h
+       $(CHARMC) -c $(LIBS) $(INCLUDES) -I$(CHARMINC) Worker_sim.C
+
+Worker.def.h Worker.decl.h : Worker_sim.ci
+       $(CHARMC) $(INCLUDES) $(LIBS) Worker_sim.ci
+
+Worker_sim.C Worker_sim.h Worker_sim.ci: Worker.C Worker.h Worker.ci 
+       $(CHARMBIN)/etrans.pl Worker
+
+test:
+       ./pgm 1000 100 SMALL 50 -gf 200
diff --git a/examples/pose/PHOLD/Worker.C b/examples/pose/PHOLD/Worker.C
new file mode 100644 (file)
index 0000000..ea7d404
--- /dev/null
@@ -0,0 +1,80 @@
+worker::worker(WorkerData *m)
+{
+  int i;
+  numObjs = m->numObjs;
+  numMsgs = m->numMsgs;
+  tscale = m->tscale;
+  locality = m->locality;
+  grainSize = m->grainSize;
+  granularity = m->granularity;
+  delete m;
+  POSE_srand(myHandle);
+  WorkMsg *wm;
+  if (myHandle == 0) { // populate system with messages
+    for (int i=0; i<numMsgs; i++) {
+      wm = new WorkMsg;
+      wm->fromPE = -1;
+      POSE_invoke(work(wm), worker, POSE_rand()%numObjs, POSE_rand()%(tscale/100));
+    }
+  }
+}
+
+worker::worker()
+{
+}
+
+worker& worker::operator=(const worker& obj)
+{
+  int i;
+  rep::operator=(obj);
+  numObjs = obj.numObjs;
+  numMsgs = obj.numMsgs;
+  tscale = obj.tscale;
+  locality = obj.locality;
+  grainSize = obj.grainSize;
+  granularity = obj.granularity;
+  return *this;
+}
+
+void worker::work(WorkMsg *m)
+{
+  //CkPrintf("%d receiving work at %d\n", parent->thisIndex, ovt);
+  WorkMsg *wm;
+  int nbr=-1, away, sign, offset;
+
+  // fake computation
+  if (granularity > 0.0) POSE_busy_wait(granularity);
+  else if (grainSize == FINE) POSE_busy_wait(FINE_GRAIN);
+  else if (grainSize == MEDIUM_GS) POSE_busy_wait(MEDIUM_GRAIN);
+  else if (grainSize == COARSE) POSE_busy_wait(COARSE_GRAIN);
+  else if (grainSize == MIX_GS) {
+    int gsIdx = POSE_rand() % 3;
+    if (gsIdx == 0) POSE_busy_wait(FINE_GRAIN);
+    else if (gsIdx == 1) POSE_busy_wait(MEDIUM_GRAIN);
+    else POSE_busy_wait(COARSE_GRAIN);
+  }
+ // generate an event
+  if (OVT() < tscale) {
+    wm = new WorkMsg;
+    wm->fromPE = myHandle;
+    offset = POSE_rand() % (tscale/100);
+    while ((nbr < 0) || (nbr >= numObjs)) {
+      away = (POSE_rand() % locality) + 1;
+      sign = POSE_rand() % 2;
+      if (sign) nbr = myHandle+away;
+      else nbr = myHandle-away;
+    }
+    POSE_invoke(work(wm), worker, nbr, offset);
+    //CkPrintf("%d sending work to %d at %d. Sent=%d\n",myHandle,nbr,ovt,sent);
+  }
+}
+
+void worker::work_anti(WorkMsg *m)
+{
+  restore(this);
+}
+
+void worker::work_commit(WorkMsg *m)
+{
+}
diff --git a/examples/pose/PHOLD/Worker.ci b/examples/pose/PHOLD/Worker.ci
new file mode 100644 (file)
index 0000000..e442d21
--- /dev/null
@@ -0,0 +1,12 @@
+message WorkerData;
+message WorkMsg;
+
+poser worker : sim adapt4 chpt {
+  entry worker(WorkerData *);
+  // Event methods
+  entry [event] void work(WorkMsg *);
+};
+
+
+
+
diff --git a/examples/pose/PHOLD/Worker.h b/examples/pose/PHOLD/Worker.h
new file mode 100644 (file)
index 0000000..0475691
--- /dev/null
@@ -0,0 +1,63 @@
+// Grain sizes
+#define MIX_GS 0
+#define FINE 1
+#define MEDIUM_GS 2
+#define COARSE 3
+
+// Granularity
+#define FINE_GRAIN   0.000010
+#define MEDIUM_GRAIN 0.001000
+#define COARSE_GRAIN 0.010000
+
+// Distribution types
+#define RANDOM 0
+#define IMBALANCED 1
+#define UNIFORM 2
+
+class WorkerData {
+ public:
+  int numObjs, numMsgs, tscale, locality, density, grainSize;
+  double granularity;
+  WorkerData& operator=(const WorkerData& obj) {
+    int i;
+    eventMsg::operator=(obj);
+    numObjs = obj.numObjs;
+    numMsgs = obj.numMsgs;
+    tscale = obj.tscale;
+    locality = obj.locality;
+    grainSize = obj.grainSize;
+    granularity = obj.granularity;
+    return *this;
+  }
+};
+
+class WorkMsg {
+ public:
+  int fromPE;
+  WorkMsg& operator=(const WorkMsg& obj) {
+    eventMsg::operator=(obj);
+    fromPE = obj.fromPE;
+    return *this;
+  }
+};
+
+class worker {
+  int numObjs, numMsgs, tscale, locality, grainSize;
+  double granularity;
+ public:
+  worker();
+  worker(WorkerData *m); 
+  ~worker() { }
+  worker& operator=(const worker& obj);
+  void pup(PUP::er &p) { 
+    chpt<state_worker>::pup(p); 
+    p(numObjs); p(numMsgs); p(tscale); p(locality); p(grainSize); 
+    p(granularity);
+  }
+
+  // Event methods
+  void work(WorkMsg *m);
+  void work_anti(WorkMsg *m);
+  void work_commit(WorkMsg *m);
+};
+
diff --git a/examples/pose/PHOLD/phold.C b/examples/pose/PHOLD/phold.C
new file mode 100644 (file)
index 0000000..b74d0f0
--- /dev/null
@@ -0,0 +1,129 @@
+#include <unistd.h>
+#include <math.h>
+#include "pose.h"
+#include "phold.h"
+#include "PHOLD.def.h"
+#include "Worker_sim.h"
+
+main::main(CkArgMsg *m)
+{ 
+  CkGetChareID(&mainhandle);
+
+  int numLPs=-1, numMsgs=-1, locality=1, grainSize=-1, msgDist, tsIncFn, 
+    moveFn, tScale;
+  double granularity=-1.0;
+  char grainString[20];
+  char *text;
+
+  if(m->argc<7) {
+    CkPrintf("Usage: phold <#LPs> <#initMsgs> <initMsgDist> <timestampIncFn> <moveFn> [ -g[f|m|c|z] | -t<granularity> ] <spacialLocality> <timescale>\n");
+    CkExit();
+  }
+  numLPs = atoi(m->argv[1]);
+  map = (int *)malloc(numLPs*sizeof(int));
+  numMsgs = atoi(m->argv[2]);
+  if (strcmp(m->argv[3], "RANDOM") == 0)
+    msgDist = RANDOM;
+  else {
+    CkPrintf("Invalid message distribution: %s\n", m->argv[3]);
+    CkExit();
+  }
+  if (strcmp(m->argv[4], "RANDOM") == 0)
+    tsIncFn = RANDOM;
+  else {
+    CkPrintf("Invalid timestamp increment function: %s\n", m->argv[4]);
+    CkExit();
+  }
+  if (strcmp(m->argv[5], "RANDOM") == 0)
+    moveFn = RANDOM;
+  else {
+    CkPrintf("Invalid movement function: %s\n", m->argv[5]);
+    CkExit();
+  }
+  locality = atoi(m->argv[7]);
+  tScale = atoi(m->argv[8]);
+
+  strcpy(grainString, m->argv[6]);
+  text = "";
+  if (strcmp(grainString, "-gf") == 0) {
+    grainSize = FINE; text = "FINE"; }
+  else if (strcmp(grainString, "-gm") == 0) {
+    grainSize = MEDIUM_GS; text = "MEDIUM"; }
+  else if (strcmp(grainString, "-gc") == 0) {
+    grainSize = COARSE; text = "COARSE"; }
+  else if (strcmp(grainString, "-gz") == 0) {
+    grainSize = MIX_GS; text = "MIXED"; }
+  else if (strncmp(grainString, "-t", 2) == 0)
+    granularity = atof(&(grainString[2]));
+
+  CkPrintf(">>> PHOLD: %d LPs, %d initial messages distributed: %s ...\n", 
+          numLPs, numMsgs, m->argv[3]);
+  CkPrintf(">>> ...timestamp incremented: %s  movement function: %s ...\n",
+          m->argv[4], m->argv[5]);
+  CkPrintf(">>> ...grainsize: %s %3.8e  locality: %d  time scale: %d.\n", 
+          text, granularity, locality, tScale);
+
+  POSE_init();
+
+  // create all the workers
+  WorkerData *wd;
+  int dest;
+  srand48(42);
+  buildMap(numLPs, UNIFORM);
+  for (int i=0; i<numLPs; i++) {
+    wd = new WorkerData;
+    wd->numObjs = numLPs;
+    wd->numMsgs = numMsgs;
+    wd->grainSize = grainSize;
+    wd->granularity = granularity;
+    wd->locality = locality;
+    wd->tscale = tScale;
+    dest = map[i];
+    wd->Timestamp(0);
+    (*(CProxy_worker *) &POSE_Objects)[i].insert(wd, dest);
+  }
+}
+
+void main::buildMap(int numLPs, int dist)
+{
+  int i, j=0, k;
+  if (dist == RANDOM)
+    for (i=0; i<numLPs; i++) map[i] = lrand48() % CkNumPes();
+  else if (dist == UNIFORM)
+    for (i=0; i<numLPs; i++) map[i] = i / (numLPs/CkNumPes());
+  else if (dist == IMBALANCED) {
+    int min = (numLPs/CkNumPes())/2;
+    if (min < 1) min = 1;
+    for (k=0; k<CkNumPes(); k++)
+      for (i=0; i<min; i++) {
+       map[j] = k;
+       j++;
+      }
+    i=CkNumPes()/2;
+    for (k=j; k<numLPs; k++) {
+      map[k] = i;
+      i++;
+      if (i == CkNumPes()) i = CkNumPes()/2;
+    }
+  }
+}
+
+int main::getAnbr(int numLPs, int locale, int dest)
+{
+  int here = (lrand48() % 101) <= locale;
+  int idx;
+  if (CkNumPes() == 1) return lrand48() % numLPs;
+  if (here) {
+    idx = lrand48() % numLPs;
+    while (map[idx] != dest)
+      idx = lrand48() % numLPs;
+    return idx;
+  }
+  else {
+    idx = lrand48() % numLPs;
+    while (map[idx] == dest)
+      idx = lrand48() % numLPs;
+    return idx;
+  }
+}
+
diff --git a/examples/pose/PHOLD/phold.ci b/examples/pose/PHOLD/phold.ci
new file mode 100644 (file)
index 0000000..dc7e461
--- /dev/null
@@ -0,0 +1,8 @@
+mainmodule PHOLD {
+  extern module Worker;
+  readonly CkChareID mainhandle;
+  
+  mainchare main {
+    entry main();
+  };
+};
diff --git a/examples/pose/PHOLD/phold.h b/examples/pose/PHOLD/phold.h
new file mode 100644 (file)
index 0000000..5a78cc5
--- /dev/null
@@ -0,0 +1,12 @@
+#include "PHOLD.decl.h"
+
+CkChareID mainhandle;
+
+class main : public Chare {
+  int *map;
+public:
+  main(CkArgMsg *m);
+  main(CkMigrateMessage *) {};
+  void buildMap(int numObjs, int dist);
+  int getAnbr(int numObjs, int locale, int dest);
+};