fix bug and clean up jacobi examples 98/398/9
authorYanhua Sun <sun51@illinois.edu>
Mon, 13 Oct 2014 16:43:23 +0000 (11:43 -0500)
committerGerrit Code Review <gerrit2@charm.cs.uiuc.edu>
Fri, 30 Jan 2015 00:54:04 +0000 (18:54 -0600)
The boundary condition constrain was wrong because it constrains the
boundary of each sub block. When using different number of subblocks,
the boundary condition changes. Fixed this by only constrains the
boundary of boundary subblock. Replace all tabs with 2 spaces.

Change-Id: Ib6d7979e6ababf070daf4c3a990cd3b3d866bcf1

31 files changed:
examples/charm++/Makefile
examples/charm++/jacobi1d/jacobi1d.C [deleted file]
examples/charm++/jacobi1d/jacobi1d.ci [deleted file]
examples/charm++/jacobi2d-1d-decomposition/Makefile [moved from examples/charm++/jacobi1d/Makefile with 81% similarity]
examples/charm++/jacobi2d-1d-decomposition/README [new file with mode: 0644]
examples/charm++/jacobi2d-1d-decomposition/jacobi1d.C [new file with mode: 0644]
examples/charm++/jacobi2d-1d-decomposition/jacobi1d.ci [new file with mode: 0644]
examples/charm++/jacobi2d-2d-decomposition/Makefile [moved from examples/charm++/jacobi2d-sdag/Makefile with 80% similarity]
examples/charm++/jacobi2d-2d-decomposition/README [moved from examples/charm++/jacobi2d-sdag/README with 100% similarity]
examples/charm++/jacobi2d-2d-decomposition/jacobi2d.C [new file with mode: 0644]
examples/charm++/jacobi2d-2d-decomposition/jacobi2d.ci [new file with mode: 0644]
examples/charm++/jacobi2d-iter/Makefile [deleted file]
examples/charm++/jacobi2d-iter/README [deleted file]
examples/charm++/jacobi2d-iter/jacobi2d.C [deleted file]
examples/charm++/jacobi2d-iter/jacobi2d.ci [deleted file]
examples/charm++/jacobi2d-iter/runserver.sh [deleted file]
examples/charm++/jacobi2d-sdag/jacobi2d.C [deleted file]
examples/charm++/jacobi2d-sdag/jacobi2d.ci [deleted file]
examples/charm++/jacobi2d/Makefile [deleted file]
examples/charm++/jacobi2d/README [deleted file]
examples/charm++/jacobi2d/jacobi2d.C [deleted file]
examples/charm++/jacobi2d/jacobi2d.ci [deleted file]
examples/charm++/jacobi3d-2d-decomposition/Makefile [moved from examples/charm++/jacobi3d-sdag/Makefile with 90% similarity]
examples/charm++/jacobi3d-2d-decomposition/README [new file with mode: 0644]
examples/charm++/jacobi3d-2d-decomposition/jacobi3d.C [new file with mode: 0644]
examples/charm++/jacobi3d-2d-decomposition/jacobi3d.ci [new file with mode: 0644]
examples/charm++/jacobi3d-sdag-constrain/Makefile [deleted file]
examples/charm++/jacobi3d-sdag-constrain/jacobi3d.C [deleted file]
examples/charm++/jacobi3d-sdag-constrain/jacobi3d.ci [deleted file]
examples/charm++/jacobi3d-sdag/jacobi3d.C [deleted file]
examples/charm++/jacobi3d-sdag/jacobi3d.ci [deleted file]

index 3502a9d104ff812f44d09e0f86ec3ab329c676f5..c941a045f1f9b9ac9f690ab9b4a25f066edf281d 100644 (file)
@@ -7,7 +7,9 @@ hello \
 integrate \
 integrate2 \
 integrateArray \
-jacobi2d \
+jacobi2d-1d-decomposition \
+jacobi2d-2d-decomposition \
+jacobi3d-2d-decomposition \
 leanmd \
 load_balancing \
 manyToMany \
@@ -29,7 +31,6 @@ hello \
 integrate \
 integrate2 \
 integrateArray \
-jacobi2d \
 load_balancing \
 piArray \
 PUP \
diff --git a/examples/charm++/jacobi1d/jacobi1d.C b/examples/charm++/jacobi1d/jacobi1d.C
deleted file mode 100644 (file)
index f7c1e98..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/** \file jacobi1d.C
- *  Author: Abhinav S Bhatele
- *  Date Created: July 16th, 2009
- *
- *
- *    ***********  ^
- *    *                *  |
- *    *                *  |
- *    *                *  X
- *    *                *  |
- *    *                *  |
- *    ***********  ~
- *    <--- Y --->
- *
- *    X: blockDimX, arrayDimX --> wrap_x
- *    Y: arrayDimY --> wrap_y
- * 
- *  This example does a 1D decomposition of a 2D data array
- */
-
-#include "jacobi1d.decl.h"
-#include "TopoManager.h"
-
-/*readonly*/ CProxy_Main mainProxy;
-/*readonly*/ int blockDimX;
-/*readonly*/ int arrayDimX;
-/*readonly*/ int arrayDimY;
-
-// specify the number of worker chares in each dimension
-/*readonly*/ int num_chares;
-
-// We want to wrap entries around, and because mod operator % 
-// sometimes misbehaves on negative values. -1 maps to the highest value.
-#define wrap_y(a)  (((a)+num_chares)%num_chares)
-
-#define MAX_ITER       26
-#define WARM_ITER      5
-#define TOP            1
-#define BOTTOM         2
-
-double startTime;
-double endTime;
-
-class Main : public CBase_Main
-{
-  public:
-    CProxy_Jacobi array;
-    int iterations;
-
-    Main(CkArgMsg* m) {
-      if (m->argc != 4) {
-        CkPrintf("%s [array_size_X] [array_size_Y] [num_chares]\n", m->argv[0]);
-        CkAbort("Abort");
-      }
-
-      CkPrintf("\nSTENCIL COMPUTATION WITH NO BARRIERS\n");
-      arrayDimX = atoi(m->argv[1]);
-      arrayDimY = atoi(m->argv[2]);
-      num_chares = atoi(m->argv[3]);
-      if (arrayDimX < num_chares || arrayDimX % num_chares != 0)
-        CkAbort("array_size_X % num_chares != 0!");
-      blockDimX = arrayDimX / num_chares;
-
-      // store the main proxy
-      mainProxy = thisProxy;
-
-      // print info
-      CkPrintf("Running Jacobi on %d processors with (%d) elements\n", CkNumPes(), num_chares);
-      CkPrintf("Array Dimensions: %d %d\n", arrayDimX, arrayDimY);
-      CkPrintf("Block Dimensions: %d %d\n", blockDimX, arrayDimY);
-
-      // Create new array of worker chares
-      array = CProxy_Jacobi::ckNew(num_chares);
-
-      //Start the computation
-      iterations = 0;
-      array.begin_iteration();
-    }
-
-    // Each worker reports back to here when it completes an iteration
-    void report(CkReductionMsg *msg) {
-      iterations++;
-      if(iterations == WARM_ITER)
-       startTime = CkWallTimer();
-      double error = *((double *)msg->getData());
-
-      if(iterations < MAX_ITER) {
-       CkPrintf("Start of iteration %d\n", iterations);
-       array.begin_iteration();
-      } else {
-       CkPrintf("Completed %d iterations\n", MAX_ITER-1);
-        endTime = CkWallTimer();
-        CkPrintf("Time elapsed per iteration: %f\n", (endTime - startTime)/(MAX_ITER-1-WARM_ITER));
-        CkExit();
-      }
-    }
-
-};
-
-class Jacobi: public CBase_Jacobi {
-  public:
-    int arrived_top;
-    int arrived_bottom;
-
-    double **temperature;
-    double **new_temperature;
-    void *sendLogs[4];
-    void *ackLogs[5];
-    int iterations;
-
-    // Constructor, initialize values
-    Jacobi() {
-      int i,j;
-      // allocate two dimensional arrays
-      temperature = new double*[blockDimX+2];
-      new_temperature = new double*[blockDimX+2];
-      for (i=0; i<blockDimX+2; i++) {
-       temperature[i] = new double[arrayDimY];
-       new_temperature[i] = new double[arrayDimY];
-      }
-      for(i=0;i<blockDimX+2; i++) {
-       for(j=0;j<arrayDimY; j++) {
-         temperature[i][j] = 0.5;
-         new_temperature[i][j] = 0.5;
-       }
-      }
-
-      arrived_top = 0;
-      arrived_bottom = 0;
-      iterations = 0;
-      constrainBC();
-    }
-
-    Jacobi(CkMigrateMessage* m) {}
-
-    ~Jacobi() { 
-      for (int i=0; i<blockDimX+2; i++) {
-        delete [] temperature[i];
-        delete [] new_temperature[i];
-      }
-      delete [] temperature; 
-      delete [] new_temperature; 
-    }
-
-    // Perform one iteration of work
-    void begin_iteration(void) {
-      iterations++;
-       
-      // Send my top edge
-      thisProxy(wrap_y(thisIndex)).receiveGhosts(BOTTOM, arrayDimY, &temperature[1][1]);
-      // Send my bottom edge
-      thisProxy(wrap_y(thisIndex)).receiveGhosts(TOP, arrayDimY, &temperature[blockDimX][1]);
-    }
-
-    void receiveGhosts(int dir, int size, double gh[]) {
-      int i, j;
-
-      switch(dir) {
-       case TOP:
-         arrived_top++;
-         for(j=0; j<size; j++)
-            temperature[0][j+1] = gh[j];
-         break;
-       case BOTTOM:
-         arrived_bottom++;
-         for(j=0; j<size; j++)
-            temperature[blockDimX+1][j+1] = gh[j];
-          break;
-       default:
-         CkAbort("ERROR\n");
-      }
-      check_and_compute();
-    }
-
-    void check_and_compute() {
-      double error = 0.0, max_error = 0.0;
-
-      if (arrived_top >=1 && arrived_bottom >= 1) {
-       arrived_top--;
-       arrived_bottom--;
-
-       compute_kernel();       
-
-       for(int i=1; i<blockDimX+1; i++) {
-         for(int j=0; j<arrayDimY; j++) {
-           error = fabs(new_temperature[i][j] - temperature[i][j]);
-           if(error > max_error) {
-             max_error = error;
-           }
-         }
-       }
-
-       double **tmp;
-       tmp = temperature;
-       temperature = new_temperature;
-       new_temperature = tmp;
-
-       constrainBC();
-
-       contribute(sizeof(double), &max_error, CkReduction::max_double,
-             CkCallback(CkIndex_Main::report(NULL), mainProxy));
-      }
-    }
-
-    // Check to see if we have received all neighbor values yet
-    // If all neighbor values have been received, we update our values and proceed
-    void compute_kernel()
-    {
-      for(int i=1; i<blockDimX+1; i++) {
-       for(int j=0; j<arrayDimY; j++) {
-         // update my value based on the surrounding values
-         new_temperature[i][j] = (temperature[i-1][j]+temperature[i+1][j]+temperature[i][j-1]+temperature[i][j+1]+temperature[i][j]) * 0.2;
-       }
-      }
-    }
-
-    // Enforce some boundary conditions
-    void constrainBC()
-    {
-     if(thisIndex <= num_chares/2) {
-       for(int i=1; i<=blockDimX; i++)
-         temperature[i][1] = 1.0;
-      }
-
-      if(thisIndex == num_chares-1) {
-       for(int j=arrayDimY/2; j<arrayDimY; j++)
-         temperature[blockDimX][j] = 0.0;
-      }
-    }
-
-};
-
-#include "jacobi1d.def.h"
diff --git a/examples/charm++/jacobi1d/jacobi1d.ci b/examples/charm++/jacobi1d/jacobi1d.ci
deleted file mode 100644 (file)
index e46b0eb..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-mainmodule jacobi1d {
-  readonly CProxy_Main mainProxy;
-  readonly int arrayDimX;
-  readonly int arrayDimY;
-  readonly int blockDimX;
-  readonly int num_chares;
-
-  mainchare Main {
-    entry Main(CkArgMsg *m);
-    entry void report(CkReductionMsg *msg);
-  };
-
-  array [1D] Jacobi {
-    entry Jacobi(void);
-    entry void begin_iteration(void);
-    entry void receiveGhosts(int dir, int size, double gh[size]);
-  };
-
-};
similarity index 81%
rename from examples/charm++/jacobi1d/Makefile
rename to examples/charm++/jacobi2d-1d-decomposition/Makefile
index a51c5dd822a12fbd48fe4a505f7ffe7c33d5468a..c4b54e5ead912d1969ea0e09239bc157b6723f47 100644 (file)
@@ -1,5 +1,4 @@
-OPTS   = -g
-CHARMC = ../../../bin/charmc $(OPTS)
+CHARMC=../../../bin/charmc $(OPTS)
 
 OBJS = jacobi1d.o
 
@@ -11,11 +10,15 @@ jacobi1d: $(OBJS)
 proj: $(OBJS)
        $(CHARMC) -language charm++ -tracemode projections -o jacobi1d.prj $(OBJS)
 
+jacobi1d.o: jacobi1d.C jacobi1d.decl.h
+       $(CHARMC) -c jacobi1d.C
+
 jacobi1d.decl.h: jacobi1d.ci
        $(CHARMC)  jacobi1d.ci
 
 clean:
        rm -f *.decl.h *.def.h conv-host *.o jacobi1d jacobi1d.prj charmrun *~ *log *projrc *sts
 
