From: bdemsky Date: Fri, 2 May 2008 19:45:05 +0000 (+0000) Subject: new makefile and rewritten benchmark X-Git-Tag: preEdgeChange~120 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8ba9a072444a0d62ea2b89e03e5f029a09c57039;p=IRC.git new makefile and rewritten benchmark --- diff --git a/Robust/src/Benchmarks/Prefetch/MatrixMultiply/MatrixMultiplyN.java b/Robust/src/Benchmarks/Prefetch/MatrixMultiply/MatrixMultiplyN.java new file mode 100644 index 00000000..1a5aa110 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/MatrixMultiply/MatrixMultiplyN.java @@ -0,0 +1,159 @@ +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 { + //Use btranspose for cache performance + for(int i = x0; i<= x1; i++){ + double a[]=mmul.a[i]; + double c[]=mmul.c[i]; + int M=mmul.M; + for (int j = y0; j <= y1; j++) { + double innerProduct=0; + double b[] = mmul.btranspose[j]; + for(int k = 0; k < M; k++) { + innerProduct += a[k] *b[k]; + } + c[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[] mid = new int[NUM_THREADS]; + mid[0] = (128<<24)|(195<<16)|(175<<8)|80; + mid[1] = (128<<24)|(195<<16)|(175<<8)|73; + mid[2] = (128<<24)|(195<<16)|(175<<8)|78; + mid[3] = (128<<24)|(195<<16)|(175<<8)|79; + int p, q, r; + MatrixMultiply[] mm; + MatrixMultiply tmp; + MMul matrix; + + atomic { + matrix = global new MMul(SIZE, SIZE, SIZE); + matrix.setValues(); + matrix.transpose(); + mm = global new MatrixMultiply[NUM_THREADS]; + int increment=SIZE/NUM_THREADS; + int base=0; + for(int i=0;i