New benchmarks to test the learning framework. Several new tests are now enabled.
authorSameer Kumar <skumar2@uiuc.edu>
Fri, 18 Mar 2005 03:17:16 +0000 (03:17 +0000)
committerSameer Kumar <skumar2@uiuc.edu>
Fri, 18 Mar 2005 03:17:16 +0000 (03:17 +0000)
tests/charm++/commtest/comlib/Makefile
tests/charm++/commtest/comlib/bench.C
tests/charm++/commtest/comlib/bench.ci
tests/charm++/commtest/comlib/benchmulti.C
tests/charm++/commtest/comlib/benchsectionmulti.C [new file with mode: 0644]

index e6d881b3a4eb6b01c9a54d05ea63fa56b43a7ca1..38740ebaec32c52554fb7218c40ef9377505328b 100644 (file)
@@ -1,6 +1,6 @@
-CHARMC=../../../../bin/charmc -module comlib $(OPTS)
+CHARMC=../../../../bin/charmc -module comlib -module RefineLB $(OPTS)
 
-all: hello bench benchmulti
+all: hello bench benchmulti benchsectionmulti
 
 hello: hello.o
        $(CHARMC) -language charm++ -o hello hello.o
@@ -17,6 +17,10 @@ bench: bench.o
 benchmulti: benchmulti.o
        $(CHARMC) -language charm++ -o benchmulti benchmulti.o 
 
+benchsectionmulti: benchsectionmulti.o
+       $(CHARMC) -language charm++ -o benchsectionmulti benchsectionmulti.o 
+
+
 bench.decl.h: bench.ci
        $(CHARMC)  bench.ci
 
@@ -26,8 +30,11 @@ bench.o: bench.C bench.decl.h
 benchmulti.o: benchmulti.C bench.decl.h
        $(CHARMC) -c benchmulti.C
 
+benchsectionmulti.o: benchsectionmulti.C bench.decl.h
+       $(CHARMC) -c benchsectionmulti.C
+
 clean:
-       rm -f *.decl.h *.def.h conv-host *.o hello bench benchmulti charmrun *~
+       rm -f *.decl.h *.def.h conv-host *.o hello bench benchmulti benchsectionmulti charmrun *~
 
 test_bench: all
        ./charmrun bench +p4 10
@@ -41,6 +48,32 @@ test: all
        ./charmrun hello +p4 10 4
        ./charmrun hello +p4 10 5
        ./charmrun hello +p2 1
+       ./charmrun bench +p2 100 1 +balancer RefineLB
+       ./charmrun bench +p2 100 2 +balancer RefineLB
+       ./charmrun bench +p2 100 4 +balancer RefineLB
+       ./charmrun bench +p4 100 2 +balancer RefineLB
+       ./charmrun bench +p4 100 4 +balancer RefineLB
+       ./charmrun bench +p2 100 1 +strategy USE_GRID +balancer RefineLB 
+       ./charmrun bench +p2 100 2 +strategy USE_GRID +balancer RefineLB
+       ./charmrun bench +p2 100 4 +strategy USE_GRID +balancer RefineLB
+       ./charmrun bench +p2 100 1 +strategy USE_DIRECT +balancer RefineLB
+       ./charmrun bench +p2 100 2 +strategy USE_DIRECT +balancer RefineLB
+       ./charmrun bench +p2 100 4 +strategy USE_DIRECT +balancer RefineLB
+       ./charmrun benchmulti +p2 100 1 +balancer RefineLB
+       ./charmrun benchmulti +p2 100 2 +balancer RefineLB
+       ./charmrun benchmulti +p2 100 4 +balancer RefineLB
+       ./charmrun benchmulti +p4 100 2 +balancer RefineLB
+       ./charmrun benchmulti +p4 100 4 +balancer RefineLB
+       ./charmrun benchmulti +p2 100 1 +strategy USE_GRID +balancer RefineLB 
+       ./charmrun benchmulti +p2 100 2 +strategy USE_GRID +balancer RefineLB
+       ./charmrun benchmulti +p2 100 4 +strategy USE_GRID +balancer RefineLB
+       ./charmrun benchmulti +p2 100 1 +strategy USE_DIRECT +balancer RefineLB
+       ./charmrun benchmulti +p2 100 2 +strategy USE_DIRECT +balancer RefineLB
+       ./charmrun benchmulti +p2 100 4 +strategy USE_DIRECT +balancer RefineLB
+       ./charmrun benchsectionmulti +p2 100 1 +balancer RefineLB
+       ./charmrun benchsectionmulti +p2 100 2 +balancer RefineLB
+       ./charmrun benchsectionmulti +p2 100 4 +balancer RefineLB
+       ./charmrun benchsectionmulti +p4 100 4 +balancer RefineLB
 
 bgtest: all
        ./charmrun hello +p1 1  +x1 +y1 +z1
