Adding two new comlib tests of section multicasts. These tests should work with the...
authorIsaac Dooley <idooley2@illinois.edu>
Wed, 3 Jun 2009 01:38:43 +0000 (01:38 +0000)
committerIsaac Dooley <idooley2@illinois.edu>
Wed, 3 Jun 2009 01:38:43 +0000 (01:38 +0000)
tests/charm++/commtest/Makefile
tests/charm++/commtest/section-multicast-test-6/Makefile [new file with mode: 0644]
tests/charm++/commtest/section-multicast-test-6/runTests.pl [new file with mode: 0755]
tests/charm++/commtest/section-multicast-test-6/test.C [new file with mode: 0644]
tests/charm++/commtest/section-multicast-test-6/test.ci [new file with mode: 0644]
tests/charm++/commtest/section-multicast-test/Makefile [new file with mode: 0644]
tests/charm++/commtest/section-multicast-test/runTests.pl [new file with mode: 0755]
tests/charm++/commtest/section-multicast-test/test.C [new file with mode: 0644]
tests/charm++/commtest/section-multicast-test/test.ci [new file with mode: 0644]

index b4d21d98a96947aaad78b5fa4dd795d4f513e5f7..40a7b207111b84e985fa46c62dd026bf347347dd 100644 (file)
@@ -1,15 +1,13 @@
 #DIRS=comlib commlib_stream pipeBroadcast
-DIRS=commlib_stream pipeBroadcast
+DIRS=section-multicast-test section-multicast-test-6
 
 .PHONY: test $(DIRS)
 
 all:
-       echo "skipping comlib tests"
-#      for d in $(DIRS); do \
-#                (cd $$d; $(MAKE) all OPTS='$(OPTS)' || exit 1) || exit 1; \
-#        done
+       for d in $(DIRS); do \
+                (cd $$d; $(MAKE) all OPTS='$(OPTS)' || exit 1) || exit 1; \
+        done
 
-#test: comlib commlib_stream pipeBroadcast
 test: $(DIRS)
 
 comlib: 
@@ -24,6 +22,11 @@ pipeBroadcast:
        echo "skipping comlib test"
 #      $(MAKE) -C $@ test OPTS='$(OPTS)'
 
+section-multicast-test:
+       $(MAKE) -C $@ test OPTS='$(OPTS)'                                                                                                                               
+section-multicast-test-6:
+       $(MAKE) -C $@ test OPTS='$(OPTS)'    
+
 bgtest:
        echo "skipping bgtest
 #      for d in $(DIRS); do \
