Example charm++/matmul: simplify logic for when to pass blocks
authorPhil Miller <mille121@illinois.edu>
Tue, 8 May 2012 19:30:42 +0000 (14:30 -0500)
committerPhil Miller <mille121@illinois.edu>
Tue, 8 May 2012 19:30:42 +0000 (14:30 -0500)
examples/charm++/matmul/matmul.ci

index 054332ea523d35edcfb86d3c8ba9399b63f94fff..7b8696afd9c584491683db7d145a13e8e7b0ca87 100644 (file)
@@ -10,9 +10,9 @@ mainmodule matmul {
     entry void pdgemmSendInput(CProxy_Block output, bool aOrB) {
       atomic {
         if (aOrB)
-          output[thisIndex].inputA(thisIndex.x, data, blockSize, true);
+          output[thisIndex].inputA(0, data, blockSize);
         else
-          output[thisIndex].inputB(thisIndex.y, data, blockSize, true);
+          output[thisIndex].inputB(0, data, blockSize);
       }
     };
 
@@ -20,24 +20,24 @@ mainmodule matmul {
       forall [block] (0:numBlocks-1,1) {
         when
           inputA[block](int blockIdA, double blockA[blockSizeA*blockSizeA],
-                        unsigned int blockSizeA, bool fromSourceA),
+                        unsigned int blockSizeA),
           inputB[block](int blockIdB, double blockB[blockSizeB*blockSizeB],
-                        unsigned int blockSizeB, bool fromSourceB) atomic {
+                        unsigned int blockSizeB) atomic {
           CkAssert(blockSizeA == blockSizeB);
           cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
                       blockSize, blockSize, blockSize,
                       alpha,
                       blockA, blockSize, blockB, blockSize,
                       beta, data, blockSize);
-          if (fromSourceA || ((blockIdA + numBlocks - 1) % numBlocks != thisIndex.x)) {
+          if (blockIdA != numBlocks) {
             int destX = (thisIndex.x + 1) % numBlocks;
             int destY = thisIndex.y;
-            thisProxy(destX, destY).inputA(blockIdA, blockA, blockSizeA);
+            thisProxy(destX, destY).inputA(blockIdA+1, blockA, blockSizeA);
           }
-          if (fromSourceB || ((blockIdB + numBlocks - 1) % numBlocks != thisIndex.y)) {
+          if (blockIdB != numBlocks) {
             int destX = thisIndex.x;
             int destY = (thisIndex.y + 1) % numBlocks;
-            thisProxy(destX, destY).inputB(blockIdB, blockB, blockSizeB);
+            thisProxy(destX, destY).inputB(blockIdB+1, blockB, blockSizeB);
           }
         }
       }
@@ -45,7 +45,7 @@ mainmodule matmul {
         contribute(done);
       }
     };
-    entry void inputA(int blockIdA, double blockA[blockSizeA*blockSizeA], unsigned int blockSizeA, bool fromSource = false);
-    entry void inputB(int blockIdB, double blockB[blockSizeB*blockSizeB], unsigned int blockSizeB, bool fromSource = false);
+    entry void inputA(int blockIdA, double blockA[blockSizeA*blockSizeA], unsigned int blockSizeA);
+    entry void inputB(int blockIdB, double blockB[blockSizeB*blockSizeB], unsigned int blockSizeB);
   };
 };