revert pingpong in commbench
authorYanhua Sun <sun51@hopper09.(none)>
Thu, 15 Sep 2011 03:39:38 +0000 (20:39 -0700)
committerYanhua Sun <sun51@hopper09.(none)>
Thu, 15 Sep 2011 03:39:38 +0000 (20:39 -0700)
tests/converse/commbench/pingpong.c

index 2d480cd5f7090f195b5bbda62bc49330fe7c7507..4027c88e72b65f7e03cd65f5cf4033c1f4738c9a 100644 (file)
@@ -10,35 +10,32 @@ static struct testdata {
   int size;
   int numiter;
 } sizes[] = {
- {16,      4000},
- {32,      4000},
- {128,      4000},
- {256,     1000},
- {512,     1000},
- {1024,    1000},
- {2048,    1000},
- {4096,    1000},
- {8192,    1000},
- {16384,   1000},
- {32768,   1000},
- {65536,   1000},
- {131072,   400},
- {524288,   400},
- {1048576, 100},
- {4194304, 40},
-  {-1,      -1},
   {16,      4000},
   {32,      4000},
   {128,      4000},
   {256,     1000},
   {512,     1000},
   {1024,    1000},
   {2048,    1000},
   {4096,    1000},
   {8192,    1000},
   {16384,   1000},
   {32768,   1000},
   {65536,   1000},
   {131072,   400},
   {524288,   400},
   {1048576, 100},
   {4194304, 40},
+    {-1,      -1},
 };
 
 typedef struct message_{
   char core[CmiMsgHeaderSizeBytes];
   int srcpe;
   int idx;
-  int iter;
   int data[1];
 } Message;
 
