--- jsr166/src/test/loops/ThreadPhaserJacobi.java 2009/10/29 23:09:08 1.2 +++ jsr166/src/test/loops/ThreadPhaserJacobi.java 2015/01/15 18:34:19 1.9 @@ -1,3 +1,9 @@ +/* + * Written by Doug Lea with assistance from members of JCP JSR-166 + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + // Barrier version of Jacobi iteration import java.util.*; @@ -11,8 +17,7 @@ public class ThreadPhaserJacobi { /** * The maximum submatrix length (both row-wise and column-wise) * for any Segment - **/ - + */ static final double EPSILON = 0.0001; // convergence criterion static int dimGran; @@ -33,7 +38,7 @@ public class ThreadPhaserJacobi { } int granularity = n * n / nprocs; - dimGran = (int)(Math.sqrt(granularity)); + dimGran = (int) Math.sqrt(granularity); // allocate enough space for edges int dim = n+2; @@ -61,7 +66,7 @@ public class ThreadPhaserJacobi { driver.compute(); long time = System.currentTimeMillis() - startTime; - double secs = ((double)time) / 1000.0; + double secs = (double) time / 1000.0; System.out.println("Compute Time: " + secs); } @@ -94,7 +99,6 @@ public class ThreadPhaserJacobi { barrier.register(); } - public void run() { try { double[][] a = A; @@ -107,7 +111,7 @@ public class ThreadPhaserJacobi { double[][] tmp = a; a = b; b = tmp; } } - catch(Exception ex) { + catch (Exception ex) { ex.printStackTrace(); return; } @@ -133,7 +137,6 @@ public class ThreadPhaserJacobi { } - static class Driver { double[][] A; // matrix to get old values from double[][] B; // matrix to put new values into @@ -157,8 +160,8 @@ public class ThreadPhaserJacobi { int rows = hiRow - loRow + 1; int cols = hiCol - loCol + 1; - int rblocks = (int)(Math.round((float)rows / dimGran)); - int cblocks = (int)(Math.round((float)cols / dimGran)); + int rblocks = Math.round((float) rows / dimGran); + int cblocks = Math.round((float) cols / dimGran); int n = rblocks * cblocks; @@ -201,6 +204,4 @@ public class ThreadPhaserJacobi { System.out.println("Max diff after " + steps + " steps = " + maxd); } } - - }