index deffe7cd85120edfbeeae27c10b9f5912c3d525d..0b8d4e6f1c940348c37a2870bd16d9448b10d8d3 100644 (file)
 #include "bench.decl.h"
 
 #define USELIB  1
-#define MAXITER 5000
+#define MAXITER 100
 #define NUMPASS 2
 
-int fraction = 1;  /* readonly */
 /*readonly*/ CkChareID mid;
 /*readonly*/ CProxy_Bench arr;
 /*readonly*/ int nElements;
@@ -44,10 +43,6 @@ public:
     }
 };
 
-void reductionClient(void *param, int dataSize, void *data){
-    arr.start(0);
-}
-
 /*mainchare*/
 class Main : public Chare
 {
@@ -69,9 +64,9 @@ public:
 
         size = 128;
         if(m->argc > 1 ) size = atoi(m->argv[1]);
-       if(m->argc > 2 ) //fraction=atoi(m->argv[2]);
+       if(m->argc > 2 ) 
             nElements = atoi(m->argv[2]);
-        //delete m;
+        delete m;
         
         //Start the computation
         CkPrintf("Running Bench on %d processors for %d elements with %d byte messages\n", CkNumPes(), nElements, size);
@@ -81,22 +76,25 @@ public:
         ComlibInstanceHandle cinst = CkGetComlibInstance();
        
         arr = CProxy_Bench::ckNew();
-
-       DummyStrategy *dstrat = new DummyStrategy();
-        EachToManyMulticastStrategy *strat = new EachToManyMulticastStrategy(USE_MESH, arr.ckGetArrayID(), arr.ckGetArrayID());
         
-        StreamingStrategy *sstrat = new StreamingStrategy(10, 10);
-        //sstrat->enableShortArrayMessagePacking();
+        int count = 0;
+        CkArrayIndexMax *elem_array = new CkArrayIndexMax[nElements];
+        for(count = 0; count < nElements; count ++) {
+            elem_array[count] = CkArrayIndex1D(count);
+        }
 
+        EachToManyMulticastStrategy *strat = new 
+            EachToManyMulticastStrategy(USE_MESH, arr.ckGetArrayID(), 
+                                        arr.ckGetArrayID(), 
+                                        nElements, elem_array, 
+                                        nElements, elem_array);
+        
         cinst.setStrategy(strat);                
-        //tmpInstance.setStrategy(sstrat);
-        //cinst = tmpInstance;
 
-        for(int count =0; count < nElements; count++)
+        for(count =0; count < nElements; count++)
          arr[count].insert(cinst);
 
         arr.doneInserting();
-        arr.setReductionClient(reductionClient, NULL);
 
        curTime = CkWallTimer();
         arr.start(size);
@@ -106,14 +104,13 @@ public:
         
       mcount ++;
       
-      //printf("Count = %d\n", count);
-      
       if (mcount == nElements){
        
        pass ++;
        mcount = 0;
        
-       CkPrintf("%d %5.4lf\n", size, (CmiWallTimer() - curTime)*1000/MAXITER);
+       CkPrintf("%d %5.4lf\n", size, (CmiWallTimer() - curTime)*1000/
+                 MAXITER);
        curTime = CkWallTimer();
        
        if(pass == NUMPASS)
@@ -129,19 +126,19 @@ public:
       mcount = 0;
       pass = 0;
       
-      if(superpass == 20)
-       CkExit();
+      if(superpass == 10)
+          CkExit();
       else {
-       if(superpass < 20)
-         size += 50;
-       else if(superpass < 30)
-         size += 100;
-       else if(superpass < 40)
-         size += 200;
-       else if(superpass < 50)
-         size += 500;
-       
-       arr.start(size);
+          if(superpass < 20)
+              size += 50;
+          else if(superpass < 30)
+              size += 100;
+          else if(superpass < 40)
+              size += 200;
+          else if(superpass < 50)
+              size += 500;
+          
+          arr.start(size);
       }
     }
 };
@@ -187,15 +184,9 @@ public:
 #ifdef USELIB
         myInst.beginIteration();
 #endif        