-jacobi1d.o: jacobi1d.C jacobi1d.decl.h
-       $(CHARMC) -c jacobi1d.C
+test: all
+       ./charmrun +p4 ./jacobi1d 32 32 4 $(TESTOPTS)
+
diff --git a/examples/charm++/jacobi2d-1d-decomposition/README b/examples/charm++/jacobi2d-1d-decomposition/README
new file mode 100644 (file)
index 0000000..2030da7
--- /dev/null
@@ -0,0 +1,18 @@
+Jacobi iteration with a 2D Array.
+
+This code uses a 1-D blocked decomposition of a 2-d array with more
+than one element per chare. 
+
+A 5-point stencil pattern is used to update the value for each data
+element. For example, the new value for element X is the current
+value of X plus the current values of its left, right, top, and
+bottom neighbors.
+
+     T
+   L X R
+     B
+
+X'  = (X + L + R + T + B) / 5.0
+
+Boundary conditions are obeyed in this example.  Control is expressed
+using structured dagger.
diff --git a/examples/charm++/jacobi2d-1d-decomposition/jacobi1d.C b/examples/charm++/jacobi2d-1d-decomposition/jacobi1d.C
new file mode 100644 (file)
index 0000000..6194d69
--- /dev/null
@@ -0,0 +1,247 @@
+/** \file jacobi1d.C
+ *  Author: Harshitha Menon, Yanhua Sun
+ *
+ *    ***********  ^
+ *    *                *  |
+ *    *                *  |
+ *    *                *  X
+ *    *                *  |
+ *    *                *  |
+ *    ***********  ~
+ *    <--- Y --->
+ *
+ *  This example does a 1D decomposition of a 2D data array
+ */
+
+#include "jacobi1d.decl.h"
+#include "TopoManager.h"
+
+/*readonly*/ CProxy_Main mainProxy;
+/*readonly*/ int blockDimX;
+/*readonly*/ int arrayDimX;
+/*readonly*/ int arrayDimY;
+
+// specify the number of worker chares 
+/*readonly*/ int numChares;
+/*readonly*/ int maxiterations;
+
+#define MAX_ITER               100
+#define TOP            1
+#define BOTTOM         2
+const double THRESHOLD =  0.004;
+
+class Main : public CBase_Main
+{
+  double startTime;
+  double endTime;
+
+public:
+  CProxy_Jacobi array;
+
+  Main(CkArgMsg* m) {
+    if (m->argc!=4 && m->argc!=5 ) {
+      CkPrintf("%s [array_size_X] [array_size_Y] [numChares]\n", m->argv[0]);
+      CkPrintf("OR %s [array_size_X] [array_size_Y] [numChares] maxiterations\n", m->argv[0]);
+      CkAbort("Abort");
+    }
+
+    CkPrintf("\nSTENCIL COMPUTATION WITH NO BARRIERS\n");
+    arrayDimX = atoi(m->argv[1]);
+    arrayDimY = atoi(m->argv[2]);
+    numChares = atoi(m->argv[3]);
+    if (arrayDimX < numChares || arrayDimX % numChares != 0)
+      CkAbort("array_size_X % numChares != 0!");
+    blockDimX = arrayDimX / numChares;
+
+    maxiterations = MAX_ITER;
+    if(m->argc==5)
+      maxiterations = atoi(m->argv[4]); 
+    // store the main proxy
+    mainProxy = thisProxy;
+
+    // print info
+    CkPrintf("Running Jacobi on %d processors with (%d) elements\n", CkNumPes(), numChares);
+    CkPrintf("Array Dimensions: %d %d\n", arrayDimX, arrayDimY);
+    CkPrintf("Block Dimensions: %d %d\n", arrayDimX, blockDimX);
+
+    // Create new array of worker chares
+    array = CProxy_Jacobi::ckNew(numChares);
+
+    //Start the computation
+    startTime = CkWallTimer();
+    array.run();
+  }
+
+  void done(int totalIter) {
+    if(totalIter >= maxiterations)
+      CkPrintf("Finish due to max iterations %d, total time %.3f seconds. \n", totalIter, CkWallTimer()-startTime); 
+    else
+      CkPrintf("Finish due to convergence, iterations %d, total time %.3f seconds. \n", totalIter, CkWallTimer()-startTime); 
+    CkExit();
+  }
+};
+
+class Jacobi: public CBase_Jacobi {
+  Jacobi_SDAG_CODE
+
+public:
+
+    double **temperature;
+    double **new_temperature;
+    int imsg;
+    int iterations;
+    int neighbors;
+    double max_error;
+    int converged;
+    bool topBound, bottomBound;
+    int istart, ifinish;
+
+    // Constructor, initialize values
+    Jacobi() {
+      int i,j;
+      temperature = new double*[blockDimX+2];
+      new_temperature = new double*[blockDimX+2];
+      for (i=0; i<blockDimX+2; i++) {
+        temperature[i] = new double[arrayDimY];
+        new_temperature[i] = new double[arrayDimY];
+      }
+      for (i=0; i<blockDimX+2; i++) {
+        for(j=0;j<arrayDimY; j++) {
+          temperature[i][j] = 0;
+          new_temperature[i][j] = 0;
+        }
+      }
+      converged = 0;
+      topBound = bottomBound = false;
+      neighbors = 0;
+      if(thisIndex == 0) {
+        topBound = true;
+        istart = 2;
+      }
+      else {
+        neighbors++;
+        istart = 1;
+      }
+
+      if(thisIndex == numChares -1){
+        bottomBound = true;
+        ifinish = blockDimX;
+      }
+      else {
+        neighbors++;
+        ifinish = blockDimX+1;
+      }
+
+      iterations = 0;
+      constrainBC();
+    }
+
+    Jacobi(CkMigrateMessage* m) {}
+
+    ~Jacobi() { 
+      for (int i=0; i<blockDimX+2; i++) {
+        delete [] temperature[i];
+        delete [] new_temperature[i];
+      }
+      delete [] temperature; 
+      delete [] new_temperature; 
+    }
+
+
+    void pup(PUP::er &p)
+    {
+      CBase_Jacobi::pup(p);
+      __sdag_pup(p);
+      p|imsg;
+      p|iterations;
+      p|neighbors;
+      p|max_error;
+      p|converged;
+      p|topBound;
+      p|bottomBound;
+      p|istart;
+      p|ifinish;
+
+      size_t size = (blockDimX+2) * (arrayDimY);
+      if (p.isUnpacking()) {
+        temperature = new double*[blockDimX+2];
+        new_temperature = new double*[blockDimX+2];
+
+        for (int i=0; i<blockDimX+2; i++) {
+          temperature[i] = new double[arrayDimY];
+          new_temperature[i] = new double[arrayDimY];
+        }
+      }
+
+      for(int i=0;i<blockDimX+2; i++) {
+        for(int j=0;j<arrayDimY; j++) {
+          p|temperature[i][j];
+          p|new_temperature[i][j];
+        }
+      }
+    }
+
+    void check_and_compute() {
+      double error = 0.0;
+      double **tmp;
+
+      max_error = 0.0;
+      for(int i=istart; i<ifinish; i++) {
+        for(int j=1; j<arrayDimY-1; j++) {
+          // update my value based on the surrounding values
+          new_temperature[i][j] = (temperature[i-1][j]+temperature[i+1][j]+temperature[i][j-1]+temperature[i][j+1]+temperature[i][j]) * 0.2;
+          error = fabs(new_temperature[i][j] - temperature[i][j]);
+          if(error > max_error) {
+            max_error = error;
+          }
+        }
+      }
+
+      tmp = temperature;
+      temperature = new_temperature;
+      new_temperature = tmp;
+    }
+
+    // Enforce some boundary conditions
+    void constrainBC() {
+      int i;
+      //top boundary 
+      if(topBound) {
+        for(i=0;i<arrayDimY; i++) {
+          temperature[1][i] = 1.0;
+          new_temperature[1][i] = 1.0;
+        }
+      }
+      //left, right boundary
+      for(i=0;i<blockDimX+2; i++) 
+      {
+        temperature[i][0] = 1.0;
+        new_temperature[i][0] = 1.0;
+        temperature[i][arrayDimY-1] = 1.0;
+        new_temperature[i][arrayDimY-1] = 1.0;
+      }
+      //bottom boundary
+      if(bottomBound) {
+        for(i=0;i<arrayDimY; i++) {
+          temperature[blockDimX][i] = 1.0;
+          new_temperature[blockDimX][i] = 1.0;
+        }
+      }
+    } 
+    // for debugging
+    void dumpMatrix(double **matrix)
+    {
+      CkPrintf("\n\n[%d]\n",thisIndex);
+      for(int i=0; i<blockDimX+2;++i)
+      {
+        for(int j=0; j<arrayDimY;++j)
+        {
+          CkPrintf("%0.6lf ",matrix[i][j]);
+        }
+        CkPrintf("\n");
+      }
+    }
+
+};
+
+#include "jacobi1d.def.h"
diff --git a/examples/charm++/jacobi2d-1d-decomposition/jacobi1d.ci b/examples/charm++/jacobi2d-1d-decomposition/jacobi1d.ci
new file mode 100644 (file)
index 0000000..ee18f3a
--- /dev/null
@@ -0,0 +1,48 @@
+mainmodule jacobi1d {
+  readonly CProxy_Main mainProxy;
+  readonly int arrayDimX;
+  readonly int arrayDimY;
+  readonly int blockDimX;
+  readonly int numChares;
+  readonly int maxiterations;
+
+  mainchare Main {
+    entry Main(CkArgMsg *m);
+    entry void done(int totalIter);
+  };
+
+  array [1D] Jacobi {
+    entry Jacobi(void);
+    entry void receiveGhosts(int iter, int dir, int size, double gh[size]);
+    entry [reductiontarget] void recvConvergeResult(int result);
+
+    entry void run() {
+      while (!converged && iterations<maxiterations) {
+        serial "send_to_neighbors" {
+          iterations++;
+          if(!topBound)
+            thisProxy((thisIndex-1+numChares)%numChares).receiveGhosts(iterations, BOTTOM, arrayDimY, &temperature[1][0]);
+          if(!bottomBound)
+            thisProxy((thisIndex+1)%numChares).receiveGhosts(iterations, TOP, arrayDimY, &temperature[blockDimX][0]);
+        }
+        for(imsg = 0; imsg < neighbors; imsg++)
+          when receiveGhosts[iterations] (int iter, int dir, int size, double gh[size])
+            serial "update_boundary" {
+              int row = (dir == TOP) ? 0 : blockDimX+1;
+              for(int j=0; j<size; j++)
+                temperature[row][j] = gh[j];
+            }
+        serial "compute" { check_and_compute(); }
+        serial "compute_converge" {
+          int conv = (max_error <= THRESHOLD);
+          CkCallback cb(CkReductionTarget(Jacobi, recvConvergeResult), thisProxy);
+          contribute(sizeof(int), &conv, CkReduction::logical_and, cb);
+        }
+        when recvConvergeResult(int result) serial "check_converge"{
+          converged = result;
+        if ((result || iterations>=maxiterations) && thisIndex == 0) mainProxy.done(iterations);
+      }
+      }
+    };
+  };
+};
similarity index 80%
rename from examples/charm++/jacobi2d-sdag/Makefile
rename to examples/charm++/jacobi2d-2d-decomposition/Makefile
index 3467f4fd6dea51c22aab2e72659024cfa0d316e0..c12f62748ef481e0fe7b86e31ba09441804a91b3 100644 (file)
@@ -6,7 +6,7 @@ OBJS = jacobi2d.o
 all: jacobi2d
 
 jacobi2d: $(OBJS)
-       $(CHARMC) -language charm++ -module RefineLB -o jacobi2d $(OBJS)
+       $(CHARMC) -language charm++ -o jacobi2d $(OBJS)
 
 projections: $(OBJS)
        $(CHARMC) -language charm++ -tracemode projections -lz -o jacobi2d.prj $(OBJS)
@@ -24,4 +24,4 @@ jacobi2d.o: jacobi2d.C jacobi2d.decl.h
        $(CHARMC) -c jacobi2d.C
 
 test: jacobi2d
