changes
authorbdemsky <bdemsky>
Thu, 16 Apr 2009 07:41:46 +0000 (07:41 +0000)
committerbdemsky <bdemsky>
Thu, 16 Apr 2009 07:41:46 +0000 (07:41 +0000)
Robust/src/Benchmarks/SingleTM/LeeRouting/LeeRouter.java
Robust/src/Benchmarks/SingleTM/LeeRouting/LeeThread.java
Robust/src/Benchmarks/SingleTM/LeeRouting/makefile
Robust/src/Benchmarks/SingleTM/MatrixMultiply/MatrixMultiplyN.java [new file with mode: 0644]
Robust/src/Benchmarks/SingleTM/MatrixMultiply/makefile [new file with mode: 0644]

index a946f6177d83a3957491da067e639f5b6e8d62f4..e01422403942c84b8ab9d22bd9521a0b13aba8f0 100644 (file)
@@ -508,9 +508,10 @@ public class LeeRouter {
         tempg[tempX][tempY][tempZ] = viat;
         grid.setPoint(tempX,tempY,tempZ,viat);
         if(DEBUG)grid.setDebugPoint(tempX,tempY,tempZ,trackNo);
-        num_vias++;
-        if (!advanced)
-          forced_vias++;
+       //XXXXXXX- changes to make transactional
+       //        num_vias++;
+        //if (!advanced)
+       // forced_vias++;
         if (advanced)
           if(DEBUG)
             System.out.println("Via " + distsofar + " "
@@ -574,6 +575,7 @@ public class LeeRouter {
     else {
       if(DEBUG) System.out.println("Failed to route " + xs + " " + ys + " to " + xg
           + "  " + yg);
+      System.out.println("Failure");
       failures++;
     }
     return found;
index 96d6e0e8769a7da972bf60f6dedfbc3ee3a879c0..b7f74d000cb814c44b9747f180701d3b1d53fd53 100644 (file)
@@ -77,7 +77,6 @@ public class LeeThread extends Thread {
 
   public void run() {
     int [][][] tempg = scratch new int[lt.GRID_SIZE][lt.GRID_SIZE][2]; // Lee 2D Grid copy
-
     while (!finished && !stop) {
       if(sampleNow) {
         //collectMyStatistics();
index 670e5c9fe2557890eca29ff89f7739570593a6c2..45aa60e9fdd3b41537be887779ce8e3ef0144947 100644 (file)
@@ -5,7 +5,7 @@ SRC=${MAINCLASS}.java \
        GridCell.java \
        LeeThread.java \
        WorkQueue.java 
-FLAGS=-mainclass ${MAINCLASS} -joptimize -debug -singleTM -optimize -dcopts -abcclose -transstats -profile
+FLAGS=-mainclass ${MAINCLASS} -joptimize -debug -singleTM -optimize -dcopts -transstats -abcclose -stmdebug
 default:
        ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
 
diff --git a/Robust/src/Benchmarks/SingleTM/MatrixMultiply/MatrixMultiplyN.java b/Robust/src/Benchmarks/SingleTM/MatrixMultiply/MatrixMultiplyN.java
new file mode 100644 (file)
index 0000000..5438be0
--- /dev/null
@@ -0,0 +1,146 @@
+public class MatrixMultiply extends Thread{
+    MMul mmul;
+    public int x0, y0, x1, y1;
+    public MatrixMultiply(MMul mmul, int x0, int x1, int y0, int y1) {
+       this.mmul = mmul;
+       this.x0 = x0;
+       this.y0 = y0;
+       this.x1 = x1;
+       this.y1 = y1;
+    }
+    
+    public void run() {
+       atomic {
+           int M=mmul.M;
+           int l=8;
+           //Use btranspose for cache performance
+           for(int i = x0; i< x1; i++,l++){
+               for (int j = y0; j < y1; j++) {
+                   double innerProduct=0;
+                   for(int k = 0; k < M; k++) {
+                       innerProduct += mmul.a[i][k] *mmul.btranspose[j][k];
+                   }
+                   mmul.c[i][j]=innerProduct;
+               }
+           }
+       }
+    }
+    
+    public static void main(String[] args) {
+       int NUM_THREADS = 4;
+       int SIZE=600;
+       if (args.length>0) {
+           NUM_THREADS=Integer.parseInt(args[0]);
+           if (args.length>1)
+               SIZE=Integer.parseInt(args[1]);
+       }
+       
+       int p, q, r;
+       MatrixMultiply[] mm;
+       MatrixMultiply tmp;
+       MMul matrix;
+       
+       matrix = new MMul(SIZE, SIZE, SIZE);
+       matrix.setValues();
+       matrix.transpose();
+       mm = new MatrixMultiply[NUM_THREADS];
+       int increment=SIZE/NUM_THREADS;
+       int base=0;
+       for(int i=0;i<NUM_THREADS;i++) {
+         if ((i+1)==NUM_THREADS)
+           mm[i]=new MatrixMultiply(matrix,base, SIZE, 0, SIZE);
+         else
+           mm[i]=new MatrixMultiply(matrix,base, base+increment, 0, SIZE);
+         base+=increment;
+       }
+       p = matrix.L;
+       q = matrix.M;
+       r = matrix.N;
+       
+       // print out the matrices to be multiplied
+       System.printString("\n");
+       System.printString("MatrixMultiply: L=");
+       System.printInt(p);
+       System.printString("\t");
+       System.printString("M=");
+       System.printInt(q);
+       System.printString("\t");
+       System.printString("N=");
+       System.printInt(r);
+       System.printString("\n");
+       
+       // start a thread to compute each c[l,n]
+       for (int i = 0; i < NUM_THREADS; i++) {
+           tmp = mm[i];
+           tmp.start();
+       }
+
+       
+       // wait for them to finish
+       for (int i = 0; i < NUM_THREADS; i++) {
+           tmp = mm[i];
+           tmp.join();
+       }
+       
+       // print out the result of the matrix multiply
+
+       System.printString("Finished\n");
+    }
+}
+
+public class MMul{
+
+       public int L, M, N;
+       public double[][] a;
+       public double[][] b;
+       public double[][] c;
+       public double[][] btranspose;
+
+       public MMul(int L, int M, int N) {
+               this.L = L;
+               this.M = M;
+               this.N = N;
+               a = new double[L][M];  
+               b = new double[M][N]; 
+               c = new double[L][N]; 
+               btranspose = new double[N][M];
+       }
+
+       public void setValues() {
+               for(int i = 0; i < L; i++) {
+            double ai[] = a[i];
+                       for(int j = 0; j < M; j++) {
+                               ai[j] = j+1;
+                       }
+               }
+
+               for(int i = 0; i < M; i++) {
+            double bi[] = b[i];
+                       for(int j = 0; j < N; j++) {
+                               bi[j] = j+1;
+                       }
+               }
+
+               for(int i = 0; i < L; i++) {
+            double ci[] = c[i];
+                       for(int j = 0; j < N; j++) {
+                               ci[j] = 0;
+                       }
+               }
+               for(int i = 0; i < N; i++) {
+            double btransposei[] = btranspose[i];
+                       for(int j = 0; j < M; j++) {
+                               btransposei[j] = 0;
+                       }
+               }
+       }
+
+       public void transpose() {
+               for(int row = 0; row < M; row++) {
+            double brow[] = b[row];
+                       for(int col = 0; col < N; col++) {
+                               btranspose[col][row] = brow[col];
+                       }
+               }
+       }
+}
diff --git a/Robust/src/Benchmarks/SingleTM/MatrixMultiply/makefile b/Robust/src/Benchmarks/SingleTM/MatrixMultiply/makefile
new file mode 100644 (file)
index 0000000..d0f4a2f
--- /dev/null
@@ -0,0 +1,9 @@
+MAINCLASS=MatrixMultiply
+SRC1=${MAINCLASS}N.java 
+FLAGS1=-singleTM -nooptimize -mainclass ${MAINCLASS} -joptimize -dcopts -debug
+default:
+       ../../../buildscript ${FLAGS1} -o ${MAINCLASS}RangeN ${SRC1}
+
+clean:
+       rm -rf tmpbuilddirectory
+       rm *.bin