diff --git a/tests/charm++/commtest/section-multicast-test-6/Makefile b/tests/charm++/commtest/section-multicast-test-6/Makefile
new file mode 100644 (file)
index 0000000..8d9fa4c
--- /dev/null
@@ -0,0 +1,24 @@
+CHARMC=../../../../bin/charmc -module comlib  $(OPTS)
+
+all: pgm
+
+
+test: pgm
+       ./charmrun pgm +p1 2 2
+       ./charmrun pgm +p2 5 5 
+       ./charmrun pgm +p4 5 5
+       ./charmrun pgm +p8 5 5
+
+pgm: test.o
+       $(CHARMC) -language charm++ -o pgm test.o $(COMLIB)
+
+test.decl.h: test.ci
+       $(CHARMC)  test.ci
+
+test.o: test.C test.decl.h
+       $(CHARMC) -c test.C -o test.o $(OPTS)
+
+
+clean:
+       rm -f *.decl.h *.def.h conv-host *.o charmrun *~ lu lu-blas lu-mem lu-blas-proj.*.log lu-blas-proj.*.sum lu-blas-proj.*.sts lu-blas-proj.sts lu-blas-proj.projrc lu-blas-proj test.o test.decl.h test.def.h test pgm
+
diff --git a/tests/charm++/commtest/section-multicast-test-6/runTests.pl b/tests/charm++/commtest/section-multicast-test-6/runTests.pl
new file mode 100755 (executable)
index 0000000..fef0060
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+$i = 0;
+$count_success = 0;
+$count_abort = 0;
+$runs = 10;
+
+print `make clean; make -j4`;
+
+
+while($i < $runs) {
+  $p = 1+$i*5 % 17;
+  
+  $i++;
+  
+  $program = "./charmrun ./test +p$p ++local";
+  
+  print "Running \"$program\"\n";
+  $output = `$program`;
+  
+  if ($output =~ m/Test Completed Successfully/gi) {
+    $count_success ++;  
+  } 
+  
+  if($output =~ m/abort/gi){
+    $count_abort ++;
+    print $output;
+  }
+  
+}
+
+print "${count_success} / $runs Tests succeeded (${count_abort} aborted)\n";
+
+
diff --git a/tests/charm++/commtest/section-multicast-test-6/test.C b/tests/charm++/commtest/section-multicast-test-6/test.C
new file mode 100644 (file)
index 0000000..eec6841
--- /dev/null
@@ -0,0 +1,164 @@
+#include "test.decl.h"
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+#include <comlib.h>
+
+// Each element sends a multicast to the successor elements in the 1D array, after recieving all multicasts from its predecessor elements
+
+CProxy_Main mainProxy;
+CProxy_LUBlk luArrProxy;
+ComlibInstanceHandle cinst_direct;
+ComlibInstanceHandle cinst_ring;
+ComlibInstanceHandle cinst_multiring;
+
+
+#define BLKSIZE 10
+#define NumElem 40
+#define COOKIE 777777
+#define NUM_ITER 30
+
+#define DEBUG 0
+
+class blkMsg: public CMessage_blkMsg {
+public:
+  double *data;
+};
+
+
+class Main : public CBase_Main {
+public:
+
+  double startTime;
+  int iteration;
+
+  Main(CkArgMsg* m) {
+    iteration = 0;    
+    com_debug = DEBUG;
+    
+    mainProxy = thisProxy;
+    
+    CkPrintf("Testing commlib array section multicast on %d processors (%d nodes)\n",
+            CkNumPes(), CmiNumNodes());
+    
+    luArrProxy = CProxy_LUBlk::ckNew(NumElem);
+    
+    
+    Strategy *strategy_direct = new DirectMulticastStrategy();  
+    cinst_direct = ComlibRegister(strategy_direct);
+
+    Strategy *strategy_ring = new RingMulticastStrategy();  
+    cinst_ring = ComlibRegister(strategy_ring);
+
+    Strategy *strategy_multiring = new MultiRingMulticastStrategy();
+    cinst_multiring = ComlibRegister(strategy_multiring);
+
+    
+
+    CkCallback *cb = new CkCallback(CkIndex_Main::iterationCompleted(NULL), thisProxy);
+    luArrProxy.ckSetReductionClient(cb);
+    startTime = CmiWallTimer();
+
+    startIteration();
+  }
+
+
+  void iterationCompleted(CkReductionMsg *msg) {
+    CkPrintf("iteration %d completed\n", iteration);
+    iteration ++;
+    if(iteration == NUM_ITER){
+      done(); 
+    } else {
+      startIteration();
+    }
+  }
+
+
+
+  void startIteration(){
+    blkMsg *msg = new (BLKSIZE) blkMsg;
+    msg->data[1] = COOKIE;
+    msg->data[BLKSIZE-1] = COOKIE;
+    luArrProxy.recvMessage(msg);
+  }
+
+  void done(){
+    double endTime = CmiWallTimer();
+    double duration = endTime-startTime;
+    CkPrintf("Test Completed Successfully");
+    CkPrintf("Time: %fs\n", duration);
+    CkExit();
+  }
+
+  
+};
+
+
+
+class LUBlk: public CBase_LUBlk {
+  int num_received;
+
+
+public:
+  LUBlk() {
+    num_received = 0;
+    com_debug = DEBUG;
+    srand(CkMyPe());
+  }
+
+  ~LUBlk() {}
+  
+  LUBlk(CkMigrateMessage* m) {}
+  
+  void pup(PUP::er &p) {
+    p | num_received;
+  }
+  
+  
+  
+  // Recieve the section multicasts from previous elements in the array.
+  // Once enough messages have arrived, continue on by sending a message.
+  // The messages may arrive out of order.
+  void recvMessage(blkMsg* m){
+    //    CkPrintf("recvMessage num_received=%d for element %d\n", num_received, thisIndex);
+    CkAssert(m->data[1] == COOKIE);
+    CkAssert(m->data[BLKSIZE-1] == COOKIE);
+    delete m;
+
+    if(thisIndex == num_received) {
+#if DEBUG
+      CkPrintf("Element %d is sending\n", thisIndex);
+#endif
+      if(thisIndex < NumElem-1) {
+       CProxySection_LUBlk sect = CProxySection_LUBlk::ckNew(thisArrayID, thisIndex+1, NumElem-1, 1);
+
+       switch(random() % 3){
+       case 0:
+         ComlibAssociateProxy(cinst_direct, sect); 
+         break;
+       case 1:
+         ComlibAssociateProxy(cinst_ring, sect); 
+         break;
+       case 2:
+         ComlibAssociateProxy(cinst_multiring, sect); 
+         break;
+       }
+
+       blkMsg *msg = new (BLKSIZE) blkMsg;
+       msg->data[1] = COOKIE;
+       msg->data[BLKSIZE-1] = COOKIE;
+       sect.recvMessage(msg);
+      }
+      num_received = -1;
+      contribute(0, 0, CkReduction::sum_int);
+    }
+
+    num_received ++;
+  }
+  
+};
+
+
+#include "test.def.h"
diff --git a/tests/charm++/commtest/section-multicast-test-6/test.ci b/tests/charm++/commtest/section-multicast-test-6/test.ci
new file mode 100644 (file)
index 0000000..e4b5c5a
--- /dev/null
@@ -0,0 +1,22 @@
+mainmodule test {
+  readonly CProxy_Main mainProxy;
+  readonly CProxy_LUBlk luArrProxy;
+  readonly ComlibInstanceHandle cinst_direct;
+  readonly ComlibInstanceHandle cinst_ring;
+  readonly ComlibInstanceHandle cinst_multiring;
+
+  message blkMsg {
+    double data[];
+  };
+
+  mainchare Main {
+    entry Main(CkArgMsg *m);
+    entry void iterationCompleted(CkReductionMsg *);
+  };
+
+  array [1D] LUBlk {
+    entry LUBlk(void);         
+    entry void recvMessage(blkMsg *);
+  };           
+
+};
diff --git a/tests/charm++/commtest/section-multicast-test/Makefile b/tests/charm++/commtest/section-multicast-test/Makefile
new file mode 100644 (file)
index 0000000..31c6f7b
--- /dev/null
@@ -0,0 +1,24 @@
+CHARMC=../../../../bin/charmc -module comlib  $(OPTS)
+
+all: pgm
+
+
+test: pgm
+       ./charmrun pgm +p1
+       ./charmrun pgm +p2
+       ./charmrun pgm +p4
+       ./charmrun pgm +p8
+
+pgm: test.o
+       $(CHARMC) -language charm++ -o pgm test.o $(COMLIB)
+
+test.decl.h: test.ci
+       $(CHARMC)  test.ci
+
+test.o: test.C test.decl.h
+       $(CHARMC) -c test.C -o test.o $(OPTS)
+
+
+clean:
+       rm -f *.decl.h *.def.h conv-host *.o charmrun *~ lu lu-blas lu-mem lu-blas-proj.*.log lu-blas-proj.*.sum lu-blas-proj.*.sts lu-blas-proj.sts lu-blas-proj.projrc lu-blas-proj test.o test.decl.h test.def.h test pgm
+
diff --git a/tests/charm++/commtest/section-multicast-test/runTests.pl b/tests/charm++/commtest/section-multicast-test/runTests.pl
new file mode 100755 (executable)
index 0000000..64d2015
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+$i = 0;
+$count_success = 0;
+$count_abort = 0;
+$runs = 50;
+
+while($i < $runs) {
+  $p = 1+$i*5 % 17;
+  
+  $i++;
+  
+  $program = "./charmrun ./test +p$p ++local";
+  
+  print "Running \"$program\"\n";
+  $output = `$program`;
+  
+  if ($output =~ m/Test Completed Successfully/gi) {
+    $count_success ++;  
+  } 
+  
+  if($output =~ m/abort/gi){
+    $count_abort ++;
+    print $output;
+  }
+  
+}
+
+print "${count_success} / $runs Tests succeeded (${count_abort} aborted)\n";
+
+
diff --git a/tests/charm++/commtest/section-multicast-test/test.C b/tests/charm++/commtest/section-multicast-test/test.C
new file mode 100644 (file)
index 0000000..ff8e93b
--- /dev/null
@@ -0,0 +1,116 @@
+#include "test.decl.h"
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+#include <comlib.h>
+
+CProxy_Main mainProxy;
+CProxy_LUBlk luArrProxy;
+ComlibInstanceHandle cinst;
+
+#define BLKSIZE 20
+#define NumCols 10
+#define NumRows 10
+#define COOKIE 777777
+#define numIterations 10
+
+// Test multicasts to each row of a 2d chare array.
+// Element 0,0 performs a section multicast to each row.
+// DirectMulticastStrategy is used
+// Quiescence is used for startup
+
+
+class blkMsg: public CMessage_blkMsg {
+public:
+  double *data;
+};
+
+
+class Main : public CBase_Main {
+public:
+
+  double startTime;
+  int iter;
+
+  Main(CkArgMsg* m) {
+    com_debug = 0;
+    iter = 0;
+    mainProxy = thisProxy;
+       
+    CkPrintf("Testing commlib array section multicast on %d processors (%d nodes)\n",  CkNumPes(), CmiNumNodes());
+       
+    luArrProxy = CProxy_LUBlk::ckNew(NumRows,NumCols);
+
+    Strategy *strategy = new DirectMulticastStrategy();        
+
+    cinst = ComlibRegister(strategy);
+
+    startTime = CmiWallTimer();
+
+    CkCallback *cb = new CkCallback(CkIndex_Main::startIteration(), thisProxy);
+    CkStartQD(*cb);
+
+  }
+
+  void startIteration() {
+    CkCallback *cb = new CkCallback(CkIndex_Main::iterationCompleted(NULL), thisProxy);
+    luArrProxy.ckSetReductionClient(cb);
+    luArrProxy(0,0).start();
+  }
+
+  void iterationCompleted(CkReductionMsg *msg) {
+    iter++;
+    if(iter == numIterations){
+      double endTime = CmiWallTimer();
+      double duration = endTime-startTime;
+      CkPrintf("Test Completed Successfully\n");
+      CkPrintf("Time: %fs\n", duration);
+      CkExit();
+    } else {
+      startIteration();
+    }
+  }
+
+  
+};
+
+
+
+class LUBlk: public CBase_LUBlk {
+
+public:
+  LUBlk() {}
+  ~LUBlk() {}
+  LUBlk(CkMigrateMessage* m) {}
+  void pup(PUP::er &p) {}
+
+
+  // start() should be called on one element in the array
+  // It will create an array section for each row in the array, and then multicast to each row section
+  // The array sections will result in the recvMessage method being called once for each array element
+  void start() {
+    for(int i=0;i<NumRows;i++){
+      CProxySection_LUBlk sect = CProxySection_LUBlk::ckNew(thisArrayID, i, i, 1, 0,NumCols-1, 1);
+      ComlibAssociateProxy(cinst, sect); 
+      blkMsg *msg = new (BLKSIZE) blkMsg;
+      msg->data[0] = COOKIE;
+      sect.recvMessage(msg);
+    }
+  }
+  
+
+  // Recieve the section multicast and 
+  void recvMessage(blkMsg* m){
+    CkAssert(m->data[0] == COOKIE);
+    delete m;
+
+    // CkPrintf("recvMessage for %d,%d\n", thisIndex.x, thisIndex.y);
+    contribute(0, 0, CkReduction::sum_int);
+  }
+  
+};
+
+
+#include "test.def.h"
diff --git a/tests/charm++/commtest/section-multicast-test/test.ci b/tests/charm++/commtest/section-multicast-test/test.ci
new file mode 100644 (file)
index 0000000..0f87778
--- /dev/null
@@ -0,0 +1,22 @@
+mainmodule test {
+  readonly CProxy_Main mainProxy;
+  readonly CProxy_LUBlk luArrProxy;
+  readonly ComlibInstanceHandle cinst; 
+
+  message blkMsg {
+    double data[];
+  };
+
+  mainchare Main {
+    entry Main(CkArgMsg *m);
+    entry void startIteration();
+    entry void iterationCompleted(CkReductionMsg *);
+  };
+
+  array [2D] LUBlk {
+    entry LUBlk(void);
+    entry void start(void);
+    entry void recvMessage(blkMsg *);
+  };           
+
+};