new 3d version
authorbdemsky <bdemsky>
Fri, 13 Mar 2009 03:47:18 +0000 (03:47 +0000)
committerbdemsky <bdemsky>
Fri, 13 Mar 2009 03:47:18 +0000 (03:47 +0000)
Robust/src/Benchmarks/Prefetch/ManualPrefetch/Array/Array.java

index fe8861814c73c9d62e3026b78f96a44c48f66f2c..7dfeff59b3d243071a34bdb8d2dd551d8e17d091 100644 (file)
@@ -1,14 +1,17 @@
 public class Array extends Thread {
-  int [][] array;
+  int [][][] array;
 
   public Array() {
-    int xmax=10000;
-    int ymax=10;
-    array=global new int[xmax][ymax];
+    int xmax=100;
+    int ymax=4000;
+    int zmax=10;
+    array=global new int[xmax][ymax][zmax];
     for(int i=0;i<xmax;i++) {
-      for(int j=0;j<ymax;j++) {
-        array[i][j]=i*j;
-      }
+       for(int j=0;j<ymax;j++) {
+           for(int k=0;k<zmax;k++) {
+               array[i][j][k]=i*j+k;
+           }
+       }
     }
   }
 
@@ -22,26 +25,27 @@ public class Array extends Thread {
   }
 
   public void run() {
-    short[] offsets = new short[4];
+    short[] offsets = new short[6];
     offsets[0] = getoffset{Array, array};
     offsets[1] = (short) 0;
     offsets[2] = (short) 0;
-    offsets[3] = (short) 4000;
-    System.rangePrefetch(this, offsets);
-    offsets[2] = (short) 4001;
-    offsets[3] = (short) 4000;
-    System.rangePrefetch(this, offsets);
-    offsets[2] = (short) 8002;
-    offsets[3] = (short) 1997;
+    offsets[3] = (short) 100;
+    offsets[4] = (short) 0;
+    offsets[5] = (short) 4000;
     System.rangePrefetch(this, offsets);
+
     atomic {
       int xlength=array.length;
       int ylength=array[0].length;
+      int zlength=array[0][0].length;
       long sum;
       for(int i=0;i<xlength;i++) {
-        int a[]=array[i];
+        int a[][]=array[i];
         for(int j=0;j<ylength;j++) {
-          sum+=a[j];
+           int a2[]=a[j];
+           for(int k=0;k<zlength;k++) {
+               sum+=a2[k];
+           }
         }
       }
     }