From 77d23ae84df526af75d2ff95ebc631457118d65a Mon Sep 17 00:00:00 2001 From: adash Date: Fri, 25 Sep 2009 08:43:43 +0000 Subject: [PATCH] new javasingle version --- .../javasingle/MatrixMultiplyD.java | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 Robust/src/Benchmarks/Prefetch/MatrixMultiply/javasingle/MatrixMultiplyD.java diff --git a/Robust/src/Benchmarks/Prefetch/MatrixMultiply/javasingle/MatrixMultiplyD.java b/Robust/src/Benchmarks/Prefetch/MatrixMultiply/javasingle/MatrixMultiplyD.java new file mode 100644 index 00000000..84bd597a --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/MatrixMultiply/javasingle/MatrixMultiplyD.java @@ -0,0 +1,138 @@ +public class MatrixMultiply extends Thread{ + MMul mmul; + public int x0, y0, x1, y1; + public int tid, numthreads; + + public MatrixMultiply(MMul mmul, int x0, int x1, int y0, int y1, int tid, int numthreads) { + this.mmul = mmul; + this.x0 = x0; + this.y0 = y0; + this.x1 = x1; + this.y1 = y1; + this.tid=tid; + this.numthreads=numthreads; + } + + public void run() { + mmul.setValues(tid, numthreads); + + + double la[][][]=mmul.a; + double lc[][][]=mmul.c; + double lb[][][]=mmul.btranspose; + int M=mmul.M; + int P=mmul.P; + //Use btranspose for cache performance + for(int q=0;q0) { + NUM_THREADS=Integer.parseInt(args[0]); + if (args.length>1) { + SIZE=Integer.parseInt(args[1]); + if (args.length>2) + NUM_MATRIX=Integer.parseInt(args[2]); + } + } + + int p, q, r; + MatrixMultiply[] mm; + MatrixMultiply tmp; + MMul matrix; + + matrix = new MMul(NUM_MATRIX, SIZE, SIZE, SIZE); + mm = new MatrixMultiply[NUM_THREADS]; + int increment=SIZE/NUM_THREADS; + int base=0; + for(int i=0;i0||numthreads==1) { + int delta=numthreads>1?numthreads-1:1; + int start=numthreads>1?tid-1:0; + + for(int q = start; q < P; q+=delta) { + for(int i = 0; i < N; i++) { + double bi[] = new double[M]; + for(int j = 0; j < M; j++) { + bi[j] = j+1; + } + btranspose[q][i]=bi; + } + } + } + } +} -- 2.34.1