added Ping test for sending K msgs per node
authorYanhuaSun <sun51@illinois.edu>
Fri, 22 Jun 2012 19:51:18 +0000 (14:51 -0500)
committerYanhuaSun <sun51@illinois.edu>
Fri, 22 Jun 2012 19:51:18 +0000 (14:51 -0500)
tests/charm++/ping/Makefile [new file with mode: 0644]
tests/charm++/ping/ping.C [new file with mode: 0644]
tests/charm++/ping/ping.ci [new file with mode: 0644]

diff --git a/tests/charm++/ping/Makefile b/tests/charm++/ping/Makefile
new file mode 100644 (file)
index 0000000..49df38d
--- /dev/null
@@ -0,0 +1,37 @@
+SRC=../../../src
+CHARMC=../../../bin/charmc $(OPTS)
+
+OBJS = ping.o
+
+all:   pgm
+
+projections : pgm.prj
+
+pgm: $(OBJS)
+       $(CHARMC) -language charm++ -o pgm $(OBJS)
+
+pgm.prj: $(OBJS)
+       $(CHARMC) -language charm++ -tracemode projections -o pgm.prj $(OBJS)
+
+cifiles: ping.ci
+       $(CHARMC)  ping.ci
+       touch cifiles
+
+clean:
+       rm -f *.decl.h *.def.h conv-host *.o pgm charmrun cifiles pgm.exe pgm.pdb pgm.ilk
+
+ping.o: ping.C cifiles
+       $(CHARMC) -I$(SRC)/conv-core ping.C
+
+test: all
+       @echo "Intra-processor ping.."
+       ./charmrun ./pgm +p1 $(TESTOPTS)
+       @echo "Inter-processor ping.."
+       ./charmrun ./pgm +p2 $(TESTOPTS)
+
+bgtest: all
+       @echo "Intra-processor ping.."
+       ./charmrun ./pgm +p1 +x1 +y1 +z1
+       @echo "Inter-processor ping.."
+       ./charmrun ./pgm +p2 +x2 +y1 +z1
+
diff --git a/tests/charm++/ping/ping.C b/tests/charm++/ping/ping.C
new file mode 100644 (file)
index 0000000..218686d
--- /dev/null
@@ -0,0 +1,101 @@
+#include <string.h> // for strlen, and strcmp
+#include <charm++.h>
+
+#define NITER 1000
+#define PAYLOAD 100
+
+#include "ping.decl.h"
+class PingMsg : public CMessage_PingMsg
+{
+  public:
+    char *x;
+
+};
+
+CProxy_main mainProxy;
+int iterations;
+int payload;
+int PEsPerNode;
+int CharesPerPE;
+
+class main : public CBase_main
+{
+  int niter;
+  CProxy_Ping1 arr1;
+  double start_time;
+public:
+  main(CkMigrateMessage *m) {}
+  main(CkArgMsg* m)
+  {
+      if(m->argc < 5)
+          CkPrintf("Usage: payload PEs CharesPerPE iteration\n");
+
+      niter = 0;
+      iterations=NITER;
+      payload=PAYLOAD;
+      if(m->argc>1)
+          payload=atoi(m->argv[1]);
+      if(m->argc>2)
+          PEsPerNode = atoi(m->argv[2]);
+      if(PEsPerNode > CkMyNodeSize())
+          PEsPerNode = CkMyNodeSize();
+      if(m->argc>3)
+          CharesPerPE = atoi(m->argv[3]);
+      if(m->argc>4)
+          iterations=atoi(m->argv[4]);
+  
+      mainProxy = thishandle;
+      arr1 = CProxy_Ping1::ckNew(2* PEsPerNode * CharesPerPE );
+      start_time = CkWallTimer();
+      for(int i=0; i<PEsPerNode * CharesPerPE; i++)
+          arr1[i].start();
+      delete m;
+  };
+
+  void maindone(void)
+  {
+      niter++;
+      if(niter == iterations)
+      {
+          double pingTimer = CkWallTimer() - start_time;
+          CkPrintf("Ping time for %d messages(%d Chares * %d PEs per node) of %d Bytes cost %f ms\n", 
+              PEsPerNode * CharesPerPE, CharesPerPE, PEsPerNode, payload, 1000*pingTimer/iterations);
+          CkExit();
+      }else
+      {
+          for(int i=0; i<PEsPerNode * CharesPerPE; i++)
+              arr1[i].start();
+      }
+  };
+};
+
+
+class Ping1 : public CBase_Ping1
+{
+  CProxy_Ping1 *pp;
+  int recvCnt;
+  double start_time, end_time;
+public:
+  Ping1()
+  {
+    pp = new CProxy_Ping1(thisArrayID);
+    recvCnt = 0;
+  }
+  Ping1(CkMigrateMessage *m) {}
+  void start(void)
+  {
+      int  receiver = PEsPerNode * CharesPerPE;
+      (*pp)[receiver].recv(new (payload) PingMsg);
+  }
+  void recv(PingMsg *msg)
+  {
+      recvCnt++;
+      if(recvCnt == PEsPerNode * CharesPerPE)
+      {
+          mainProxy.maindone();
+          recvCnt = 0;
+      }
+  }
+};
+
+#include "ping.def.h"
diff --git a/tests/charm++/ping/ping.ci b/tests/charm++/ping/ping.ci
new file mode 100644 (file)
index 0000000..0ffcd6a
--- /dev/null
@@ -0,0 +1,18 @@
+mainmodule ping {
+  readonly CProxy_main mainProxy;
+  readonly int iterations;
+  readonly int payload;
+  readonly int PEsPerNode;
+  readonly int CharesPerPE;
+  mainchare main {
+    entry main(CkArgMsg *);
+    entry void maindone(void);
+  };
+  message PingMsg{char x[];};
+
+  array [1D] Ping1 {
+    entry Ping1();
+    entry void start(void);
+    entry void recv(PingMsg *);
+  };           
+};