--- jsr166/src/test/loops/FJPhaserJacobi.java 2009/11/03 01:04:02 1.6 +++ jsr166/src/test/loops/FJPhaserJacobi.java 2015/08/10 03:13:33 1.12 @@ -1,14 +1,12 @@ /* * 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/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ -// Barrier version of Jacobi iteration - import java.util.concurrent.*; -//import jsr166y.*; +/** Barrier version of Jacobi iteration */ public class FJPhaserJacobi { static int dimGran; @@ -26,13 +24,14 @@ public class FJPhaserJacobi { } catch (Exception e) { - System.out.println("Usage: java FJPhaserJacobi "); + System.out.println("Usage: java ThreadPhaserJacobi "); return; } ForkJoinPool fjp = new ForkJoinPool(); + // int granularity = (n * n / fjp.getParallelism()) / 2; int granularity = n * n / fjp.getParallelism(); - dimGran = (int) Math.sqrt(granularity); + dimGran = (int)(Math.sqrt(granularity)); // allocate enough space for edges int dim = n+2; @@ -59,13 +58,11 @@ public class FJPhaserJacobi { fjp.invoke(driver); long time = System.currentTimeMillis() - startTime; - double secs = (double) time / 1000.0; + double secs = ((double)time) / 1000.0; System.out.println("Compute Time: " + secs); System.out.println(fjp); - } - } static class Segment extends CyclicAction { @@ -143,8 +140,8 @@ public class FJPhaserJacobi { public void compute() { int rows = hiRow - loRow + 1; int cols = hiCol - loCol + 1; - int rblocks = Math.round((float) rows / dimGran); - int cblocks = Math.round((float) cols / dimGran); + int rblocks = Math.round((float)rows / dimGran); + int cblocks = Math.round((float)cols / dimGran); int n = rblocks * cblocks;