Manual prefetch versions of Array and Chase
authoradash <adash>
Thu, 12 Mar 2009 17:45:11 +0000 (17:45 +0000)
committeradash <adash>
Thu, 12 Mar 2009 17:45:11 +0000 (17:45 +0000)
microbenchmarks

Robust/src/Benchmarks/Prefetch/ManualPrefetch/Array/Array.java [new file with mode: 0644]
Robust/src/Benchmarks/Prefetch/ManualPrefetch/Array/makefile [new file with mode: 0644]
Robust/src/Benchmarks/Prefetch/ManualPrefetch/Chase/Chase.java [new file with mode: 0644]
Robust/src/Benchmarks/Prefetch/ManualPrefetch/Chase/makefile [new file with mode: 0644]

diff --git a/Robust/src/Benchmarks/Prefetch/ManualPrefetch/Array/Array.java b/Robust/src/Benchmarks/Prefetch/ManualPrefetch/Array/Array.java
new file mode 100644 (file)
index 0000000..48badc4
--- /dev/null
@@ -0,0 +1,43 @@
+public class Array extends Thread {
+  int [][] array;
+
+  public Array() {
+    int xmax=10000;
+    int ymax=10;
+    array=global new int[xmax][ymax];
+    for(int i=0;i<xmax;i++) {
+      for(int j=0;j<ymax;j++) {
+        array[i][j]=i*j;
+      }
+    }
+  }
+
+  public static void main(String [] argv) {
+    Array a;
+    atomic {
+      a=global new Array();
+    }
+       a.start((128<<24)|(195<<16)|(136<<8)|162);
+    a.join();
+  }
+
+  public void run() {
+    short[] offsets = new short[4];
+    offsets[0] = getoffset{Array, array};
+    offsets[1] = (short) 0;
+    offsets[2] = (short) 0;
+    offsets[3] = (short) 100;
+    System.rangePrefetch(this, offsets);
+    atomic {
+      int xlength=array.length;
+      int ylength=array[0].length;
+      long sum;
+      for(int i=0;i<xlength;i++) {
+        int a[]=array[i];
+        for(int j=0;j<ylength;j++) {
+          sum+=a[j];
+        }
+      }
+    }
+  }
+}
diff --git a/Robust/src/Benchmarks/Prefetch/ManualPrefetch/Array/makefile b/Robust/src/Benchmarks/Prefetch/ManualPrefetch/Array/makefile
new file mode 100644 (file)
index 0000000..14848e4
--- /dev/null
@@ -0,0 +1,9 @@
+MAINCLASS=Array
+SRC1=${MAINCLASS}.java
+FLAGS=-dsm -rangeprefetch -dsmcaching -optimize -excprefetch Array.Array -mainclass ${MAINCLASS} -trueprob 0.98
+default:
+       ../../../../buildscript ${FLAGS} -o ${MAINCLASS}RangeN ${SRC1}
+
+clean:
+       rm -rf tmpbuilddirectory
+       rm *.bin
diff --git a/Robust/src/Benchmarks/Prefetch/ManualPrefetch/Chase/Chase.java b/Robust/src/Benchmarks/Prefetch/ManualPrefetch/Chase/Chase.java
new file mode 100644 (file)
index 0000000..2f04069
--- /dev/null
@@ -0,0 +1,47 @@
+public class Foo {
+    Foo next;
+    public Foo() {
+      next=null;
+    }
+}
+
+public class Chase extends Thread {
+    Foo base;
+    public Chase(Foo b) {
+       base=b;
+    }
+    
+    public static void main(String [] argv) {
+       Chase c;
+       atomic {
+           Foo fold=global new Foo();
+           
+           for(int i=0;i<10000;i++) {
+               Foo f=global new Foo();
+               f.next=fold;
+               fold=f;
+           }
+           
+           c=global new Chase(fold);
+       }
+       c.start((128<<24)|(195<<16)|(136<<8)|162);
+       c.join();
+    }
+    
+    public void run() {
+      short[] offsets = new short[4];
+      offsets[0] = getoffset{Chase, base};
+      offsets[1] = (short) 0;
+      offsets[2] = getoffset{Foo, next};
+      offsets[3] = (short) 32;
+      System.rangePrefetch(this, offsets);
+      atomic {
+        Foo b=base;
+        int i = 0;
+        while(b!=null) {
+          b=b.next;
+          i++;
+        }
+      }
+    }
+}
diff --git a/Robust/src/Benchmarks/Prefetch/ManualPrefetch/Chase/makefile b/Robust/src/Benchmarks/Prefetch/ManualPrefetch/Chase/makefile
new file mode 100644 (file)
index 0000000..91a67f4
--- /dev/null
@@ -0,0 +1,11 @@
+MAINCLASS=Chase
+SRC1=${MAINCLASS}.java
+FLAGS1=-dsm -rangeprefetch -dsmcaching -optimize -mainclass ${MAINCLASS} -trueprob 0.99
+#for testing no java option
+#FLAGS=-dsm -prefetch -optimize -debug -excprefetch Chase.main -excprefetch Chase.Chase -mainclass ${MAINCLASS} -trueprob 0.99 -nojava
+default:
+       ../../../../buildscript ${FLAGS1} -o ${MAINCLASS}RangeN ${SRC1}
+
+clean:
+       rm -rf tmpbuilddirectory
+       rm *.bin