-char     *buffer_msgs;
-
 static void fillMessage(Message *msg)
 {
   int i, size, items;
@@ -90,8 +87,6 @@ pvd(int, nbrHandler);
 pvd(int, sizeHandler);
 pvd(int, iterHandler);
 pvd(int, bounceHandler);
-pvd(int, setupHandler);
-pvd(int, startHandler);
 
 static void recvTime(TimeMessage *msg)
 {
@@ -123,12 +118,12 @@ static void recvTime(TimeMessage *msg)
       pva(gavg)[j] /= (CmiNumNodes()*(CmiNumNodes()-1));
     CmiPrintf("[pingpong] CmiSyncSend\n");
     for(j=0;j<pva(numSizes);j++) {
-      CmiPrintf("%d\t\t%le\n",
+      CmiPrintf("[pingpong] size=%d\taverageTime=%le seconds\n",
                             sizes[j].size, pva(gavg)[j]);
-      //CmiPrintf("[pingpong] size=%d\tmaxTime=%le seconds\t[%d->%d]\n",
-      //            sizes[j].size, pva(gmax)[j],pva(gmaxSrc)[j],pva(gmaxDest)[j]);
-      //CmiPrintf("[pingpong] size=%d\tminTime=%le seconds\t[%d->%d]\n",
-      //            sizes[j].size, pva(gmin)[j],pva(gminSrc)[j],pva(gminDest)[j]);
+      CmiPrintf("[pingpong] size=%d\tmaxTime=%le seconds\t[%d->%d]\n",
+                  sizes[j].size, pva(gmax)[j],pva(gmaxSrc)[j],pva(gmaxDest)[j]);
+      CmiPrintf("[pingpong] size=%d\tminTime=%le seconds\t[%d->%d]\n",
+                  sizes[j].size, pva(gmin)[j],pva(gminSrc)[j],pva(gminDest)[j]);
     }
     CmiSetHandler(&m, pva(ack_handler));
     CmiSyncSend(0, sizeof(EmptyMsg), &m);
@@ -181,7 +176,6 @@ static void startNextSize(EmptyMsg *msg)
 {
   EmptyMsg m;
   Message *mm;
-  int i;
 
   pva(nextSize)++;
   if(pva(nextSize) == pva(numSizes)) {
@@ -190,22 +184,13 @@ static void startNextSize(EmptyMsg *msg)
     CmiSyncSend(CmiMyPe(), sizeof(EmptyMsg), &m);
   } else {
     int size = sizeof(Message)+sizes[pva(nextSize)].size;
-    
-    buffer_msgs = (char*)malloc((sizes[pva(nextSize)].numiter) * sizeof(Message*));
-    for(i=0; i<sizes[pva(nextSize)].numiter; i++)
-    {
-        mm = CmiAlloc(size);
-        mm->srcpe = CmiMyPe();
-        mm->idx = pva(nextSize);
-        CmiSetHandler(mm, pva(bounceHandler));
-        *((Message**)buffer_msgs+i*sizeof(char*)) = mm;
-    }
     mm = (Message *) CmiAlloc(size);
     mm->srcpe = CmiMyPe();
     mm->idx = pva(nextSize);
-    CmiSetHandler(mm, pva(setupHandler));
-    //fillMessage(mm);
-    CmiSyncSendAndFree(pva(nextNbr), size, mm);
+    CmiSetHandler(mm, pva(iterHandler));
+    fillMessage(mm);
+    CmiSyncSendAndFree(CmiMyPe(), size, mm);
+    pva(starttime) = CmiWallTimer();
   }
   CmiFree(msg);
 }
@@ -213,7 +198,7 @@ static void startNextSize(EmptyMsg *msg)
 static void startNextIter(Message *msg)
 {
   EmptyMsg m;
-  Message *mm;
+
   pva(nextIter)++;
   if(pva(nextIter) > sizes[pva(nextSize)].numiter) {
     pva(endtime) = CmiWallTimer();
@@ -225,9 +210,8 @@ static void startNextIter(Message *msg)
     CmiSyncSend(CmiMyPe(), sizeof(EmptyMsg), &m);
     CmiFree(msg);
   } else {
-      mm = *((Message**)(buffer_msgs + pva(nextIter)*sizeof(char*))); 
-      //CmiSetHandler(mm, pva(bounceHandler));
-      CmiSyncSendAndFree(pva(nextNbr), sizeof(Message)+sizes[mm->idx].size, mm);
+    CmiSetHandler(msg, pva(bounceHandler));
+    CmiSyncSendAndFree(pva(nextNbr), sizeof(Message)+sizes[msg->idx].size, msg);
   }
 }
 
@@ -236,46 +220,6 @@ static void bounceMessage(Message *msg)
   CmiSetHandler(msg, pva(iterHandler));
   CmiSyncSendAndFree(msg->srcpe, sizeof(Message)+sizes[msg->idx].size, msg);
 }
-static void setupMessage(Message *msg)
-{
-    Message *mm;
-    int     i, size;
-
-    int nextSize =  msg->idx; 
-    buffer_msgs = (char*)malloc((sizes[nextSize].numiter) * sizeof(Message*));
-    CmiFree(msg);
-
-    for(i=0; i<sizes[nextSize].numiter; i++)
-    {
-        mm = (Message*)CmiAlloc(size);
-        mm->srcpe = CmiMyPe();
-        CmiSetHandler(mm, pva(iterHandler));
-        //mm->idx = pva(nextSize);
-        *((Message**)buffer_msgs+i*sizeof(char*)) = mm;
-    }
-    mm = (Message *) CmiAlloc(size);
-    mm->srcpe = CmiMyPe();
-    mm->idx = nextSize;
-    CmiSetHandler(mm, pva(startHandler));
-    //fillMessage(mm);
-    CmiSyncSendAndFree(pva(nextNbr), size, mm);
-}
-static void startMessage(Message *msg)
-{
-    Message *mm;
-   
-    CmiFree(msg);
-
-    mm = *((Message**)buffer_msgs);
-    mm->srcpe = CmiMyPe();
-    mm->idx = pva(nextSize);
-    CmiSetHandler(mm, pva(iterHandler));
-    //fillMessage(mm);
-    pva(starttime) = CmiWallTimer();
-    CmiSyncSendAndFree(mm->srcpe, sizeof(Message)+sizes[pva(nextSize)].size, mm);
-  
-}
-
 
 void pingpong_init(void)
 {
@@ -355,8 +299,4 @@ void pingpong_moduleinit(void)
   pva(iterHandler) = CmiRegisterHandler((CmiHandler)startNextIter);
   pvi(int, bounceHandler);
   pva(bounceHandler) = CmiRegisterHandler((CmiHandler)bounceMessage);
-  pvi(int, setupHandler);
-  pva(setupHandler) = CmiRegisterHandler((CmiHandler)setupMessage);
-  pvi(int, startHandler);
-  pva(startHandler) = CmiRegisterHandler((CmiHandler)startMessage);
 }