-       ./charmrun +p2 ./jacobi2d 20 10 +balancer Refine $(TESTOPTS)
+       ./charmrun +p2 ./jacobi2d 32 16 $(TESTOPTS)
diff --git a/examples/charm++/jacobi2d-2d-decomposition/jacobi2d.C b/examples/charm++/jacobi2d-2d-decomposition/jacobi2d.C
new file mode 100644 (file)
index 0000000..cc32627
--- /dev/null
@@ -0,0 +1,362 @@
+/** \file jacobi2d.C
+ *  Author: Yanhua Sun, Eric Bohm and Abhinav S Bhatele
+ *
+ *  This is jacobi 2d problem using 2d decomposition 
+ *
+ */
+
+#include "jacobi2d.decl.h"
+
+// See README for documentation
+
+/*readonly*/ CProxy_Main mainProxy;
+/*readonly*/ int arrayDimX;
+/*readonly*/ int arrayDimY;
+/*readonly*/ int blockDimX;
+/*readonly*/ int blockDimY;
+
+// specify the number of worker chares in each dimension
+/*readonly*/ int num_chare_x;
+/*readonly*/ int num_chare_y;
+
+/*readonly*/ int maxiterations;
+
+static unsigned long next = 1;
+
+
+#define MAX_ITER               100
+#define LEFT                   1
+#define RIGHT                  2
+#define TOP                    3
+#define BOTTOM                 4
+#define DIVIDEBY5              0.2
+const double THRESHOLD   =  0.004;
+
+
+/** \class Main
+ *
+ */
+class Main : public CBase_Main {
+
+  double startTime;
+  double endTime;
+
+public:
+  CProxy_Jacobi array;
+  double max_error;
+  Main(CkArgMsg* m) {
+    if ( (m->argc < 3) || (m->argc > 6)) {
+      CkPrintf("%s [array_size] [block_size]\n", m->argv[0]);
+      CkPrintf("OR %s [array_size] [block_size] maxiterations\n", m->argv[0]);
+      CkPrintf("OR %s [array_size_X] [array_size_Y] [block_size_X] [block_size_Y] \n", m->argv[0]);
+      CkPrintf("OR %s [array_size_X] [array_size_Y] [block_size_X] [block_size_Y] maxiterations\n", m->argv[0]);
+      CkAbort("Abort");
+    }
+
+    // store the main proxy
+    mainProxy = thisProxy;
+
+    if(m->argc <= 4) {
+      arrayDimX = arrayDimY = atoi(m->argv[1]);
+      blockDimX = blockDimY = atoi(m->argv[2]);
+    }
+    else if (m->argc >= 5) {
+      arrayDimX = atoi(m->argv[1]);
+      arrayDimY = atoi(m->argv[2]);
+      blockDimX = atoi(m->argv[3]); 
+      blockDimY = atoi(m->argv[4]); 
+    }
+    maxiterations = MAX_ITER;
+    if(m->argc==4)
+      maxiterations = atoi(m->argv[3]); 
+    if(m->argc==6)
+      maxiterations = atoi(m->argv[5]); 
+
+    if (arrayDimX < blockDimX || arrayDimX % blockDimX != 0)
+      CkAbort("array_size_X % block_size_X != 0!");
+    if (arrayDimY < blockDimY || arrayDimY % blockDimY != 0)
+      CkAbort("array_size_Y % block_size_Y != 0!");
+
+    num_chare_x = arrayDimX / blockDimX;
+    num_chare_y = arrayDimY / blockDimY;
+
+    CkPrintf("\nSTENCIL COMPUTATION WITH NO BARRIERS\n");
+    CkPrintf("Running Jacobi on %d processors with (%d, %d) chares\n", CkNumPes(), num_chare_x, num_chare_y);
+    CkPrintf("Array Dimensions: %d %d\n", arrayDimX, arrayDimY);
+    CkPrintf("Block Dimensions: %d %d\n", blockDimX, blockDimY);
+    CkPrintf("max iterations %d\n", maxiterations);
+    CkPrintf("Threshhold %.10g\n", THRESHOLD);
+
+    array = CProxy_Jacobi::ckNew(num_chare_x, num_chare_y);
+    // start computation
+    array.run();
+  }
+
+  void done(int totalIter) {
+    if(totalIter >= maxiterations)
+      CkPrintf("Finish due to max iterations %d, total time %.3f seconds. \n", totalIter, CkWallTimer()-startTime); 
+    else
+      CkPrintf("Finish due to convergence, iterations %d, total time %.3f seconds. \n", totalIter, CkWallTimer()-startTime); 
+    CkExit();
+  }
+};
+
+/** \class Jacobi
+ *
+ */
+
+class Jacobi: public CBase_Jacobi {
+  Jacobi_SDAG_CODE
+
+public:
+    double **temperature;
+    double **new_temperature;
+    int imsg;
+    int iterations;
+    int neighbors;
+    int istart,ifinish,jstart,jfinish;
+    double max_error;
+    bool leftBound, rightBound, topBound, bottomBound;
+    int converged;
+    // Constructor, initialize values
+    Jacobi() {
+      int i, j;
+      temperature = new double*[blockDimX+2];
+      new_temperature = new double*[blockDimX+2];
+
+      for (i=0; i<blockDimX+2; i++) {
+        temperature[i] = new double[blockDimY+2];
+        new_temperature[i] = new double[blockDimY+2];
+      }
+
+      for(i=0; i<blockDimX+2; ++i) {
+        for(j=0; j<blockDimY+2; ++j) {
+          temperature[i][j] = 0.;
+        } 
+      }
+
+      converged = 0;
+      imsg = 0;
+      iterations = 0;
+      neighbors = 0;
+      max_error = 0.;
+      // determine border conditions
+      leftBound = rightBound = topBound = bottomBound = false;
+      istart = jstart = 1;
+      ifinish = blockDimX+1;
+      jfinish = blockDimY+1;
+
+      if(thisIndex.x==0)
+      {
+        leftBound = true;
+        istart++;
+      }
+      else
+        neighbors++;
+
+      if(thisIndex.x==num_chare_x-1)
+      {
+        rightBound = true;
+        ifinish--;
+      }
+      else
+        neighbors++;
+
+      if(thisIndex.y==0)
+      {
+        topBound = true;
+        jstart++;
+      }
+      else
+        neighbors++;
+
+      if(thisIndex.y==num_chare_y-1)
+      {
+        bottomBound = true;
+        jfinish--;
+      }
+      else
+        neighbors++;
+      constrainBC();
+    }
+
+    void pup(PUP::er &p)
+    {
+      int i,j;
+      CBase_Jacobi::pup(p);
+      __sdag_pup(p);
+      p|imsg;
+      p|iterations;
+      p|neighbors;
+      p|istart; p|ifinish; p|jstart; p|jfinish;
+      p|leftBound; p|rightBound; p|topBound; p|bottomBound;
+      p|converged;
+      p|max_error;
+
+      if (p.isUnpacking()) {
+        temperature = new double*[blockDimX+2];
+        new_temperature = new double*[blockDimX+2];
+        for (i=0; i<blockDimX+2; i++) {
+          temperature[i] = new double[blockDimY];
+          new_temperature[i] = new double[blockDimY];
+        }
+      }
+      for(i=0;i<blockDimX+2; i++) {
+        for(j=0;j<blockDimY+2; j++) {
+          p|temperature[i][j];
+          p|new_temperature[i][j];
+        }
+      }
+    }
+
+    Jacobi(CkMigrateMessage* m) { }
+
+    ~Jacobi() { 
+      for (int i=0; i<blockDimX+2; i++) {
+        delete [] temperature[i];
+        delete [] new_temperature[i];
+      }
+      delete [] temperature; 
+      delete [] new_temperature; 
+    }
+
+    // Send ghost faces to the six neighbors
+    void begin_iteration(void) {
+      iterations++;
+
+      if(!leftBound)
+      {
+        double *leftGhost =  new double[blockDimY];
+        for(int j=0; j<blockDimY; ++j) 
+          leftGhost[j] = temperature[1][j+1];
+        thisProxy(thisIndex.x-1, thisIndex.y).receiveGhosts(iterations, RIGHT, blockDimY, leftGhost);
+        delete [] leftGhost;
+      }
+      if(!rightBound)
+      {
+        double *rightGhost =  new double[blockDimY];
+        for(int j=0; j<blockDimY; ++j) 
+          rightGhost[j] = temperature[blockDimX][j+1];
+        thisProxy(thisIndex.x+1, thisIndex.y).receiveGhosts(iterations, LEFT, blockDimY, rightGhost);
+        delete [] rightGhost;
+      }
+      if(!topBound)
+      {
+        double *topGhost =  new double[blockDimX];
+        for(int i=0; i<blockDimX; ++i) 
+          topGhost[i] = temperature[i+1][1];
+        thisProxy(thisIndex.x, thisIndex.y-1).receiveGhosts(iterations, BOTTOM, blockDimX, topGhost);
+        delete [] topGhost;
+      }
+      if(!bottomBound)
+      {
+        double *bottomGhost =  new double[blockDimX];
+        for(int i=0; i<blockDimX; ++i) 
+          bottomGhost[i] = temperature[i+1][blockDimY];
+        thisProxy(thisIndex.x, thisIndex.y+1).receiveGhosts(iterations, TOP, blockDimX, bottomGhost);
+        delete [] bottomGhost;
+      }
+    }
+
+    void processGhosts(int dir, int size, double gh[]) {
+      switch(dir) {
+      case LEFT:
+        for(int j=0; j<size; ++j) {
+          temperature[0][j+1] = gh[j];
+        }
+        break;
+      case RIGHT:
+        for(int j=0; j<size; ++j) {
+          temperature[blockDimX+1][j+1] = gh[j];
+        }
+        break;
+      case TOP:
+        for(int i=0; i<size; ++i) {
+          temperature[i+1][0] = gh[i];
+        }
+        break;
+      case BOTTOM:
+        for(int i=0; i<size; ++i) {
+          temperature[i+1][blockDimY+1] = gh[i];
+        }
+        break;
+      default:
+        CkAbort("ERROR\n");
+      }
+    }
+
+    void check_and_compute() {
+      double temperatureIth = 0.;
+      double difference = 0.;
+      double **tmp;
+
+      max_error = 0.;
+      // When all neighbor values have been received, we update our values and proceed
+      for(int i=istart; i<ifinish; ++i) {
+        for(int j=jstart; j<jfinish; ++j) {
+          temperatureIth=(temperature[i][j] 
+            + temperature[i-1][j] 
+            +  temperature[i+1][j]
+            +  temperature[i][j-1]
+            +  temperature[i][j+1]) * 0.2;
+
+          // update relative error
+          difference = temperatureIth-temperature[i][j];
+          // fix sign without fabs overhead
+          if(difference<0) difference *= -1.0; 
+          max_error=(max_error>difference) ? max_error : difference;
+          new_temperature[i][j] = temperatureIth;
+        }
+      }
+
+      tmp = temperature;
+      temperature = new_temperature;
+      new_temperature = tmp;
+      //dumpMatrix(temperature);
+    }
+
+    // Enforce some boundary conditions
+    void constrainBC() {
+      if(topBound)
+        for(int i=0; i<blockDimX+2; ++i)
+        {
+          temperature[i][1] = 1.0;
+          new_temperature[i][1] = 1.0;
+        }
+
+      if(leftBound)
+        for(int j=0; j<blockDimY+2; ++j){
+          temperature[1][j] = 1.0;
+          new_temperature[1][j] = 1.0;
+        }
+
+      if(bottomBound)
+        for(int i=0; i<blockDimX+2; ++i){
+          temperature[i][blockDimY] = 1.;
+          new_temperature[i][blockDimY] = 1.;
+        }
+
+      if(rightBound)
+        for(int j=0; j<blockDimY+2; ++j){
+          temperature[blockDimX][j] = 1.;
+          new_temperature[blockDimX][j] = 1.;
+        }
+    }
+
+    // for debugging
+    void dumpMatrix(double **matrix)
+    {
+      CkPrintf("\n\n[%d,%d]\n",thisIndex.x, thisIndex.y);
+      for(int i=0; i<blockDimX+2;++i)
+      {
+        for(int j=0; j<blockDimY+2;++j)
+        {
+          CkPrintf("%0.3lf ",matrix[i][j]);
+        }
+        CkPrintf("\n");
+      }
+    }
+};
+
+
+#include "jacobi2d.def.h"
diff --git a/examples/charm++/jacobi2d-2d-decomposition/jacobi2d.ci b/examples/charm++/jacobi2d-2d-decomposition/jacobi2d.ci
new file mode 100644 (file)
index 0000000..32090dd
--- /dev/null
@@ -0,0 +1,50 @@
+mainmodule jacobi2d {
+
+  readonly CProxy_Main mainProxy;
+  readonly int arrayDimX;
+  readonly int arrayDimY;
+  readonly int blockDimX;
+  readonly int blockDimY;
+  readonly int num_chare_x;
+  readonly int num_chare_y;
+  readonly int maxiterations;
+
+  mainchare Main {
+    entry Main(CkArgMsg *m);
+    entry void done(int totalIter);
+  };
+
+  array [2D] Jacobi {
+    entry Jacobi(void);
+    entry void begin_iteration(void);
+    entry void receiveGhosts(int iter, int dir, int size, double ghosts[size]);
+    entry [reductiontarget] void recvConvergeResult(int result);
+
+    entry void run() {
+      while (!converged && iterations < maxiterations) {
+        serial "begin_iteration" {
+          begin_iteration();
+        }
+        for(imsg = 0; imsg < neighbors; imsg++) {
+          // "iterations" keeps track of messages across steps
+          when receiveGhosts[iterations] (int iter, int dir, int size, double ghosts[size])
+            serial "process ghosts" {
+              processGhosts(dir, size, ghosts);
+            }
+        }
+        serial "compute" { 
+          check_and_compute();
+        }
+        serial "compute_converge" {
+          int conv = (max_error <= THRESHOLD);
+          CkCallback cb(CkReductionTarget(Jacobi, recvConvergeResult), thisProxy);
+          contribute(sizeof(int), &conv, CkReduction::logical_and, cb);
+        }
+        when recvConvergeResult(int result) serial "check_converge"{
+          converged = result;
+        if ((result || iterations>=maxiterations)  && thisIndex.x +thisIndex.y == 0) mainProxy.done(iterations);
+      }
+      }
+    };
+  };
+};
diff --git a/examples/charm++/jacobi2d-iter/Makefile b/examples/charm++/jacobi2d-iter/Makefile
deleted file mode 100644 (file)
index 5c38fbd..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-CHARMC=../../../bin/charmc -module liveViz $(OPTS)
-
-OBJS = jacobi2d.o
-
-all: jacobi2d
-
-jacobi2d: $(OBJS)
-       $(CHARMC) -language charm++ -o jacobi2d $(OBJS)
-
-jacobi2d.decl.h: jacobi2d.ci
-       $(CHARMC)  jacobi2d.ci
-
-clean:
-       rm -f *.decl.h *.def.h conv-host *.o jacobi2d charmrun *~
-
-jacobi2d.o: jacobi2d.C jacobi2d.decl.h
-       $(CHARMC) -c jacobi2d.C
diff --git a/examples/charm++/jacobi2d-iter/README b/examples/charm++/jacobi2d-iter/README
deleted file mode 100644 (file)
index b38bc21..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-Jacobi iteration with a 2D Array.
-
-This code uses a 2-D blocked decomposition of a 2-d array with more
-than one element per chare. The code runs for a specified number of
-iterations, using a reduction to start each successive iteration.
-
-A 5-point stencil pattern is used to update the value for each data
-element. For example, the new value for element X is the current
-value of X plus the current values of its left, right, top, and
-bottom neighbors.
-
-     T
-   L X R
-     B
-
-X'  = (X + L + R + T + B) / 5.0
-
-
-To run the program with liveviz, run the parallel job as shown in
-runserver.sh, or just do a "./runserver.sh"
-
-While the program is running, connect a visualization client to that
-server. To do this you can run "charm/java/bin/liveViz localhost 1234"
-Note that port 1234 is the port specified in runserver.sh. You should
-at this point see a window appear, with a black background, and
-a red/white grid in the upper left corner. Resize as needed. The parallel
-server job should also print out a series of lines whenever each worker
-is requested to provide a portion of the frame. Resizing the client
-window will cause the image to be requested again, but with a different
-size. The client can only connect while the server is running. So you may 
-have to be quick to get to see anything. You may want to make the client 
-perform more iterations so that you have more time to see things.
diff --git a/examples/charm++/jacobi2d-iter/jacobi2d.C b/examples/charm++/jacobi2d-iter/jacobi2d.C
deleted file mode 100644 (file)
index 006aedb..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-#include "liveViz.h"
-#include "jacobi2d.decl.h"
-
-// See README for documentation
-
-/*readonly*/ CProxy_Main mainProxy;
-/*readonly*/ int block_height;
-/*readonly*/ int block_width;
-/*readonly*/ int array_height;
-/*readonly*/ int array_width;
-
-// specify the number of worker chares in each dimension
-/*readonly*/ int num_chare_rows;
-/*readonly*/ int num_chare_cols;
-
-// We want to wrap entries around, and because mod operator % sometimes misbehaves on negative values, 
-// I just wrote these simple wrappers that will make the mod work as expected. -1 maps to the highest value.
-#define wrap_x(a)  (((a)+num_chare_cols)%num_chare_cols)
-#define wrap_y(a)  (((a)+num_chare_rows)%num_chare_rows)
-
-CkArrayID a;
-
-//#define total_iterations 200
-
-class Main : public CBase_Main
-{
-public:
-    int recieve_count;
-    CProxy_Jacobi array;
-    int num_chares;
-    int iterations;
-    int total_iterations;
-    double startTime;
-
-    Main(CkArgMsg* m) {
-        if (m->argc < 3) {
-          CkPrintf("%s [array_size] [block_size]\n", m->argv[0]);
-          CkAbort("Abort");
-        }
-
-        // set iteration counter to zero
-        iterations=0;
-
-        // store the main proxy
-        mainProxy = thisProxy;
-
-        array_height = array_width = atoi(m->argv[1]);
-        block_height = block_width = atoi(m->argv[2]);
-        if (array_width < block_width || array_width % block_width != 0)
-          CkAbort("array_size % block_size != 0!");
-
-        num_chare_rows = array_height / block_height;
-        num_chare_cols = array_width / block_width;
-        // print info
-        CkPrintf("Running Jacobi on %d processors with (%d,%d) elements\n", CkNumPes(), num_chare_rows, num_chare_cols);
-
-       total_iterations = 200;
-       if (m->argc > 3) {
-         total_iterations = atoi(m->argv[3]);
-       }
-
-        // Create new array of worker chares
-        array = CProxy_Jacobi::ckNew(num_chare_cols, num_chare_rows);
-
-        // save the total number of worker chares we have in this simulation
-        num_chares = num_chare_rows*num_chare_cols;
-
-        // setup liveviz
-        CkCallback c(CkIndex_Jacobi::requestNextFrame(0),array);
-        liveVizConfig cfg(liveVizConfig::pix_color,true);
-        liveVizInit(cfg,a,c);
-
-        //Start the computation
-        startTime = CkWallTimer();
-        recieve_count = 0;
-        array.begin_iteration();
-    }
-
-    // Each worker reports back to here when it completes an iteration
-    void report(int row, int col) {
-        recieve_count++;
-        double totaltime = CkWallTimer() - startTime;
-        if (num_chares == recieve_count) {
-            if (iterations == total_iterations) {
-                CkPrintf("Completed %d iterations; last iteration time: %.6lf\n", iterations, totaltime);
-                CkExit();
-            } else {
-                CkPrintf("starting new iteration; iteration %d time: %.6lf\n", iterations, totaltime);
-                recieve_count=0;
-                iterations++;
-                // Call begin_iteration on all worker chares in array
-                startTime = CkWallTimer();
-                array.begin_iteration();
-            }
-        }
-    }
-};
-
-class Jacobi: public CBase_Jacobi {
-public:
-    int messages_due;
-
-    double **temperature;
-
-    // Constructor, initialize values
-    Jacobi() {
-        int i,j;
-          // allocate two dimensional array
-        temperature = new double*[block_height+2];
-        for (i=0; i<block_height+2; i++)
-          temperature[i] = new double[block_width+2];
-        messages_due = 4;
-        for(i=0;i<block_height+2;++i){
-            for(j=0;j<block_width+2;++j){
-                temperature[i][j] = 0.0;
-            }
-        }
-        BC();
-    }
-
-    // Enforce some boundary conditions
-    void BC(){
-        // Heat left and top edges of each chare's block
-       for(int i=1;i<block_height+1;++i)
-            temperature[i][1] = 255.0;
-        for(int j=1;j<block_width+1;++j)
-            temperature[1][j] = 255.0;
-    }
-
-    // a necessary function which we ignore now
-    // if we were to use load balancing and migration
-    // this function might become useful
-    Jacobi(CkMigrateMessage* m) {}
-
-    ~Jacobi() { 
-      for (int i=0; i<block_height; i++)
-        delete [] temperature[i];
-      delete [] temperature; 
-    }
-
-    // Perform one iteration of work
-    // The first step is to send the local state to the neighbors
-    void begin_iteration(void) {
-
-        // Copy left column and right column into temporary arrays
-        double *left_edge = new double[block_height];
-        double *right_edge = new double[block_height];
-
-        for(int i=0;i<block_height;++i){
-            left_edge[i] = temperature[i+1][1];
-            right_edge[i] = temperature[i+1][block_width];
-        }
-
-        // Send my left edge
-        thisProxy(wrap_x(thisIndex.x-1), thisIndex.y).ghostsFromRight(block_height, left_edge);
-               // Send my right edge
-        thisProxy(wrap_x(thisIndex.x+1), thisIndex.y).ghostsFromLeft(block_height, right_edge);
-               // Send my top edge
-        thisProxy(thisIndex.x, wrap_y(thisIndex.y-1)).ghostsFromBottom(block_width, &temperature[1][1]);
-               // Send my bottom edge
-        thisProxy(thisIndex.x, wrap_y(thisIndex.y+1)).ghostsFromTop(block_width, &temperature[block_height][1]);
-
-        delete [] right_edge;
-        delete [] left_edge;
-    }
-
-    void ghostsFromRight(int width, double ghost_values[]) {
-        for(int i=0;i<width;++i){
-            temperature[i+1][block_width+1] = ghost_values[i];
-        }
-        check_and_compute();
-    }
-
-    void ghostsFromLeft(int width, double ghost_values[]) {
-        for(int i=0;i<width;++i){
-            temperature[i+1][0] = ghost_values[i];
-        }
-        check_and_compute();
-    }
-
-    void ghostsFromBottom(int width, double ghost_values[]) {
-        for(int i=0;i<width;++i){
-            temperature[block_height+1][i+1] = ghost_values[i];
-        }
-        check_and_compute();
-    }
-
-    void ghostsFromTop(int width, double ghost_values[]) {
-        for(int i=0;i<width;++i){
-            temperature[0][i+1] = ghost_values[i];
-        }
-        check_and_compute();
-    }
-
-    void check_and_compute() {
-       if (--messages_due == 0) {
-          messages_due = 4;
-          compute();
-          mainProxy.report(thisIndex.x, thisIndex.y);
-        }
-    }
-
-    // Check to see if we have received all neighbor values yet
-    // If all neighbor values have been received, we update our values and proceed
-    void compute() {
-            // We must create a new array for these values because we don't want to update any of the
-            // the values in temperature[][] array until using them first. Other schemes could be used
-            // to accomplish this same problem. We just put the new values in a temporary array
-            // and write them to temperature[][] after all of the new values are computed.
-            double new_temperature[block_height+2][block_width+2];
-    
-            for(int i=1;i<block_height+1;++i){
-                for(int j=1;j<block_width+1;++j){
-                    // update my value based on the surrounding values
-                    new_temperature[i][j] = (temperature[i-1][j]+temperature[i+1][j]+temperature[i][j-1]+temperature[i][j+1]+temperature[i][j]) / 5.0;
-
-                }
-            }
-
-            for(int i=0;i<block_height+2;++i)
-                for(int j=0;j<block_width+2;++j)
-                    temperature[i][j] = new_temperature[i][j];
-
-            // Enforce the boundary conditions again
-            BC();
-
-    }
-
-
-    // provide my portion of the image to the graphical liveViz client
-    // Currently we just provide some pretty color depending upon the thread id
-    // In a real program we would provide a colored rectangle or pixel that
-    // depends upon the local thread data.
-    void requestNextFrame(liveVizRequestMsg *m){
-               // These specify the desired total image size requested by the client viewer
-        int wdes = m->req.wid;
-        int hdes = m->req.ht;
-
-        // Deposit a rectangular region to liveViz
-
-        // where to deposit
-        int sx=thisIndex.x*block_width;
-        int sy=thisIndex.y*block_height;
-        int w=block_width,h=block_height; // Size of my rectangular part of the image
-
-        // set the output pixel values for my rectangle
-        // Each component is a char which can have 256 possible values.
-        unsigned char *intensity= new unsigned char[3*w*h];
-        for(int i=0;i<h;++i){
-            for(int j=0;j<w;++j){
-                        intensity[3*(i*w+j)+0] = 255; // RED component
-                        intensity[3*(i*w+j)+1] = 255-temperature[i+1][j+1]; // BLUE component
-                        intensity[3*(i*w+j)+2] = 255-temperature[i+1][j+1]; // GREEN component
-            }
-        }
-
-        liveVizDeposit(m, sx,sy, w,h, intensity, this);
-        delete[] intensity;
-
-    }
-
-
-
-};
-
-#include "jacobi2d.def.h"
diff --git a/examples/charm++/jacobi2d-iter/jacobi2d.ci b/examples/charm++/jacobi2d-iter/jacobi2d.ci
deleted file mode 100644 (file)
index af33ee4..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-mainmodule jacobi2d {
-  readonly CProxy_Main mainProxy;
-  readonly int array_height;
-  readonly int array_width;
-  readonly int block_height;
-  readonly int block_width;
-  readonly int num_chare_rows;
-  readonly int num_chare_cols;
-
-  mainchare Main {
-    entry Main(CkArgMsg *m);
-    entry void report(int, int);
-  };
-
-  array [2D] Jacobi {
-    // Normal Charm++ entry methods
-    entry Jacobi(void);
-    entry void begin_iteration(void);
-    entry void ghostsFromLeft(int width, double s[width]);
-    entry void ghostsFromRight(int width, double s[width]);
-    entry void ghostsFromTop(int width, double s[width]);
-    entry void ghostsFromBottom(int width, double s[width]);
-
-    // A method for requesting data to be displayed graphically to the user
-    entry void requestNextFrame(liveVizRequestMsg *m);
-  };
-};
diff --git a/examples/charm++/jacobi2d-iter/runserver.sh b/examples/charm++/jacobi2d-iter/runserver.sh
deleted file mode 100755 (executable)
index e974f90..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-echo "Starting up server:"
-./charmrun +p1 ./jacobi2d 2000 100 ++server ++server-port 1234
-echo "Server Exited"
-
diff --git a/examples/charm++/jacobi2d-sdag/jacobi2d.C b/examples/charm++/jacobi2d-sdag/jacobi2d.C
deleted file mode 100644 (file)
index 7e3c393..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-/** \file jacobi2d.C
- *  Author: Eric Bohm and Abhinav S Bhatele
- *
- *  This is jacobi3d-sdag cut down to 2d and fixed to be a correct
- *  implementation of the finite difference method by Eric Bohm.
- *
- *  Date Created: Dec 7th, * 2010
- *
- */
-
-#include "jacobi2d.decl.h"
-
-// See README for documentation
-
-/*readonly*/ CProxy_Main mainProxy;
-/*readonly*/ int arrayDimX;
-/*readonly*/ int arrayDimY;
-/*readonly*/ int blockDimX;
-/*readonly*/ int blockDimY;
-
-// specify the number of worker chares in each dimension
-/*readonly*/ int num_chare_x;
-/*readonly*/ int num_chare_y;
-
-/*readonly*/ int maxiterations;
-
-static unsigned long next = 1;
-
-
-
-#define index(a, b)    ( (b)*(blockDimX+2) + (a) )
-
-#define MAX_ITER               100
-#define WARM_ITER              2
-#define LEFT                   1
-#define RIGHT                  2
-#define TOP                    3
-#define BOTTOM                 4
-#define DIVIDEBY5              0.2
-const double THRESHHOLD =  0.001;
-
-double startTime;
-double endTime;
-
-/** \class Main
- *
- */
-class Main : public CBase_Main {
-public:
-  CProxy_Jacobi array;
-  int iterations;
-  double maxdifference;
-  Main_SDAG_CODE;
-  Main(CkArgMsg* m) {
-    if ( (m->argc < 3) || (m->argc > 6)) {
-      CkPrintf("%s [array_size] [block_size]\n", m->argv[0]);
-      CkPrintf("OR %s [array_size] [block_size] maxiterations\n", m->argv[0]);
-      CkPrintf("OR %s [array_size_X] [array_size_Y] [block_size_X] [block_size_Y] \n", m->argv[0]);
-      CkPrintf("OR %s [array_size_X] [array_size_Y] [block_size_X] [block_size_Y] maxiterations\n", m->argv[0]);
-      CkAbort("Abort");
-    }
-
-    // set iteration counter to zero
-    iterations = 0;
-    // store the main proxy
-    mainProxy = thisProxy;
-       
-    if(m->argc <= 4) {
-      arrayDimX = arrayDimY = atoi(m->argv[1]);
-      blockDimX = blockDimY = atoi(m->argv[2]);
-    }
-    else if (m->argc >= 5) {
-      arrayDimX = atoi(m->argv[1]);
-      arrayDimY = atoi(m->argv[2]);
-      blockDimX = atoi(m->argv[3]); 
-      blockDimY = atoi(m->argv[4]); 
-    }
-    maxiterations=MAX_ITER;
-    if(m->argc==4)
-      maxiterations=atoi(m->argv[3]); 
-    if(m->argc==6)
-      maxiterations=atoi(m->argv[5]); 
-      
-    if (arrayDimX < blockDimX || arrayDimX % blockDimX != 0)
-      CkAbort("array_size_X % block_size_X != 0!");
-    if (arrayDimY < blockDimY || arrayDimY % blockDimY != 0)
-      CkAbort("array_size_Y % block_size_Y != 0!");
-
-    num_chare_x = arrayDimX / blockDimX;
-    num_chare_y = arrayDimY / blockDimY;
-
-    // print info
-    CkPrintf("\nSTENCIL COMPUTATION WITH NO BARRIERS\n");
-    CkPrintf("Running Jacobi on %d processors with (%d, %d) chares\n", CkNumPes(), num_chare_x, num_chare_y);
-    CkPrintf("Array Dimensions: %d %d\n", arrayDimX, arrayDimY);
-    CkPrintf("Block Dimensions: %d %d\n", blockDimX, blockDimY);
-    CkPrintf("max iterations %d\n", maxiterations);
-    CkPrintf("Threshhold %.10g\n", THRESHHOLD);
-      
-    // NOTE: boundary conditions must be set based on values
-      
-    // make proxy and populate array in one call
-    array = CProxy_Jacobi::ckNew(num_chare_x, num_chare_y);
-
-    // initiate computation
-    thisProxy.run();
-  }
-
-  void done(bool success) {
-      if(success)
-       CkPrintf("Difference %.10g Satisfied Threshhold %.10g in %d Iterations\n", maxdifference,THRESHHOLD,iterations);
-      else
-       CkPrintf("Completed %d Iterations , Difference %lf fails threshhold\n", iterations,maxdifference);
-      endTime = CkWallTimer();
-      CkPrintf("Time elapsed per iteration: %f\n", (endTime - startTime)/(maxiterations-1-WARM_ITER));
-      CkExit();
-  }
-};
-
-/** \class Jacobi
- *
- */
-
-class Jacobi: public CBase_Jacobi {
-  Jacobi_SDAG_CODE
-
-  public:
-  double *temperature;
-  double *new_temperature;
-  int imsg;
-  int iterations;
-  int numExpected;
-  int istart,ifinish,jstart,jfinish;
-  double maxdifference;
-  bool leftBound, rightBound, topBound, bottomBound;
-  // Constructor, initialize values
-  Jacobi() {
-    usesAtSync=true;
-
-    int i, j;
-    // allocate a two dimensional array
-    temperature = new double[(blockDimX+2) * (blockDimY+2)];
-    new_temperature = new double[(blockDimX+2) * (blockDimY+2)];
-
-    for(i=0; i<blockDimX+2; ++i) {
-      for(j=0; j<blockDimY+2; ++j) {
-       temperature[index(i, j)] = 0.;
-      } 
-    }
-    imsg=0;
-    iterations = 0;
-    numExpected=0;
-    maxdifference=0.;
-    // determine border conditions
-    leftBound=rightBound=topBound=bottomBound=false;
-    istart=jstart=1;
-    ifinish=blockDimX+1;
-    jfinish=blockDimY+1;
-
-    if(thisIndex.x==0)
-      {
-       leftBound=true;
-       istart++;
-      }
-    else
-      numExpected++;
-
-    if(thisIndex.x==num_chare_x-1)
-      {
-       rightBound=true;
-       ifinish--;
-      }
-    else
-      numExpected++;
-
-    if(thisIndex.y==0)
-      {
-       topBound=true;
-       jstart++;
-      }
-    else
-      numExpected++;
-
-    if(thisIndex.y==num_chare_y-1)
-      {
-       bottomBound=true;
-       jfinish--;
-      }
-    else
-      numExpected++;
-    constrainBC();
-  }
-
-  void pup(PUP::er &p)
-  {
-    CBase_Jacobi::pup(p);
-    __sdag_pup(p);
-    p|imsg;
-    p|iterations;
-    p|numExpected;
-    p|maxdifference;
-    p|istart; p|ifinish; p|jstart; p|jfinish;
-    p|leftBound; p|rightBound; p|topBound; p|bottomBound;
-    
-    size_t size = (blockDimX+2) * (blockDimY+2);
-    if (p.isUnpacking()) {
-      temperature = new double[size];
-      new_temperature = new double[size];
-    }
-    p(temperature, size);
-    p(new_temperature, size);
-  }
-
-  Jacobi(CkMigrateMessage* m) { }
-
-  ~Jacobi() { 
-    delete [] temperature; 
-    delete [] new_temperature; 
-  }
-
-  // Send ghost faces to the six neighbors
-  void begin_iteration(void) {
-    AtSync();
-    if (thisIndex.x == 0 && thisIndex.y == 0) {
-      CkPrintf("Start of iteration %d\n", iterations);
-    }
-    iterations++;
-
-    if(!leftBound)
-      {
-       double *leftGhost =  new double[blockDimY];
-       for(int j=0; j<blockDimY; ++j) 
-         leftGhost[j] = temperature[index(1, j+1)];
-       thisProxy(thisIndex.x-1, thisIndex.y)
-         .receiveGhosts(iterations, RIGHT, blockDimY, leftGhost);
-       delete [] leftGhost;
-      }
-    if(!rightBound)
-      {
-       double *rightGhost =  new double[blockDimY];
-       for(int j=0; j<blockDimY; ++j) 
-         rightGhost[j] = temperature[index(blockDimX, j+1)];
-        thisProxy(thisIndex.x+1, thisIndex.y)
-         .receiveGhosts(iterations, LEFT, blockDimY, rightGhost);
-       delete [] rightGhost;
-      }
-    if(!topBound)
-      {
-       double *topGhost =  new double[blockDimX];
-       for(int i=0; i<blockDimX; ++i) 
-         topGhost[i] = temperature[index(i+1, 1)];
-       thisProxy(thisIndex.x, thisIndex.y-1)
-         .receiveGhosts(iterations, BOTTOM, blockDimX, topGhost);
-       delete [] topGhost;
-      }
-    if(!bottomBound)
-      {
-       double *bottomGhost =  new double[blockDimX];
-       for(int i=0; i<blockDimX; ++i) 
-         bottomGhost[i] = temperature[index(i+1, blockDimY)];
-       thisProxy(thisIndex.x, thisIndex.y+1)
-         .receiveGhosts(iterations, TOP, blockDimX, bottomGhost);
-       delete [] bottomGhost;
-      }
-  }
-
-  void processGhosts(int dir, int size, double gh[]) {
-    switch(dir) {
-    case LEFT:
-      for(int j=0; j<size; ++j) {
-       temperature[index(0, j+1)] = gh[j];
-      }
-      break;
-    case RIGHT:
-      for(int j=0; j<size; ++j) {
-       temperature[index(blockDimX+1, j+1)] = gh[j];
-      }
-      break;
-    case TOP:
-      for(int i=0; i<size; ++i) {
-       temperature[index(i+1, 0)] = gh[i];
-      }
-      break;
-    case BOTTOM:
-      for(int i=0; i<size; ++i) {
-       temperature[index(i+1, blockDimY+1)] = gh[i];
-      }
-      break;
-    default:
-      CkAbort("ERROR\n");
-    }
-  }
-
-
-  void check_and_compute(CkCallback cb, int numSteps) {
-    compute_kernel();
-
-    double *tmp;
-    tmp = temperature;
-    temperature = new_temperature;
-    new_temperature = tmp;
-    constrainBC();
-
-    contribute(sizeof(double), &maxdifference, CkReduction::max_double, cb);
-    if (numSteps > 1)
-      doStep(cb, numSteps-1);
-  }
-
-
-  // When all neighbor values have been received, 
-  // we update our values and proceed
-  void compute_kernel() {
-    double temperatureIth=0.;
-    double difference=0.;
-    maxdifference=0.;
-#pragma unroll    
-    for(int i=istart; i<ifinish; ++i) {
-      for(int j=jstart; j<jfinish; ++j) {
-       // calculate discrete mean value property 5 pt stencil
-       temperatureIth=(temperature[index(i, j)] 
-                       + temperature[index(i-1, j)] 
-                       +  temperature[index(i+1, j)]
-                       +  temperature[index(i, j-1)]
-                       +  temperature[index(i, j+1)]) * 0.2;
-
-       // update relative error
-       difference=temperatureIth - temperature[index(i, j)];
-       // fix sign without fabs overhead
-       if(difference<0) difference*=-1.0; 
-       maxdifference=(maxdifference>difference) ? maxdifference : difference;
-       new_temperature[index(i, j)] = temperatureIth;
-      }
-    }
-  }
-
-  // Enforce some boundary conditions
-  void constrainBC() {
-    if(topBound)
-      for(int i=0; i<blockDimX+2; ++i)
-       temperature[index(i, 1)] = 1.0;
-    if(leftBound)
-      for(int j=0; j<blockDimY+2; ++j)
-       temperature[index(1, j)] = 1.0;
-
-    if(bottomBound)
-      for(int i=0; i<blockDimX+2; ++i)
-       temperature[index(i, blockDimY)] = 0.;
-    if(rightBound)
-      for(int j=0; j<blockDimY+2; ++j)
-       temperature[index(blockDimX, j)] = 0.;
-
-  }
-  // for debugging
- void dumpMatrix(double *matrix)
-  {
-    CkPrintf("[%d,%d]\n",thisIndex.x, thisIndex.y);
-    for(int i=0; i<blockDimX+2;++i)
-      {
-       for(int j=0; j<blockDimY+2;++j)
-         {
-           CkPrintf("%0.3lf ",matrix[index(i,j)]);
-         }
-       CkPrintf("\n");
-      }
-  }
-};
-
-
-#include "jacobi2d.def.h"
diff --git a/examples/charm++/jacobi2d-sdag/jacobi2d.ci b/examples/charm++/jacobi2d-sdag/jacobi2d.ci
deleted file mode 100644 (file)
index 3f81409..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-mainmodule jacobi2d {
-
-  readonly CProxy_Main mainProxy;
-  readonly int arrayDimX;
-  readonly int arrayDimY;
-  readonly int blockDimX;
-  readonly int blockDimY;
-
-  readonly int num_chare_x;
-  readonly int num_chare_y;
-
-  readonly int maxiterations;
-
-  mainchare Main {
-    entry Main(CkArgMsg *m);
-    entry void run() {
-      while (iterations < WARM_ITER) {
-       atomic {
-         array.doStep(CkCallback(CkIndex_Main::report(NULL), thisProxy), 1);
-       }
-       when report(CkReductionMsg *msg) atomic {
-         iterations++;
-         delete msg;
-       }
-      }
-      atomic "start_timed_portion" {
-       startTime = CkWallTimer();
-       array.doStep(CkCallback(CkIndex_Main::report(NULL), thisProxy),
-                    maxiterations);
-      }
-      while (iterations < maxiterations) {
-       // Each worker reports back to here when it completes an iteration
-       // Asynchronous check on threshhold satisfaction
-       when report(CkReductionMsg *msg) atomic {
-         iterations++;
-         maxdifference=((double *) msg->getData())[0];
-         delete msg;
-         if (maxdifference - THRESHHOLD < 0)
-           done(true);
-       }
-      }
-      atomic { done(false); }
-    };
-    entry void report(CkReductionMsg *m);
-  };
-
-  array [2D] Jacobi {
-    entry Jacobi(void);
-    entry void begin_iteration(void);
-    entry void receiveGhosts(int iter, int dir, int size,
-                             double ghosts[size]);
-
-    entry void doStep(CkCallback cb, int numSteps) {
-      atomic "begin_iteration" {
-       begin_iteration();
-      }
-      for(imsg = 0; imsg < numExpected; imsg++) {
-       // "iterations" keeps track of messages across steps
-       when
-          receiveGhosts[iterations] (int iter, int dir, int size,
-                                    double ghosts[size])
-         atomic "process ghosts" {
-            processGhosts(dir, size, ghosts);
-          }
-      }
-      atomic "doWork" {
-       check_and_compute(cb, numSteps);
-      }
-    };
-  };
-};
diff --git a/examples/charm++/jacobi2d/Makefile b/examples/charm++/jacobi2d/Makefile
deleted file mode 100644 (file)
index 1dadbc4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-CHARMC=../../../bin/charmc $(OPTS)
-
-OBJS = jacobi2d.o
-
-all: jacobi2d
-
-jacobi2d: $(OBJS)
-       $(CHARMC) -language charm++ -o jacobi2d $(OBJS)
-
-jacobi2d.decl.h: jacobi2d.ci
-       $(CHARMC)  jacobi2d.ci
-
-clean:
-       rm -f *.decl.h *.def.h conv-host *.o jacobi2d charmrun
-
-jacobi2d.o: jacobi2d.C jacobi2d.decl.h
-       $(CHARMC) -c jacobi2d.C
-
-test: all
-       ./charmrun ./jacobi2d +p4 10 $(TESTOPTS)
-
-bgtest: all
-       ./charmrun ./jacobi2d +p4 10 +x2 +y2 +z2 $(TESTOPTS)
diff --git a/examples/charm++/jacobi2d/README b/examples/charm++/jacobi2d/README
deleted file mode 100644 (file)
index 8b49eb0..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-Jacobi iteration with a 2D Array.
-
-Demonstrates 2d dense chare array creation and use.  This code computes
-the steady state heat distribution of a 2d plate using the jacobi
-iteration:
-
-while new_temp != temp
-  //next temperature is average of surrounding temperatures 
-  new_temp(x,y) = (temp(x-1,y)+temp(x+1,y)+temp(x,y-1)+temp(x,y+1))/4
-  temp(x,y) = new_temp(x,y)
-end
-
-Every temp(x,y) is a chare in this sample application.  The main chare
-sends a notice to all the nodes in our simulation telling them to
-exchange information.  After each node is done updating its
-temperature, it sends a message back the error as the difference
-between temp and new_temp.  Main quits driving the iterations when the
-error has been minimized below some threshold.
-
-
diff --git a/examples/charm++/jacobi2d/jacobi2d.C b/examples/charm++/jacobi2d/jacobi2d.C
deleted file mode 100644 (file)
index 27ff7da..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-#include "jacobi2d.decl.h"
-
-/*
-Jacobi iteratoin with a 2D Array.
-
-Demonstrates 2d dense char array creation and use.  This code computes
-the steady state heat distribution of a 2d plate using the jacobi
-iteration:
-
-while new_temp != temp
-  //next temperature is average of surrounding temperatures 
-  new_temp(x,y) = (temp(x-1,y)+temp(x+1,y)+temp(x,y-1)+temp(x,y+1))/4
-  temp(x,y) = new_temp(x,y)
-end
-
-Every temp(x,y) is a chare in this sample application.  The main chare
-sends a notice to all the nodes in our simulation telling them to
-exchange information.  After each node is done updating it's
-temperature, it sends a message back the error as the difference
-between temp and new_temp.  Main quits driving the iterations when the
-error has been minimized below some threshold.
-
-*/
-
-CProxy_Main mainProxy;
-int num_rows;
-int num_cols;
-
-//allowed variation between temp and new_temp
-float epsilon=1./1000;
-
-//temperatures on the various boundries
-float left = 1;
-float top = 1;
-float bottom = 0;
-float right = 0;
-
-
-class Main : public CBase_Main
-{
-public:
-    int receive_count;
-    CProxy_Jacobi array;
-    int num_chares;
-    int count;
-
-    Main(CkArgMsg* m) {
-       mainProxy = thisProxy;
-
-       //Allow the user to adjust the size of the grid at runtime
-       num_cols = 5;
-       if (m->argc == 2) {
-           num_cols = atoi(m->argv[1]);
-       }
-       delete m;
-       
-       num_rows = num_cols;
-        count = 0;
-
-       CkPrintf("Running Jacobi on %d processors with (%d,%d) elements\n",
-                CkNumPes(), num_rows, num_cols);
-
-       array = CProxy_Jacobi::ckNew(num_rows, num_cols);
-
-       //save the total number of worker chares we have in this simulation
-       num_chares = num_rows*num_cols;
-
-       //Start the computation
-       receive_count = num_chares;
-       array.begin_iteration();
-    }
-
-    float max_error;
-
-    void report_error(int row, int col, float error) {
-      //CkPrintf("[main] (%d, %d) error=%g\n", row, col, error);
-
-       if ((receive_count == num_chares) || (fabs(error) > max_error)) {
-           max_error = fabs(error);
-       }
-
-       receive_count--;
-       if (0 == receive_count) {
-            count++;
-           if (max_error < epsilon || count == 100) {
-               CkPrintf("All done\n");
-               CkExit();
-           } else {
-               CkPrintf("[main] error = %g, starting new iteration.\n", max_error);
-               receive_count=num_chares;
-               array.begin_iteration();
-           }
-       }
-    }
-};
-    
-class Jacobi: public CBase_Jacobi {
-public:
-    float temperature;
-    float update;
-    int messages_due;
-
-    Jacobi() {
-       temperature = 0;
-       messages_due = 4;
-    }
-
-    Jacobi(CkMigrateMessage* m) {}
-
-    //added for array migration
-    void pup(PUP::er &p){
-       p | temperature;
-       p | update;
-       p | messages_due;
-    }
-
-    void begin_iteration(void) {
-       /* messages_due should not be assigned here because it is not guaranteed
-        * that all elements' function "begin_iteration" are called before the
-        * function "receive_neighbor". Otherwise, the "messages_due" is messed up.
-        * For example, assuming the 2D array is of size 2*2. Then the array element(0,1)
-        * would send its data to element(1,1) and element(0,0) according to the sequence
-        * of calling "receive_neighbor" in this function. If element(1,1)'s "receive_neighbor"
-        * is called before its "begin_iteration" call and the "message_due" is reset
-        * in the "begin_iteration" function, then the "messages_due" of element(1,1) would be 
-        * messed up. Because one of 4 messages that element(1,1) needs to receive is already
-        * posted, the "messages_due" should not be reset, otherwise element(1,1) would think
-        * there's still one msg to receive and woudl not progress to the next iteration.
-        * The solution is to initialize the value in Jacobi's constructor and reset it
-        * before doing the next iteration (in the check_done_iteration function) --Chao Mei
-        */
-//     messages_due = 4;
-       update = 0;
-
-       //enforce the boundary conditions.  Nodes on an edge shouldn't
-       //send messages to non-existant chares.
-       if (thisIndex.x == 0) {
-           update += top;
-           messages_due--;
-       } else {
-           thisProxy(thisIndex.x-1, thisIndex.y).receive_neighbor(temperature);
-       }
-
-       if (thisIndex.x == num_rows-1) {
-           update += bottom;
-           messages_due--;
-       } else {
-           thisProxy(thisIndex.x+1, thisIndex.y).receive_neighbor(temperature);
-       }
-
-       if (thisIndex.y == 0) {
-           update += left;
-           messages_due--;
-       } else {
-           thisProxy(thisIndex.x, thisIndex.y-1).receive_neighbor(temperature);
-       }
-
-       if (thisIndex.y == num_cols-1) {
-           update += right;
-           messages_due--;
-       } else {
-           thisProxy(thisIndex.x, thisIndex.y+1).receive_neighbor(temperature);
-       }
-
-       //check to see if we still need messages.
-       check_done_iteration();
-    }
-
-    void receive_neighbor(float new_temperature) {
-       update += new_temperature;
-       messages_due--;
-       check_done_iteration();
-    }
-
-    void check_done_iteration() {
-       if (messages_due == 0) {
-           update /= 4;
-           float error = update-temperature;
-           temperature = update;
-           messages_due = 4;
-           mainProxy.report_error(thisIndex.x, thisIndex.y, error);
-       }
-    }
-};
-
-#include "jacobi2d.def.h"
diff --git a/examples/charm++/jacobi2d/jacobi2d.ci b/examples/charm++/jacobi2d/jacobi2d.ci
deleted file mode 100644 (file)
index fd8f736..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-mainmodule jacobi2d {
-  readonly CProxy_Main mainProxy;
-  readonly int num_rows;
-  readonly int num_cols;
-  readonly float left;
-  readonly float right;
-  readonly float bottom;
-  readonly float top;
-
-  mainchare Main {
-    entry Main(CkArgMsg *m);
-    entry void report_error(int, int, float);
-  };
-
-  array [2D] Jacobi {
-    entry Jacobi(void);
-    entry void begin_iteration(void);
-    entry void receive_neighbor(float);
-  };           
-};
similarity index 90%
rename from examples/charm++/jacobi3d-sdag/Makefile
rename to examples/charm++/jacobi3d-2d-decomposition/Makefile
index ff63c42fd4c99192cb1c76030cc32514f6a30d21..1be70331c8bf68ce9a9632a450a84a2a3d5069dc 100644 (file)
@@ -24,4 +24,4 @@ jacobi3d.o: jacobi3d.C jacobi3d.decl.h
        $(CHARMC) -c jacobi3d.C
 
 test: jacobi3d