-        //for(int count = 0; count < nElements; count ++){
-       for(int dest = thisIndex + 1; dest < thisIndex + nElements/fraction;
-           dest ++){
+        for(int count = 0; count < nElements; count ++){
             
-           int count = dest % nElements;
-            if(count == thisIndex)
-                continue;
-            
-            //CkPrintf("[%d] Sending Message from %d to %d\n", CkMyPe(), thisIndex, count);
+            ComlibPrintf("[%d] Sending Message from %d to %d\n", CkMyPe(), thisIndex, count);
 
 #ifdef USELIB
             arrd[count].receiveMessage(new (&msize, 0) BenchMessage); 
@@ -206,9 +197,7 @@ public:
 
 #ifdef USELIB
         myInst.endIteration();
-#endif
-
-        //CkPrintf("After SendMessage %d\n", thisIndex);
+#endif        
     }
     
     void receiveMessage(BenchMessage *bmsg){
@@ -216,41 +205,38 @@ public:
         delete bmsg;
         mcount ++;
         
-        ComlibPrintf("In Receive Message %d %d %d\n", thisIndex, CkMyPe(), pass);
+        ComlibPrintf("In Receive Message %d %d %d\n", thisIndex, CkMyPe(), 
+                     pass);
 
-        if(mcount == nElements/fraction - 1){
+        if(mcount == nElements){
             mcount = 0;            
             pass ++;            
             CProxy_Main mainProxy(mid);
             if(pass == MAXITER){
                pass = 0;
-
+                
                mainProxy.send();
             }
-            else {
+            else
                 sendMessage();
-                //int x = 0;
-                //contribute(sizeof(int), (void *)&x, CkReduction::sum_int);
-            }
         }
     }
-
+    
     void start(int messagesize){
         msize = messagesize;
-       /*
+
        if(ite % NUMPASS == NUMPASS/2 || ite % NUMPASS == 1)  
-         //Call atsync in the middle and in the end
-         AtSync();
+            //Call atsync in the middle and in the end
+            AtSync();
         else
-       */
-         sendMessage();
+            sendMessage();
         
         //CkPrintf("In Start\n");
         ite ++;
     }
 
     void ResumeFromSync() {
-        //CkPrintf("%d: resuming\n", CkMyPe());
+        CkPrintf("%d: resuming\n", CkMyPe());
         myInst.setSourcePe();
        sendMessage();
     }
index 149fc6d92d90d769c52daf73058dfe084d90aa04..baeb93110d236a7c63ccd063c771c51a3ceaff98 100644 (file)
@@ -2,7 +2,6 @@ mainmodule bench {
   readonly CkChareID mid;
   readonly CProxy_Bench arr;
   readonly int nElements;
-  readonly int fraction;
 
   message [varsize] BenchMessage;
 
index 71d5bd5a6b1c20d9d3ee57ee6a50e50acf7c8964..b7fe69a50f6467c18041e22b834e6f347eb72b80 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "ComlibManager.h"
 #include "EachToManyMulticastStrategy.h"
-#include "RingMulticastStrategy.h"
 #include "BroadcastStrategy.h"
 #include "bench.decl.h"
 
@@ -16,7 +15,6 @@
 #define MAXPASS 100
 
 int MESSAGESIZE=128;
-int fraction = 1;
 /*readonly*/ CkChareID mid;
 /*readonly*/ CProxy_Bench arr;
 /*readonly*/ int nElements;
@@ -28,7 +26,7 @@ void callbackhandler(void *message){
     arr[CkMyPe()].receiveMessage(bm);
 }
 
-class BenchMessage : public CkMcastBaseMsg, public CMessage_BenchMessage {
+class BenchMessage : public CMessage_BenchMessage {
 public:
     int size;
     char *data;
@@ -52,10 +50,6 @@ public:
     }
 };
 
-void reductionClient(void *param, int dataSize, void *data){
-    arr.sendMessage();
-}
-
 /*mainchare*/
 class Main : public Chare
 {
@@ -70,7 +64,6 @@ public:
         nElements= CkNumPes();
 
         if(m->argc > 1 ) MESSAGESIZE=atoi(m->argv[1]);
-       //if(m->argc > 2 ) fraction=atoi(m->argv[2]);
 
         if(m->argc > 2 ) nElements=atoi(m->argv[2]);
 
@@ -81,34 +74,29 @@ public:
         mid = thishandle;        
 
        arr = CProxy_Bench::ckNew();
-       arr.setReductionClient(reductionClient, NULL);
                 
         int count = 0;
-        CkArrayIndexMax *elem_array = new CkArrayIndexMax[nElements/fraction];
-        for(count = 0; count < nElements/fraction; count ++) {
+        CkArrayIndexMax *elem_array = new CkArrayIndexMax[nElements];
+        for(count = 0; count < nElements; count ++) {
             elem_array[count] = CkArrayIndex1D(count);
         }
 
         EachToManyMulticastStrategy *strat = new 
             EachToManyMulticastStrategy(USE_MESH, arr.ckGetArrayID(), 
-                                        arr.ckGetArrayID(), 
-                                        nElements/fraction, elem_array,
-                                        nElements/fraction, elem_array); 
-        
-        DirectMulticastStrategy *dstrat = new DirectMulticastStrategy
-            (arr.ckGetArrayID());
+                                        arr.ckGetArrayID(),
+                                        nElements, elem_array,
+                                        nElements, elem_array);
 
-       RingMulticastStrategy *rstrat = new RingMulticastStrategy
-            (arr.ckGetArrayID(), arr.ckGetArrayID());
+        strat->setMulticast();
 
-        BroadcastStrategy *bstrat = new BroadcastStrategy(arr.ckGetArrayID(),
-                                                          USE_HYPERCUBE);
+        BroadcastStrategy *bstrat = new BroadcastStrategy
+            (arr.ckGetArrayID(), USE_HYPERCUBE);
         
         CkPrintf("After creating array\n");
        CkArrayID aid = arr.ckGetArrayID();
 
         ComlibInstanceHandle cinst = CkGetComlibInstance();        
-        cinst.setStrategy(bstrat);
+        cinst.setStrategy(strat);
         ComlibPrintf("After register strategy\n");
 
         for(count = 0; count < nElements; count++)
@@ -146,32 +134,31 @@ public:
            pass = 0;
             count = 0;
 
-           if(superpass == 50)
+           if(superpass == 10)
                CkExit();
            else {
-             if(superpass < 20)
-                 MESSAGESIZE += 50;
-             else if(superpass < 30)
-                 MESSAGESIZE += 100;
-             else if(superpass < 40)
-                 MESSAGESIZE += 200;
-             else if(superpass < 50)
-                 MESSAGESIZE += 500;
-             
-             arr.start(MESSAGESIZE);
+                if(superpass < 20)
+                    MESSAGESIZE += 50;
+                else if(superpass < 30)
+                    MESSAGESIZE += 100;
+                else if(superpass < 40)
+                    MESSAGESIZE += 200;
+                else if(superpass < 50)
+                    MESSAGESIZE += 500;
+                
+                arr.start(MESSAGESIZE);
            }
         }
     }
 };
 
 /*array [1D]*/
-class Bench : public CBase_Bench //ArrayElement1D
+class Bench : public CBase_Bench 
 {
     int pass;
     int mcount;
     double time, startTime;
     int firstEntryFlag, sendFinishedFlag;
-    CProxySection_Bench sproxy;
     CProxy_Bench arrd;
     ComlibInstanceHandle myinst;
 
@@ -188,7 +175,6 @@ public:
         p | startTime;
         p | firstEntryFlag ;
         p | sendFinishedFlag ;
-        p | sproxy ;
         p | myinst;
         p | arrd;
     }
@@ -205,15 +191,10 @@ public:
         arrd = thisProxy;
         ComlibDelegateProxy(&arrd);
 
-        CkArrayIndexMax *elem_array = new CkArrayIndexMax[nElements/fraction];
-        for(int count = 0; count < nElements/fraction; count ++) 
+        CkArrayIndexMax *elem_array = new CkArrayIndexMax[nElements];
+        for(int count = 0; count < nElements; count ++) 
             elem_array[count] = CkArrayIndex1D(count);
         
-        sproxy = CProxySection_Bench::ckNew
-            (thisProxy.ckGetArrayID(), elem_array, nElements/fraction); 
-        //ComlibInitSection(sproxy.ckGetSectionInfo());
-        ComlibDelegateProxy(&sproxy);
-
         usesAtSync = CmiTrue;
         setMigratable(true);
         myinst = cinst;
@@ -225,7 +206,7 @@ public:
     
     void sendMessage()
     {
-        if(thisIndex >= nElements/fraction) {
+        if(thisIndex >= nElements) {
             finishPass();
             return;
         }
@@ -238,9 +219,7 @@ public:
        int size = MESSAGESIZE;
        
 #ifdef USELIB
-        //ComlibDelegateProxy(&arrd);
         arrd.receiveMessage(new(&size, 0) BenchMessage);
-        //sproxy.receiveMessage(new(&size, 0) BenchMessage);
 #else
        arr[count].receiveMessage(new (&size, 0) BenchMessage);
 #endif
@@ -265,25 +244,24 @@ public:
         
         mcount ++;
 
-        if((mcount == nElements/fraction) /*&& (sendFinishedFlag)*/){
+        if(mcount == nElements){
             finishPass();
         }
     }
 
     void start(int messagesize){
         //CkPrintf("In Start\n");
-       MESSAGESIZE = 128;  //messagesize;
+       MESSAGESIZE = messagesize;
         
-        //if(firstEntryFlag) {
-        //  CkPrintf("Calling AtSync\n");
-        //  AtSync();
-        //}
-        //else
-        sendMessage();
+        if(firstEntryFlag) {
+            CkPrintf("Calling AtSync\n");
+            AtSync();
+        }
+        else
+            sendMessage();
     }
 
     void ResumeFromSync() {
-        ComlibResetSectionProxy(&sproxy);
         myinst.setSourcePe();
         sendMessage();
     }
@@ -301,7 +279,6 @@ public:
         else {
             sendMessage();
             int x = 0;
-            //contribute(sizeof(int), (void *)&x, CkReduction::sum_int);
         }
         
         sendFinishedFlag = 0;
diff --git a/tests/charm++/commtest/comlib/benchsectionmulti.C b/tests/charm++/commtest/comlib/benchsectionmulti.C
new file mode 100644 (file)
index 0000000..022554c
--- /dev/null
@@ -0,0 +1,270 @@
+
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+#include "ComlibManager.h"
+#include "RingMulticastStrategy.h"
+#include "DirectMulticastStrategy.h"
+#include "bench.decl.h"
+
+#define USELIB
+#define MAXPASS 100
+
+int MESSAGESIZE=128;
+/*readonly*/ CkChareID mid;
+/*readonly*/ CProxy_Bench arr;
+/*readonly*/ int nElements;
+
+class BenchMessage : public CkMcastBaseMsg, public CMessage_BenchMessage {
+public:
+    int size;
+    char *data;
+    int src;
+    
+    static void *alloc(int mnum, size_t size, int *sizes, int priobits){
+        int total_size = size + sizeof(char) * sizes[0];
+        BenchMessage *dmsg = (BenchMessage *)CkAllocMsg(mnum, total_size, 
+                                                        priobits);
+        dmsg->size = sizes[0];        
+        return (void *)dmsg;
+    }
+    
+    static void *pack(BenchMessage *msg){
+        return (void *)msg;
+    }
+    
+    static BenchMessage *unpack(void *buf){
+        BenchMessage *bmsg = (BenchMessage *)buf;
+        return bmsg;
+    }
+};
+
+/*mainchare*/
+class Main : public Chare
+{
+    int pass, superpass;
+    double curTime;
+public:
+    Main(CkArgMsg* m)
+    {
+        //Process command-line arguments
+       pass = 0;
+       superpass = 0;
+        nElements= CkNumPes();
+
+        if(m->argc > 1 ) MESSAGESIZE=atoi(m->argv[1]);
+
+        if(m->argc > 2 ) nElements=atoi(m->argv[2]);
+
+        delete m;
+        
+        CkPrintf("Running Bench on %d processors for %d elements with %d byte messages\n", CkNumPes(), nElements, MESSAGESIZE);
+        
+        mid = thishandle;        
+
+       arr = CProxy_Bench::ckNew();
+                
+        int count = 0;
+        CkArrayIndexMax *elem_array = new CkArrayIndexMax[nElements];
+        for(count = 0; count < nElements; count ++) {
+            elem_array[count] = CkArrayIndex1D(count);
+        }
+
+        DirectMulticastStrategy *dstrat = new DirectMulticastStrategy
+            (arr.ckGetArrayID());
+
+       RingMulticastStrategy *rstrat = new RingMulticastStrategy(arr.ckGetArrayID());
+
+        CkPrintf("After creating array\n");
+       CkArrayID aid = arr.ckGetArrayID();
+
+        ComlibInstanceHandle cinst = CkGetComlibInstance();        
+        cinst.setStrategy(dstrat);
+        ComlibPrintf("After register strategy\n");
+
+        for(count = 0; count < nElements; count++)
+            arr[count].insert(cinst);
+        arr.doneInserting();
+        
+       curTime = CkWallTimer();
+       arr.sendMessage();
+        CkPrintf("After Main\n");
+    };
+    
+    void send(void) {
+        
+        static int count = 0;
+        count ++;
+
+        if (count == nElements){
+            pass ++;
+            count = 0;
+           arr.sendMessage();
+        }
+    }
+    
+    void done()
+    {
+        static int count = 0;
+        
+        count ++;
+        
+        if(count == nElements) {
+            CkPrintf("%d %5.4lf\n", MESSAGESIZE, (CmiWallTimer() - curTime)*1000/MAXPASS);
+
+           curTime = CkWallTimer();
+           superpass ++;
+           pass = 0;
+            count = 0;
+
+           if(superpass == 10)
+               CkExit();
+           else {
+             if(superpass < 20)
+                 MESSAGESIZE += 50;
+             else if(superpass < 30)
+                 MESSAGESIZE += 100;
+             else if(superpass < 40)
+                 MESSAGESIZE += 200;
+             else if(superpass < 50)
+                 MESSAGESIZE += 500;
+             
+             arr.start(MESSAGESIZE);
+           }
+        }
+    }
+};
+
+/*array [1D]*/
+class Bench : public CBase_Bench
+{
+    int pass;
+    int mcount;
+    double time, startTime;
+    int firstEntryFlag, sendFinishedFlag;
+    CProxySection_Bench sproxy;
+    ComlibInstanceHandle myinst;
+
+public:
+
+    void pup(PUP::er &p) {
+        if(p.isPacking())
+            CkPrintf("Migrating from %d\n", CkMyPe());
+
+        ArrayElement1D::pup(p);
+        p | pass ;
+        p | mcount ;
+        p | time;
+        p | startTime;
+        p | firstEntryFlag ;
+        p | sendFinishedFlag ;
+        p | sproxy ;
+        p | myinst;
+    }
+  
+    Bench(ComlibInstanceHandle cinst)
+    {   
+        pass = 0;
+        mcount = 0;
+        time = 0.0;
+        
+        firstEntryFlag = 0;
+        sendFinishedFlag = 0;
+
+        CkArrayIndexMax *elem_array = new CkArrayIndexMax[nElements];
+        for(int count = 0; count < nElements; count ++) 
+            elem_array[count] = CkArrayIndex1D(count);
+        
+        sproxy = CProxySection_Bench::ckNew
+            (thisProxy.ckGetArrayID(), elem_array, nElements); 
+        ComlibResetSectionProxy(&sproxy);
+        ComlibDelegateProxy(&sproxy);
+
+        usesAtSync = CmiTrue;
+        setMigratable(true);
+        myinst = cinst;
+    }
+    
+    Bench(CkMigrateMessage *m) {
+        CkPrintf(" Migrated to %d\n", CkMyPe());
+    }
+    
+    void sendMessage()
+    {
+        if(thisIndex >= nElements) {
+            finishPass();
+            return;
+        }
+       
+       int count = 0;
+       int size = MESSAGESIZE;
+       
+#ifdef USELIB
+        sproxy.receiveMessage(new(&size, 0) BenchMessage);
+#else
+       arr[count].receiveMessage(new (&size, 0) BenchMessage);
+#endif
+
+        sendFinishedFlag = 1;  
+    }
+    
+    void receiveMessage(BenchMessage *bmsg){
+        
+        //CkPrintf("[%d][%d] In Receive Message \n", CkMyPe(), thisIndex);
+        
+        if(!firstEntryFlag) {
+            startTime = CkWallTimer();
+            firstEntryFlag = 1;
+        }
+        
+        delete bmsg;
+        
+        mcount ++;
+
+        if(mcount == nElements){
+            finishPass();
+        }
+    }
+
+    void start(int messagesize){
+        //CkPrintf("In Start\n");
+       MESSAGESIZE = messagesize;
+        
+        if(firstEntryFlag) {
+            CkPrintf("Calling AtSync\n");
+            AtSync();
+        }
+        else
+            sendMessage();
+    }
+
+    void ResumeFromSync() {
+        ComlibResetSectionProxy(&sproxy);
+        myinst.setSourcePe();
+        sendMessage();
+    }
+
+    void finishPass(){
+        mcount = 0;            
+        pass ++;        
+        time += CkWallTimer() - startTime;
+
+        CProxy_Main mainProxy(mid);
+        if(pass == MAXPASS){
+            pass = 0;
+            mainProxy.done();
+        }
+        else {
+            sendMessage();
+            int x = 0;
+        }
+        
+        sendFinishedFlag = 0;
+    }
+};
+
+#include "bench.def.h"