--- jsr166/src/test/loops/FJPhaserJacobi.java 2010/09/20 20:42:37 1.8 +++ jsr166/src/test/loops/FJPhaserJacobi.java 2015/09/12 18:37:19 1.13 @@ -1,14 +1,19 @@ -// Barrier version of Jacobi iteration +/* + * 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/ + */ import java.util.concurrent.*; +/** Barrier version of Jacobi iteration */ public class FJPhaserJacobi { static int dimGran; static final double EPSILON = 0.0001; // convergence criterion - public static void main(String[] args) { + public static void main(String[] args) throws Exception { int n = 2048; int steps = 1000; try { @@ -23,7 +28,9 @@ public class FJPhaserJacobi { return; } - ForkJoinPool fjp = new ForkJoinPool(); + // ForkJoinPool fjp = new ForkJoinPool(); + ForkJoinPool fjp = ForkJoinPool.commonPool(); + // int granularity = (n * n / fjp.getParallelism()) / 2; int granularity = n * n / fjp.getParallelism(); dimGran = (int)(Math.sqrt(granularity)); @@ -39,7 +46,7 @@ public class FJPhaserJacobi { for (int j = 1; j < dim-1; ++j) a[i][j] = smallVal; } - int nreps = 3; + int nreps = 10; for (int rep = 0; rep < nreps; ++rep) { // Fill all edges with 1's. for (int k = 0; k < dim; ++k) { @@ -57,9 +64,8 @@ public class FJPhaserJacobi { System.out.println("Compute Time: " + secs); System.out.println(fjp); - + Thread.sleep(1000); } - } static class Segment extends CyclicAction { @@ -137,8 +143,8 @@ public class FJPhaserJacobi { public void compute() { 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; @@ -171,4 +177,3 @@ public class FJPhaserJacobi { } } } -