-       ./charmrun +p2 ./jacobi3d 20 10 +balancer Refine $(TESTOPTS)
+       ./charmrun +p2 ./jacobi3d 32 16 $(TESTOPTS)
diff --git a/examples/charm++/jacobi3d-2d-decomposition/README b/examples/charm++/jacobi3d-2d-decomposition/README
new file mode 100644 (file)
index 0000000..bc6376f
--- /dev/null
@@ -0,0 +1,7 @@
+Jacobi iteration with a 3D Array.
+
+This code uses a 2-D blocked decomposition of a 3-d array with more
+than one element per chare. 
+
+Boundary conditions are obeyed in this example.  Control is expressed
+using structured dagger.
diff --git a/examples/charm++/jacobi3d-2d-decomposition/jacobi3d.C b/examples/charm++/jacobi3d-2d-decomposition/jacobi3d.C
new file mode 100644 (file)
index 0000000..80ccd63
--- /dev/null
@@ -0,0 +1,414 @@
+#define MAX_ITER       100     
+#define LEFT                   1
+#define RIGHT                  2
+#define TOP                    3
+#define BOTTOM                 4
+#define FRONT                  5
+#define BACK                   6
+#define DIVIDEBY7              0.14285714285714285714
+#define DELTA                  0.01
+
+const double THRESHOLD   =  0.004;
+#include "jacobi3d.decl.h"
+
+/*readonly*/ CProxy_Main mainProxy;
+/*readonly*/ int arrayDimX;
+/*readonly*/ int arrayDimY;
+/*readonly*/ int arrayDimZ;
+/*readonly*/ int blockDimX;
+/*readonly*/ int blockDimY;
+/*readonly*/ int blockDimZ;
+
+// specify the number of worker chares in each dimension
+/*readonly*/ int numChareX;
+/*readonly*/ int numChareY;
+/*readonly*/ int numChareZ;
+/*readonly*/ int maxiterations;
+
+class Main : public CBase_Main {
+  double startTime;
+  double endTime;
+public:
+  CProxy_Jacobi array;
+  int iterations;
+
+  Main(CkArgMsg* m) {
+    if ( (m->argc<3) || (m->argc>8) ) {
+      CkPrintf("%s [array_size] [block_size]\n", m->argv[0]);
+      CkPrintf("OR %s [array_size] [block_size] maxiterations\n", m->argv[0]);
+      CkPrintf("OR %s [array_size_X] [array_size_Y] [array_size_Z] [block_size_X] [block_size_Y] [block_size_Z]\n", m->argv[0]);
+      CkPrintf("OR %s [array_size_X] [array_size_Y] [array_size_Z] [block_size_X] [block_size_Y] [block_size_Z] maxiterations\n", m->argv[0]);
+      CkAbort("Abort");
+    }
+
+    iterations = 0;
+    // store the main proxy
+    mainProxy = thisProxy;
+
+    if(m->argc <=4 ) {
+      arrayDimX = arrayDimY = arrayDimZ = atoi(m->argv[1]);
+      blockDimX = blockDimY = blockDimZ = atoi(m->argv[2]); 
+    }
+    else if (m->argc <=8) {
+      arrayDimX = atoi(m->argv[1]);
+      arrayDimY = atoi(m->argv[2]);
+      arrayDimZ = atoi(m->argv[3]);
+      blockDimX = atoi(m->argv[4]); 
+      blockDimY = atoi(m->argv[5]); 
+      blockDimZ = atoi(m->argv[6]);
+    }
+
+    maxiterations = MAX_ITER;
+    if(m->argc==4)
+      maxiterations = atoi(m->argv[3]); 
+    if(m->argc==8)
+      maxiterations = atoi(m->argv[7]); 
+
+    if (arrayDimX < blockDimX || arrayDimX % blockDimX != 0)
+      CkAbort("array_size_X % block_size_X != 0!");
+    if (arrayDimY < blockDimY || arrayDimY % blockDimY != 0)
+      CkAbort("array_size_Y % block_size_Y != 0!");
+    if (arrayDimZ < blockDimZ || arrayDimZ % blockDimZ != 0)
+      CkAbort("array_size_Z % block_size_Z != 0!");
+
+    numChareX = arrayDimX / blockDimX;
+    numChareY = arrayDimY / blockDimY;
+    numChareZ = arrayDimZ / blockDimZ;
+
+    // print info
+    CkPrintf("\nSTENCIL COMPUTATION WITH NO BARRIERS\n");
+    CkPrintf("Running Jacobi on %d processors with (%d, %d, %d) chares\n", CkNumPes(), numChareX, numChareY, numChareZ);
+    CkPrintf("Array Dimensions: %d %d %d\n", arrayDimX, arrayDimY, arrayDimZ);
+    CkPrintf("Block Dimensions: %d %d %d\n", blockDimX, blockDimY, blockDimZ);
+
+    // Create new array of worker chares
+    array = CProxy_Jacobi::ckNew(numChareX, numChareY, numChareZ);
+
+    //Start the computation
+    array.run();
+    startTime = CkWallTimer();
+  }
+
+  void done(int totalIter)
+  {
+    if(totalIter >= maxiterations)
+      CkPrintf("Finish due to max iterations %d, total time %.3f seconds. \n", totalIter, CkWallTimer()-startTime); 
+    else
+      CkPrintf("Finish due to convergence, iterations %d, total time %.3f seconds. \n", totalIter, CkWallTimer()-startTime); 
+    CkExit();
+  }
+};
+
+
+class Jacobi: public CBase_Jacobi {
+  Jacobi_SDAG_CODE
+
+public:
+    int iterations;
+    int neighbors;
+    int remoteCount;
+    double error;
+    double ***temperature;
+    double ***new_temperature;
+    int converged;
+    bool leftBound, rightBound, topBound, bottomBound, frontBound, backBound;
+    int istart, jstart, kstart, ifinish, jfinish, kfinish;
+    double max_error;
+
+    // Constructor, initialize values
+    Jacobi() {
+      converged = 0;
+      neighbors = 0;
+      istart=jstart=kstart=1;
+      ifinish=blockDimX+1;
+      jfinish=blockDimY+1;
+      kfinish=blockDimZ+1;
+
+      leftBound = rightBound = topBound = bottomBound = frontBound = backBound = false;
+      if(thisIndex.x == 0) {
+        leftBound = true;
+        istart++;
+      }
+      else
+        neighbors++;
+      if(thisIndex.x == numChareX-1) {
+        rightBound = true;
+        ifinish--;
+      }
+      else
+        neighbors++;
+
+      if(thisIndex.y == 0) {
+        bottomBound = true;
+        jstart++;
+      }
+      else
+        neighbors++;
+
+      if(thisIndex.y == numChareY-1) {
+        topBound = true;
+        jfinish--;
+      }
+      else
+        neighbors++;
+
+      if(thisIndex.z == 0) {
+        backBound = true;
+        kstart++;
+      }
+      else
+        neighbors++;
+
+      if(thisIndex.z == numChareZ-1) {
+        frontBound = true;
+        kfinish--;
+      }
+      else
+        neighbors++;
+
+      // allocate a three dimensional array
+      temperature = new double**[blockDimX+2];
+      new_temperature = new double**[blockDimX+2];
+      for(int i=0; i<blockDimX+2; i++)
+      {
+        temperature[i] = new double*[blockDimY+2];
+        new_temperature[i] = new double*[blockDimY+2];
+        for(int j=0; j<blockDimY+2; j++)
+        {
+          temperature[i][j] = new double[blockDimZ+2];
+          new_temperature[i][j] = new double[blockDimZ+2];
+        }
+      }
+
+      for(int k=0; k<blockDimZ+2; ++k)
+        for(int j=0; j<blockDimY+2; ++j)
+          for(int i=0; i<blockDimX+2; ++i)
+            new_temperature[i][j][k] = temperature[i][j][k] = 0.0;
+      iterations = 0;
+      constrainBC();
+    }
+
+    void pup(PUP::er &p)
+    {
+      CBase_Jacobi::pup(p);
+      __sdag_pup(p);
+      p|iterations;
+      p|neighbors;
+
+      if (p.isUnpacking()) {
+        // allocate a three dimensional array
+        temperature = new double**[blockDimX+2];
+        new_temperature = new double**[blockDimX+2];
+        for(int i=0; i<blockDimX+2; i++)
+        {
+          temperature[i] = new double*[blockDimY+2];
+          new_temperature[i] = new double*[blockDimY+2];
+          for(int j=0; j<blockDimY+2; j++)
+          {
+            temperature[i][j] = new double[blockDimZ+2];
+            new_temperature[i][j] = new double[blockDimZ+2];
+          }
+        }
+      }
+
+      for(int k=0; k<blockDimZ+2; ++k)
+        for(int j=0; j<blockDimY+2; ++j)
+          for(int i=0; i<blockDimX+2; ++i)
+          {
+            p|new_temperature[i][j][k];
+            p|temperature[i][j][k];
+          }
+      iterations = 0;
+    }
+
+    Jacobi(CkMigrateMessage* m) { }
+
+    ~Jacobi() { 
+      delete [] temperature; 
+      delete [] new_temperature; 
+    }
+
+    // Send ghost faces to the six neighbors
+    void begin_iteration(void) {
+      iterations++;
+      // Copy different faces into messages
+      double *leftGhost =  new double[blockDimY*blockDimZ];
+      double *rightGhost =  new double[blockDimY*blockDimZ];
+      double *topGhost =  new double[blockDimX*blockDimZ];
+      double *bottomGhost =  new double[blockDimX*blockDimZ];
+      double *frontGhost =  new double[blockDimX*blockDimY];
+      double *backGhost =  new double[blockDimX*blockDimY];
+      for(int k=0; k<blockDimZ; ++k)
+        for(int j=0; j<blockDimY; ++j) {
+          leftGhost[k*blockDimY+j] = temperature[1][j+1][k+1];
+          rightGhost[k*blockDimY+j] = temperature[blockDimX][j+1][k+1];
+        }
+
+      for(int k=0; k<blockDimZ; ++k)
+        for(int i=0; i<blockDimX; ++i) {
+          bottomGhost[k*blockDimX+i] = temperature[i+1][1][k+1];
+          topGhost[k*blockDimX+i] = temperature[i+1][blockDimY][k+1];
+        }
+
+      for(int j=0; j<blockDimY; ++j)
+        for(int i=0; i<blockDimX; ++i) {
+          backGhost[j*blockDimX+i] = temperature[i+1][j+1][1];
+          frontGhost[j*blockDimX+i] = temperature[i+1][j+1][blockDimZ];
+        }
+
+      int x = thisIndex.x, y = thisIndex.y, z = thisIndex.z;
+      if(!leftBound)
+        thisProxy(x-1,y,z).receiveGhosts(iterations, RIGHT,  blockDimY, blockDimZ, leftGhost);
+      if(!rightBound)
+        thisProxy(x+1,y,z).receiveGhosts(iterations, LEFT,   blockDimY, blockDimZ, rightGhost);
+      if(!topBound)
+        thisProxy(x,y+1,z).receiveGhosts(iterations, BOTTOM,    blockDimX, blockDimZ, topGhost);
+      if(!bottomBound)
+        thisProxy(x,y-1,z).receiveGhosts(iterations, TOP, blockDimX, blockDimZ, bottomGhost);
+      if(!frontBound)
+        thisProxy(x,y,z+1).receiveGhosts(iterations, BACK,   blockDimX, blockDimY, frontGhost);
+      if(!backBound)
+        thisProxy(x,y,z-1).receiveGhosts(iterations, FRONT,  blockDimX, blockDimY, backGhost);
+
+      delete [] leftGhost;
+      delete [] rightGhost;
+      delete [] bottomGhost;
+      delete [] topGhost;
+      delete [] frontGhost;
+      delete [] backGhost;
+    }
+
+    void processGhosts(int dir, int height, int width, double* gh) {
+      switch(dir) {
+      case LEFT:
+        for(int k=0; k<width; ++k)
+          for(int j=0; j<height; ++j) {
+            temperature[0][j+1][k+1] = gh[k*height+j];
+          }
+        break;
+      case RIGHT:
+        for(int k=0; k<width; ++k)
+          for(int j=0; j<height; ++j) {
+            temperature[blockDimX+1][j+1][k+1] = gh[k*height+j];
+          }
+        break;
+      case BOTTOM:
+        for(int k=0; k<width; ++k)
+          for(int i=0; i<height; ++i) {
+            temperature[i+1][0][k+1] = gh[k*height+i];
+          }
+        break;
+      case TOP:
+        for(int k=0; k<width; ++k)
+          for(int i=0; i<height; ++i) {
+            temperature[i+1][blockDimY+1][k+1] = gh[k*height+i];
+          }
+        break;
+      case FRONT:
+        for(int j=0; j<width; ++j)
+          for(int i=0; i<height; ++i) {
+            temperature[i+1][j+1][blockDimZ+1] = gh[j*height+i];
+          }
+        break;
+      case BACK:
+        for(int j=0; j<width; ++j)
+          for(int i=0; i<height; ++i) {
+            temperature[i+1][j+1][0] = gh[j*height+i];
+          }
+        break;
+      default:
+        CkAbort("ERROR\n");
+      }
+    }
+
+    // Check to see if we have received all neighbor values yet
+    void check_and_compute() {
+      double error = 0.0;
+      max_error = 0.0;
+      for(int i=istart; i<ifinish; ++i) 
+        for(int j=jstart; j<jfinish; ++j)
+          for(int k=kstart; k<kfinish; ++k){
+            // update my value based on the surrounding values
+            new_temperature[i][j][k] = (temperature[i-1][j][k] 
+              +  temperature[i+1][j][k]
+              +  temperature[i][j-1][k]
+              +  temperature[i][j+1][k]
+              +  temperature[i][j][k-1]
+              +  temperature[i][j][k+1]
+              +  temperature[i][j][k] ) * DIVIDEBY7;
+            error = fabs(new_temperature[i][j][k] - temperature[i][j][k]);
+            if (error > max_error) {
+              max_error = error;
+            }
+          } // end for
+
+      double ***tmp;
+      tmp = temperature;
+      temperature = new_temperature;
+      new_temperature = tmp;
+      //dumpMatrix();
+    }
+
+    void dumpMatrix()
+    {
+
+      if(thisIndex.x + thisIndex.y + thisIndex.z == 0)
+      {
+        CkPrintf("\n\n[%d:%d:%d]\n", thisIndex.x, thisIndex.y, thisIndex.z);
+        for(int i=0; i<blockDimX+2; ++i){
+          for(int j=0; j<blockDimY+2; ++j){
+            for(int k=0; k<blockDimZ+2; ++k){
+              CkPrintf(" [%d:%d:%d %.3f] ", i,j,k, temperature[i][j][k]);
+            }
+            CkPrintf("\n");
+          }
+          CkPrintf("\n");
+        }
+        CkPrintf("\n\n");
+      }
+    }
+    // Enforce some boundary conditions
+    void constrainBC() {
+      if(leftBound)
+        for(int j=0; j<blockDimY+2; ++j)
+          for(int k=0; k<blockDimZ+2; ++k)
+          {   
+            new_temperature[1][j][k] = temperature[1][j][k] = 1.0;
+          }
+      if(rightBound)
+        for(int j=0; j<blockDimY+2; ++j)
+          for(int k=0; k<blockDimZ+2; ++k)
+          {   
+            new_temperature[blockDimX][j][k] = temperature[blockDimX][j][k] = 1.0;
+          }
+
+      if(topBound)
+        for(int i=0; i<blockDimX+2; ++i)
+          for(int k=0; k<blockDimZ+2; ++k)
+          {   
+            new_temperature[i][blockDimY][k]  = temperature[i][blockDimY][k] = 1.0;
+          }
+      if(bottomBound)
+        for(int i=0; i<blockDimX+2; ++i)
+          for(int k=0; k<blockDimZ+2; ++k)
+          {   
+            new_temperature[i][1][k]  = temperature[i][1][k] = 1.0;
+          }
+
+      if(frontBound)
+        for(int i=0; i<blockDimX+2; ++i)
+          for(int j=0; j<blockDimY+2; ++j)
+          {   
+            new_temperature[i][j][blockDimZ] = temperature[i][j][blockDimZ] = 1.0;
+          }
+
+      if(backBound)
+        for(int i=0; i<blockDimX+2; ++i)
+          for(int j=0; j<blockDimY+2; ++j)
+          {   
+            new_temperature[i][j][1] = temperature[i][j][1] = 1.0;
+          }
+    }
+};
+
+#include "jacobi3d.def.h"
diff --git a/examples/charm++/jacobi3d-2d-decomposition/jacobi3d.ci b/examples/charm++/jacobi3d-2d-decomposition/jacobi3d.ci
new file mode 100644 (file)
index 0000000..d9ed05f
--- /dev/null
@@ -0,0 +1,50 @@
+mainmodule jacobi3d {
+  readonly CProxy_Main mainProxy;
+  readonly int arrayDimX;
+  readonly int arrayDimY;
+  readonly int arrayDimZ;
+  readonly int blockDimX;
+  readonly int blockDimY;
+  readonly int blockDimZ;
+  readonly int numChareX;
+  readonly int numChareY;
+  readonly int numChareZ;
+  readonly int maxiterations;
+
+  mainchare Main {
+    entry Main(CkArgMsg *m);
+    entry [reductiontarget] void done(int);
+  };
+
+  array [3D] Jacobi {
+    entry Jacobi(void);
+    entry void receiveGhosts(int ref, int dir, int w, int h, double gh[w*h]);
+    entry [reductiontarget] void recvConvergeResult(int result);
+
+    entry void run() {
+      while (!converged && iterations<maxiterations) {
+        serial "begin_iteration" {
+          begin_iteration();
+        }
+        for (remoteCount = 0; remoteCount < neighbors; remoteCount++) {
+          when receiveGhosts[iterations](int ref, int dir, int w, int h, double buf[w*h]) serial {
+            processGhosts(dir, w, h, buf);
+          }
+        }
+
+        serial "compute" { 
+          check_and_compute();
+        }
+        serial "compute_converge" {
+          int conv = (max_error <= THRESHOLD);
+          CkCallback cb(CkReductionTarget(Jacobi, recvConvergeResult), thisProxy);
+          contribute(sizeof(int), &conv, CkReduction::logical_and, cb);
+        }
+        when recvConvergeResult(int result) serial "check_converge"{
+          converged = result;
+        if ((result || iterations>=maxiterations) && thisIndex.x +thisIndex.y == 0) mainProxy.done(iterations);
+      }
+      }
+    };
+  };
+};
diff --git a/examples/charm++/jacobi3d-sdag-constrain/Makefile b/examples/charm++/jacobi3d-sdag-constrain/Makefile
deleted file mode 100644 (file)
index 34373f5..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-OPTS   = -O3
-CHARMC = ../../../bin/charmc $(OPTS)
-
-OBJS = jacobi3d.o
-
-all: jacobi3d
-
-jacobi3d: $(OBJS)
-       $(CHARMC) -language charm++ -o jacobi3d $(OBJS)
-
-projections: $(OBJS)
-       $(CHARMC) -language charm++ -tracemode projections -lz -o jacobi3d.prj $(OBJS)
-
-summary: $(OBJS)
-       $(CHARMC) -language charm++ -tracemode summary -lz -o jacobi3d.sum $(OBJS)
-
-autoPerf: $(OBJS)
-       $(CHARMC) -language charm++ -tracemode autoPerf -lz -o jacobi3d.ap $(OBJS)
-
-jacobi3d.decl.h: jacobi3d.ci
-       $(CHARMC)  jacobi3d.ci
-
-clean:
-       rm -f *.decl.h *.def.h conv-host *.o jacobi3d jacobi3d.prj charmrun *~
-
-jacobi3d.o: jacobi3d.C jacobi3d.decl.h
-       $(CHARMC) -c jacobi3d.C
-
-test: jacobi3d
-       ./charmrun +p2 ./jacobi3d 20 10 +balancer Refine $(TESTOPTS)
diff --git a/examples/charm++/jacobi3d-sdag-constrain/jacobi3d.C b/examples/charm++/jacobi3d-sdag-constrain/jacobi3d.C
deleted file mode 100644 (file)
index 935832e..0000000
+++ /dev/null
@@ -1,344 +0,0 @@
-#define MAX_ITER       200     
-#define LEFT                   1
-#define RIGHT                  2
-#define TOP                    3
-#define BOTTOM                 4
-#define FRONT                  5
-#define BACK                   6
-#define DIVIDEBY7              0.14285714285714285714
-#define DELTA                  0.01
-
-#include "jacobi3d.decl.h"
-
-/*readonly*/ CProxy_Main mainProxy;
-/*readonly*/ int arrayDimX;
-/*readonly*/ int arrayDimY;
-/*readonly*/ int arrayDimZ;
-/*readonly*/ int blockDimX;
-/*readonly*/ int blockDimY;
-/*readonly*/ int blockDimZ;
-
-// specify the number of worker chares in each dimension
-/*readonly*/ int num_chare_x;
-/*readonly*/ int num_chare_y;
-/*readonly*/ int num_chare_z;
-/*readonly*/ int max_iter;
-
-#define wrapX(a)       (((a)+num_chare_x)%num_chare_x)
-#define wrapY(a)       (((a)+num_chare_y)%num_chare_y)
-#define wrapZ(a)       (((a)+num_chare_z)%num_chare_z)
-
-#define index(a,b,c)   ((a)+(b)*(blockDimX+2)+(c)*(blockDimX+2)*(blockDimY+2))
-
-double startTime;
-double endTime;
-
-/** \class Main
- *
- */
-class Main : public CBase_Main {
-public:
-  CProxy_Jacobi array;
-  int iterations;
-
-  Main(CkArgMsg* m) {
-    if ( (m->argc != 3) && (m->argc != 7) && (m->argc != 4) && (m->argc != 8)) {
-      CkPrintf("%s [array_size] [block_size]\n", m->argv[0]);
-      CkPrintf("OR %s [array_size_X] [array_size_Y] [array_size_Z] [block_size_X] [block_size_Y] [block_size_Z]\n", m->argv[0]);
-      CkAbort("Abort");
-    }
-
-    // set iteration counter to zero
-    iterations = 0;
-    max_iter = MAX_ITER;
-    // store the main proxy
-    mainProxy = thisProxy;
-       
-    if(m->argc <5 ) {
-      arrayDimX = arrayDimY = arrayDimZ = atoi(m->argv[1]);
-      blockDimX = blockDimY = blockDimZ = atoi(m->argv[2]); 
-      if(m->argc == 4)
-          max_iter =  atoi(m->argv[3]);
-    }
-    else if (m->argc <9) {
-      arrayDimX = atoi(m->argv[1]);
-      arrayDimY = atoi(m->argv[2]);
-      arrayDimZ = atoi(m->argv[3]);
-      blockDimX = atoi(m->argv[4]); 
-      blockDimY = atoi(m->argv[5]); 
-      blockDimZ = atoi(m->argv[6]);
-      if(m->argc == 8)
-          max_iter =  atoi(m->argv[7]);
-    }
-
-    if (arrayDimX < blockDimX || arrayDimX % blockDimX != 0)
-      CkAbort("array_size_X % block_size_X != 0!");
-    if (arrayDimY < blockDimY || arrayDimY % blockDimY != 0)
-      CkAbort("array_size_Y % block_size_Y != 0!");
-    if (arrayDimZ < blockDimZ || arrayDimZ % blockDimZ != 0)
-      CkAbort("array_size_Z % block_size_Z != 0!");
-
-    num_chare_x = arrayDimX / blockDimX;
-    num_chare_y = arrayDimY / blockDimY;
-    num_chare_z = arrayDimZ / blockDimZ;
-
-    // print info
-    CkPrintf("\nSTENCIL COMPUTATION WITH NO BARRIERS\n");
-    CkPrintf("Running Jacobi on %d processors with (%d, %d, %d) chares\n", CkNumPes(), num_chare_x, num_chare_y, num_chare_z);
-    CkPrintf("Array Dimensions: %d %d %d\n", arrayDimX, arrayDimY, arrayDimZ);
-    CkPrintf("Block Dimensions: %d %d %d\n", blockDimX, blockDimY, blockDimZ);
-
-    // Create new array of worker chares
-    array = CProxy_Jacobi::ckNew(num_chare_x, num_chare_y, num_chare_z);
-
-    //Start the computation
-    array.run();
-    startTime = CkWallTimer();
-  }
-
-  void commonExit(int iter)
-  {
-    endTime = CkWallTimer();
-    CkPrintf("Time elapsed per iteration: %f total time %f \n", (endTime - startTime) / iter, (endTime-startTime));
-    CkExit();
-
-  }
-  void doneConverge(int done_iters) {
-      CkPrintf(" finished due to convergence %d \n", done_iters); 
-      commonExit(done_iters);
-  }
-  void doneIter(double error)
-  {
-      CkPrintf(" finished due to maximum iterations %d with error  %f \n", max_iter, error); 
-      commonExit(max_iter);
-  }
-};
-
-/** \class Jacobi
- *
- */
-
-class Jacobi: public CBase_Jacobi {
-  Jacobi_SDAG_CODE
-
-public:
-  int iterations;
-  int neighbors;
-  int remoteCount;
-  double error;
-  double *temperature;
-  double *new_temperature;
-  bool converged;
-
-  // Constructor, initialize values
-  Jacobi() {
-    converged = false;
-    neighbors = 6;
-    if(thisIndex.x == 0) 
-        neighbors--;
-    if( thisIndex.x== num_chare_x-1)
-        neighbors--;
-    if(thisIndex.y == 0) 
-        neighbors--;
-    if( thisIndex.y== num_chare_y-1)
-        neighbors--;
-    if(thisIndex.z == 0) 
-        neighbors--;
-    if( thisIndex.z== num_chare_z-1)
-          neighbors--;
-
-    // allocate a three dimensional array
-    temperature = new double[(blockDimX+2) * (blockDimY+2) * (blockDimZ+2)];
-    new_temperature = new double[(blockDimX+2) * (blockDimY+2) * (blockDimZ+2)];
-
-    for(int k=0; k<blockDimZ+2; ++k)
-      for(int j=0; j<blockDimY+2; ++j)
-        for(int i=0; i<blockDimX+2; ++i)
-          new_temperature[index(i, j, k)] = temperature[index(i, j, k)] = 0.0;
-    //print();
-    iterations = 0;
-    constrainBC();
-    //print();
-  }
-
-  void pup(PUP::er &p)
-  {
-    CBase_Jacobi::pup(p);
-    __sdag_pup(p);
-    p|iterations;
-    p|neighbors;
-
-    size_t size = (blockDimX+2) * (blockDimY+2) * (blockDimZ+2);
-    if (p.isUnpacking()) {
-      temperature = new double[size];
-      new_temperature = new double[size];
-    }
-    p(temperature, size);
-    p(new_temperature, size);
-  }
-
-  Jacobi(CkMigrateMessage* m) { }
-
-  ~Jacobi() { 
-    delete [] temperature; 
-    delete [] new_temperature; 
-  }
-
-  // Send ghost faces to the six neighbors
-  void begin_iteration(void) {
-    // Copy different faces into messages
-    double *leftGhost =  new double[blockDimY*blockDimZ];
-    double *rightGhost =  new double[blockDimY*blockDimZ];
-    double *topGhost =  new double[blockDimX*blockDimZ];
-    double *bottomGhost =  new double[blockDimX*blockDimZ];
-    double *frontGhost =  new double[blockDimX*blockDimY];
-    double *backGhost =  new double[blockDimX*blockDimY];
-    for(int k=0; k<blockDimZ; ++k)
-      for(int j=0; j<blockDimY; ++j) {
-        leftGhost[k*blockDimY+j] = temperature[index(1, j+1, k+1)];
-        rightGhost[k*blockDimY+j] = temperature[index(blockDimX, j+1, k+1)];
-      }
-
-    for(int k=0; k<blockDimZ; ++k)
-      for(int i=0; i<blockDimX; ++i) {
-        topGhost[k*blockDimX+i] = temperature[index(i+1, 1, k+1)];
-        bottomGhost[k*blockDimX+i] = temperature[index(i+1, blockDimY, k+1)];
-      }
-
-    for(int j=0; j<blockDimY; ++j)
-      for(int i=0; i<blockDimX; ++i) {
-        frontGhost[j*blockDimX+i] = temperature[index(i+1, j+1, 1)];
-        backGhost[j*blockDimX+i] = temperature[index(i+1, j+1, blockDimZ)];
-      }
-
-    int x = thisIndex.x, y = thisIndex.y, z = thisIndex.z;
-    if(thisIndex.x>0)
-        thisProxy(wrapX(x-1),y,z).updateGhosts(iterations, RIGHT,  blockDimY, blockDimZ, rightGhost);
-    if(thisIndex.x<num_chare_x-1)
-        thisProxy(wrapX(x+1),y,z).updateGhosts(iterations, LEFT,   blockDimY, blockDimZ, leftGhost);
-    if(thisIndex.y>0)
-        thisProxy(x,wrapY(y-1),z).updateGhosts(iterations, TOP,    blockDimX, blockDimZ, topGhost);
-    if(thisIndex.y<num_chare_y-1)
-        thisProxy(x,wrapY(y+1),z).updateGhosts(iterations, BOTTOM, blockDimX, blockDimZ, bottomGhost);
-    if(thisIndex.z>0)
-        thisProxy(x,y,wrapZ(z-1)).updateGhosts(iterations, BACK,   blockDimX, blockDimY, backGhost);
-    if(thisIndex.z<num_chare_z-1)
-        thisProxy(x,y,wrapZ(z+1)).updateGhosts(iterations, FRONT,  blockDimX, blockDimY, frontGhost);
-
-    delete [] leftGhost;
-    delete [] rightGhost;
-    delete [] bottomGhost;
-    delete [] topGhost;
-    delete [] frontGhost;
-    delete [] backGhost;
-  }
-
-  void updateBoundary(int dir, int height, int width, double* gh) {
-    switch(dir) {
-    case LEFT:
-      for(int k=0; k<width; ++k)
-        for(int j=0; j<height; ++j) {
-          temperature[index(0, j+1, k+1)] = gh[k*height+j];
-        }
-      break;
-    case RIGHT:
-      for(int k=0; k<width; ++k)
-        for(int j=0; j<height; ++j) {
-          temperature[index(blockDimX+1, j+1, k+1)] = gh[k*height+j];
-        }
-      break;
-    case BOTTOM:
-      for(int k=0; k<width; ++k)
-        for(int i=0; i<height; ++i) {
-          temperature[index(i+1, 0, k+1)] = gh[k*height+i];
-        }
-      break;
-    case TOP:
-      for(int k=0; k<width; ++k)
-        for(int i=0; i<height; ++i) {
-          temperature[index(i+1, blockDimY+1, k+1)] = gh[k*height+i];
-        }
-      break;
-    case FRONT:
-      for(int j=0; j<width; ++j)
-        for(int i=0; i<height; ++i) {
-          temperature[index(i+1, j+1, 0)] = gh[j*height+i];
-        }
-      break;
-    case BACK:
-      for(int j=0; j<width; ++j)
-        for(int i=0; i<height; ++i) {
-          temperature[index(i+1, j+1, blockDimZ+1)] = gh[j*height+i];
-        }
-      break;
-    default:
-      CkAbort("ERROR\n");
-    }
-  }
-
-  // Check to see if we have received all neighbor values yet
-  // If all neighbor values have been received, we update our values and proceed
-  double computeKernel() {
-    double error = 0.0, max_error = 0.0;
-    for(int k=1; k<blockDimZ+1; ++k)
-      for(int j=1; j<blockDimY+1; ++j)
-        for(int i=1; i<blockDimX+1; ++i) {
-          // update my value based on the surrounding values
-          new_temperature[index(i, j, k)] = (temperature[index(i-1, j, k)] 
-                                             +  temperature[index(i+1, j, k)]
-                                             +  temperature[index(i, j-1, k)]
-                                             +  temperature[index(i, j+1, k)]
-                                             +  temperature[index(i, j, k-1)]
-                                             +  temperature[index(i, j, k+1)]
-                                             +  temperature[index(i, j, k)] ) * DIVIDEBY7;
-          error = fabs(new_temperature[index(i,j,k)] - temperature[index(i,j,k)]);
-          if (error > max_error) {
-            max_error = error;
-          }
-        } // end for
-    
-    double *tmp;
-    tmp = temperature;
-    temperature = new_temperature;
-    new_temperature = tmp;
-
-    //constrainBC();
-
-    return max_error;
-  }
-
-  void print()
-  {
-
-    for(int k=1; k<blockDimZ+2; ++k)
-      for(int j=1; j<blockDimY+2; ++j)
-        for(int i=1; i<blockDimX+2; ++i)
-          CkPrintf(" -%d:%d:%d %f ", k,j,i, temperature[index(k, j, i)]);
-    CkPrintf("--------------------------------\n");
-  }
-  // Enforce some boundary conditions
-  void constrainBC() {
-    // // Heat right, left
-    if(thisIndex.x == 0 )
-        for(int j=0; j<blockDimY+2; ++j)
-            for(int k=0; k<blockDimZ+2; ++k)
-            {   
-                new_temperature[index(0, j, k)] = temperature[index(0, j, k)] = 255.0;
-            }
-    if(thisIndex.y == 0 )
-        for(int j=0; j<blockDimX+2; ++j)
-            for(int k=0; k<blockDimZ+2; ++k)
-            {   
-                new_temperature[index(j,0, k)]  = temperature[index(j,0, k)] = 255.0;
-            }
-    if(thisIndex.z == 0 )
-        for(int j=0; j<blockDimX+2; ++j)
-            for(int k=0; k<blockDimY+2; ++k)
-            {   
-                new_temperature[index(j, k, 0)] = temperature[index(j, k, 0)] = 255.0;
-            }
-
-  }
-};
-
-#include "jacobi3d.def.h"
diff --git a/examples/charm++/jacobi3d-sdag-constrain/jacobi3d.ci b/examples/charm++/jacobi3d-sdag-constrain/jacobi3d.ci
deleted file mode 100644 (file)
index 879379d..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-mainmodule jacobi3d {
-  readonly CProxy_Main mainProxy;
-  readonly int arrayDimX;
-  readonly int arrayDimY;
-  readonly int arrayDimZ;
-  readonly int blockDimX;
-  readonly int blockDimY;
-  readonly int blockDimZ;
-  readonly int num_chare_x;
-  readonly int num_chare_y;
-  readonly int num_chare_z;
-  readonly int max_iter;
-
-  mainchare Main {
-    entry Main(CkArgMsg *m);
-    entry [reductiontarget] void doneConverge(int);
-    entry [reductiontarget] void doneIter(double);
-  };
-
-  array [3D] Jacobi {
-    entry Jacobi(void);
-    entry void updateGhosts(int ref, int dir, int w, int h, double gh[w*h]);
-    entry [reductiontarget] void checkConverged(double e);
-    entry void run() {
-      while (iterations < max_iter && !converged) {
-        atomic { begin_iteration(); }
-        for (remoteCount = 0; remoteCount < neighbors; remoteCount++) {
-          when updateGhosts[iterations](int ref, int dir, int w, int h, double buf[w*h]) atomic {
-            updateBoundary(dir, w, h, buf);
-          }
-        }
-        atomic {
-          error = computeKernel();
-          //CkPrintf(" error   %d %d %d  is %f\n", thisIndex.x, thisIndex.y, thisIndex.z, error);
-          iterations++;
-          contribute(sizeof(double), &error, CkReduction::max_double, CkCallback(CkReductionTarget(Jacobi, checkConverged), thisProxy));
-        }
-        when checkConverged(double maxerror)
-        {
-            if (maxerror<DELTA) atomic{ converged = true; contribute(sizeof(int), &iterations, CkReduction::nop, CkCallback((CkReductionTarget(Main, doneConverge)), mainProxy)); }
-        }
-      }
-      if(iterations >= max_iter)
-          atomic { contribute(sizeof(double), &error, CkReduction::max_double, CkCallback((CkReductionTarget(Main, doneIter)), mainProxy));}
-
-    };
-  };
-};
diff --git a/examples/charm++/jacobi3d-sdag/jacobi3d.C b/examples/charm++/jacobi3d-sdag/jacobi3d.C
deleted file mode 100644 (file)
index 21c43ad..0000000
+++ /dev/null
@@ -1,301 +0,0 @@
-#define MAX_ITER               26
-#define LEFT                   1
-#define RIGHT                  2
-#define TOP                    3
-#define BOTTOM                 4
-#define FRONT                  5
-#define BACK                   6
-#define DIVIDEBY7              0.14285714285714285714
-#define DELTA                  0.01
-#define LBPERIOD                       50
-#define CHECKPOINTPERIOD        500
-
-#include "jacobi3d.decl.h"
-
-/*readonly*/ CProxy_Main mainProxy;
-/*readonly*/ int arrayDimX;
-/*readonly*/ int arrayDimY;
-/*readonly*/ int arrayDimZ;
-/*readonly*/ int blockDimX;
-/*readonly*/ int blockDimY;
-/*readonly*/ int blockDimZ;
-
-// specify the number of worker chares in each dimension
-/*readonly*/ int num_chare_x;
-/*readonly*/ int num_chare_y;
-/*readonly*/ int num_chare_z;
-
-#define wrapX(a)       (((a)+num_chare_x)%num_chare_x)
-#define wrapY(a)       (((a)+num_chare_y)%num_chare_y)
-#define wrapZ(a)       (((a)+num_chare_z)%num_chare_z)
-
-#define index(a,b,c)   ((a)+(b)*(blockDimX+2)+(c)*(blockDimX+2)*(blockDimY+2))
-
-double startTime;
-double endTime;
-
-/** \class Main
- *
- */
-class Main : public CBase_Main {
-public:
-  CProxy_Jacobi array;
-  int iterations;
-
-  Main(CkArgMsg* m) {
-    if ( (m->argc != 3) && (m->argc != 7) ) {
-      CkPrintf("%s [array_size] [block_size]\n", m->argv[0]);
-      CkPrintf("OR %s [array_size_X] [array_size_Y] [array_size_Z] [block_size_X] [block_size_Y] [block_size_Z]\n", m->argv[0]);
-      CkAbort("Abort");
-    }
-
-    // set iteration counter to zero
-    iterations = 0;
-
-    // store the main proxy
-    mainProxy = thisProxy;
-       
-    if(m->argc == 3) {
-      arrayDimX = arrayDimY = arrayDimZ = atoi(m->argv[1]);
-      blockDimX = blockDimY = blockDimZ = atoi(m->argv[2]); 
-    }
-    else if (m->argc == 7) {
-      arrayDimX = atoi(m->argv[1]);
-      arrayDimY = atoi(m->argv[2]);
-      arrayDimZ = atoi(m->argv[3]);
-      blockDimX = atoi(m->argv[4]); 
-      blockDimY = atoi(m->argv[5]); 
-      blockDimZ = atoi(m->argv[6]);
-    }
-
-    if (arrayDimX < blockDimX || arrayDimX % blockDimX != 0)
-      CkAbort("array_size_X % block_size_X != 0!");
-    if (arrayDimY < blockDimY || arrayDimY % blockDimY != 0)
-      CkAbort("array_size_Y % block_size_Y != 0!");
-    if (arrayDimZ < blockDimZ || arrayDimZ % blockDimZ != 0)
-      CkAbort("array_size_Z % block_size_Z != 0!");
-
-    num_chare_x = arrayDimX / blockDimX;
-    num_chare_y = arrayDimY / blockDimY;
-    num_chare_z = arrayDimZ / blockDimZ;
-
-    // print info
-    CkPrintf("\nSTENCIL COMPUTATION WITH NO BARRIERS\n");
-    CkPrintf("Running Jacobi on %d processors with (%d, %d, %d) chares\n", CkNumPes(), num_chare_x, num_chare_y, num_chare_z);
-    CkPrintf("Array Dimensions: %d %d %d\n", arrayDimX, arrayDimY, arrayDimZ);
-    CkPrintf("Block Dimensions: %d %d %d\n", blockDimX, blockDimY, blockDimZ);
-
-    // Create new array of worker chares
-    array = CProxy_Jacobi::ckNew(num_chare_x, num_chare_y, num_chare_z);
-
-    //Start the computation
-    array.run();
-    startTime = CkWallTimer();
-  }
-
-  void done(int iterations) {
-    CkPrintf("Completed %d iterations\n", iterations);
-    endTime = CkWallTimer();
-    CkPrintf("Time elapsed per iteration: %f\n", (endTime - startTime) / iterations);
-    CkExit();
-  }
-};
-
-/** \class Jacobi
- *
- */
-
-class Jacobi: public CBase_Jacobi {
-  Jacobi_SDAG_CODE
-
-public:
-  int iterations;
-  int remoteCount;
-
-  double *temperature;
-  double *new_temperature;
-  bool converged;
-
-  // Constructor, initialize values
-  Jacobi() {
-    usesAtSync = true;
-    converged = false;
-
-    // allocate a three dimensional array
-    temperature = new double[(blockDimX+2) * (blockDimY+2) * (blockDimZ+2)];
-    new_temperature = new double[(blockDimX+2) * (blockDimY+2) * (blockDimZ+2)];
-
-    for(int k=0; k<blockDimZ+2; ++k)
-      for(int j=0; j<blockDimY+2; ++j)
-        for(int i=0; i<blockDimX+2; ++i)
-          temperature[index(i, j, k)] = 0.0;
-
-    iterations = 0;
-    constrainBC();
-  }
-
-  void pup(PUP::er &p)
-  {
-    CBase_Jacobi::pup(p);
-    __sdag_pup(p);
-    p|iterations;
-    p|remoteCount;
-
-    size_t size = (blockDimX+2) * (blockDimY+2) * (blockDimZ+2);
-    if (p.isUnpacking()) {
-      temperature = new double[size];
-      new_temperature = new double[size];
-    }
-    p(temperature, size);
-    p(new_temperature, size);
-  }
-
-  Jacobi(CkMigrateMessage* m) { }
-
-  ~Jacobi() { 
-    delete [] temperature; 
-    delete [] new_temperature; 
-  }
-
-  // Send ghost faces to the six neighbors
-  void begin_iteration(void) {
-    // Copy different faces into messages
-    double *leftGhost =  new double[blockDimY*blockDimZ];
-    double *rightGhost =  new double[blockDimY*blockDimZ];
-    double *topGhost =  new double[blockDimX*blockDimZ];
-    double *bottomGhost =  new double[blockDimX*blockDimZ];
-    double *frontGhost =  new double[blockDimX*blockDimY];
-    double *backGhost =  new double[blockDimX*blockDimY];
-
-    for(int k=0; k<blockDimZ; ++k)
-      for(int j=0; j<blockDimY; ++j) {
-        leftGhost[k*blockDimY+j] = temperature[index(1, j+1, k+1)];
-        rightGhost[k*blockDimY+j] = temperature[index(blockDimX, j+1, k+1)];
-      }
-
-    for(int k=0; k<blockDimZ; ++k)
-      for(int i=0; i<blockDimX; ++i) {
-        topGhost[k*blockDimX+i] = temperature[index(i+1, 1, k+1)];
-        bottomGhost[k*blockDimX+i] = temperature[index(i+1, blockDimY, k+1)];
-      }
-
-    for(int j=0; j<blockDimY; ++j)
-      for(int i=0; i<blockDimX; ++i) {
-        frontGhost[j*blockDimX+i] = temperature[index(i+1, j+1, 1)];
-        backGhost[j*blockDimX+i] = temperature[index(i+1, j+1, blockDimZ)];
-      }
-
-    int x = thisIndex.x, y = thisIndex.y, z = thisIndex.z;
-    thisProxy(wrapX(x-1),y,z).updateGhosts(iterations, RIGHT,  blockDimY, blockDimZ, rightGhost);
-    thisProxy(wrapX(x+1),y,z).updateGhosts(iterations, LEFT,   blockDimY, blockDimZ, leftGhost);
-    thisProxy(x,wrapY(y-1),z).updateGhosts(iterations, TOP,    blockDimX, blockDimZ, topGhost);
-    thisProxy(x,wrapY(y+1),z).updateGhosts(iterations, BOTTOM, blockDimX, blockDimZ, bottomGhost);
-    thisProxy(x,y,wrapZ(z-1)).updateGhosts(iterations, BACK,   blockDimX, blockDimY, backGhost);
-    thisProxy(x,y,wrapZ(z+1)).updateGhosts(iterations, FRONT,  blockDimX, blockDimY, frontGhost);
-
-    delete [] leftGhost;
-    delete [] rightGhost;
-    delete [] bottomGhost;
-    delete [] topGhost;
-    delete [] frontGhost;
-    delete [] backGhost;
-  }
-
-  void updateBoundary(int dir, int height, int width, double* gh) {
-    switch(dir) {
-    case LEFT:
-      for(int k=0; k<width; ++k)
-        for(int j=0; j<height; ++j) {
-          temperature[index(0, j+1, k+1)] = gh[k*height+j];
-        }
-      break;
-    case RIGHT:
-      for(int k=0; k<width; ++k)
-        for(int j=0; j<height; ++j) {
-          temperature[index(blockDimX+1, j+1, k+1)] = gh[k*height+j];
-        }
-      break;
-    case BOTTOM:
-      for(int k=0; k<width; ++k)
-        for(int i=0; i<height; ++i) {
-          temperature[index(i+1, 0, k+1)] = gh[k*height+i];
-        }
-      break;
-    case TOP:
-      for(int k=0; k<width; ++k)
-        for(int i=0; i<height; ++i) {
-          temperature[index(i+1, blockDimY+1, k+1)] = gh[k*height+i];
-        }
-      break;
-    case FRONT:
-      for(int j=0; j<width; ++j)
-        for(int i=0; i<height; ++i) {
-          temperature[index(i+1, j+1, 0)] = gh[j*height+i];
-        }
-      break;
-    case BACK:
-      for(int j=0; j<width; ++j)
-        for(int i=0; i<height; ++i) {
-          temperature[index(i+1, j+1, blockDimZ+1)] = gh[j*height+i];
-        }
-      break;
-    default:
-      CkAbort("ERROR\n");
-    }
-  }
-
-  // Check to see if we have received all neighbor values yet
-  // If all neighbor values have been received, we update our values and proceed
-  double computeKernel() {
-#pragma unroll    
-    for(int k=1; k<blockDimZ+1; ++k)
-      for(int j=1; j<blockDimY+1; ++j)
-        for(int i=1; i<blockDimX+1; ++i) {
-          // update my value based on the surrounding values
-          new_temperature[index(i, j, k)] = (temperature[index(i-1, j, k)] 
-                                             +  temperature[index(i+1, j, k)]
-                                             +  temperature[index(i, j-1, k)]
-                                             +  temperature[index(i, j+1, k)]
-                                             +  temperature[index(i, j, k-1)]
-                                             +  temperature[index(i, j, k+1)]
-                                             +  temperature[index(i, j, k)] ) * DIVIDEBY7;
-        } // end for
-    
-    double error = 0.0, max_error = 0.0;
-
-    for(int k=1; k<blockDimZ+1; ++k)
-      for(int j=1; j<blockDimY+1; ++j)
-        for(int i=1; i<blockDimX+1; ++i) {
-          error = fabs(new_temperature[index(i,j,k)] - temperature[index(i,j,k)]);
-          if (error > max_error) {
-            max_error = error;
-          }
-        }
-
-    double *tmp;
-    tmp = temperature;
-    temperature = new_temperature;
-    new_temperature = tmp;
-
-    constrainBC();
-
-    return max_error;
-  }
-
-  // Enforce some boundary conditions
-  void constrainBC() {
-    // Heat left, top and front faces of each chare's block
-    for(int k=1; k<blockDimZ+1; ++k)
-      for(int i=1; i<blockDimX+1; ++i)
-        temperature[index(i, 1, k)] = 255.0;
-    for(int k=1; k<blockDimZ+1; ++k)
-      for(int j=1; j<blockDimY+1; ++j)
-        temperature[index(1, j, k)] = 255.0;
-    for(int j=1; j<blockDimY+1; ++j)
-      for(int i=1; i<blockDimX+1; ++i)
-        temperature[index(i, j, 1)] = 255.0;
-  }
-
-};
-
-#include "jacobi3d.def.h"
diff --git a/examples/charm++/jacobi3d-sdag/jacobi3d.ci b/examples/charm++/jacobi3d-sdag/jacobi3d.ci
deleted file mode 100644 (file)
index 10ee4d3..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-mainmodule jacobi3d {
-  readonly CProxy_Main mainProxy;
-  readonly int arrayDimX;
-  readonly int arrayDimY;
-  readonly int arrayDimZ;
-  readonly int blockDimX;
-  readonly int blockDimY;
-  readonly int blockDimZ;
-  readonly int num_chare_x;
-  readonly int num_chare_y;
-  readonly int num_chare_z;
-
-  mainchare Main {
-    entry Main(CkArgMsg *m);
-    entry void done(int iterations);
-  };
-
-  array [3D] Jacobi {
-    entry Jacobi(void);
-    entry void updateGhosts(int ref, int dir, int w, int h, double gh[w*h]);
-    entry [reductiontarget] void checkConverged(bool result);
-    entry void checkpointFinished();
-    entry void run() {
-      while (!converged) {
-        atomic { begin_iteration(); }
-        for (remoteCount = 0; remoteCount < 6; remoteCount++) {
-          when updateGhosts[iterations](int ref, int dir, int w, int h, double buf[w*h]) atomic {
-            updateBoundary(dir, w, h, buf);
-          }
-        }
-        atomic {
-          double error = computeKernel();
-          int conv = error < DELTA;
-          if (iterations % 5 == 1) {
-            contribute(sizeof(int), &conv, CkReduction::logical_and, CkCallback(CkReductionTarget(Jacobi, checkConverged), thisProxy));
-          }
-        }
-        if (++iterations % 5 == 0)
-          when checkConverged(bool result)
-            if (result) atomic { mainProxy.done(iterations); converged = true; }
-        if (iterations % LBPERIOD == 0) atomic { AtSync(); }
-        if (iterations % CHECKPOINTPERIOD == 0) {
-          atomic {
-            CkCallback cb(CkIndex_Jacobi::checkpointFinished(), thisProxy);
-            CkStartMemCheckpoint(cb);
-          }
-          when checkpointFinished() { }
-        }
-      }
-    };
-  };
-};