ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/FJPhaserJacobi.java
(Generate patch)

Comparing jsr166/src/test/loops/FJPhaserJacobi.java (file contents):
Revision 1.6 by jsr166, Tue Nov 3 01:04:02 2009 UTC vs.
Revision 1.13 by dl, Sat Sep 12 18:37:19 2015 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 // Barrier version of Jacobi iteration
8
7   import java.util.concurrent.*;
10 //import jsr166y.*;
8  
9 + /** Barrier version of Jacobi iteration */
10   public class FJPhaserJacobi {
11  
12      static int dimGran;
13  
14      static final double EPSILON = 0.0001;  // convergence criterion
15  
16 <    public static void main(String[] args) {
16 >    public static void main(String[] args) throws Exception {
17          int n = 2048;
18          int steps = 1000;
19          try {
# Line 26 | Line 24 | public class FJPhaserJacobi {
24          }
25  
26          catch (Exception e) {
27 <            System.out.println("Usage: java FJPhaserJacobi <matrix size> <max steps>");
27 >            System.out.println("Usage: java ThreadPhaserJacobi <matrix size> <max steps>");
28              return;
29          }
30  
31 <        ForkJoinPool fjp = new ForkJoinPool();
31 >        //        ForkJoinPool fjp = new ForkJoinPool();
32 >        ForkJoinPool fjp = ForkJoinPool.commonPool();
33 >
34 >        //        int granularity = (n * n / fjp.getParallelism()) / 2;
35          int granularity = n * n / fjp.getParallelism();
36 <        dimGran = (int) Math.sqrt(granularity);
36 >        dimGran = (int)(Math.sqrt(granularity));
37  
38          // allocate enough space for edges
39          int dim = n+2;
# Line 45 | Line 46 | public class FJPhaserJacobi {
46              for (int j = 1; j < dim-1; ++j)
47                  a[i][j] = smallVal;
48          }
49 <        int nreps = 3;
49 >        int nreps = 10;
50          for (int rep = 0; rep < nreps; ++rep) {
51              // Fill all edges with 1's.
52              for (int k = 0; k < dim; ++k) {
# Line 59 | Line 60 | public class FJPhaserJacobi {
60              fjp.invoke(driver);
61  
62              long time = System.currentTimeMillis() - startTime;
63 <            double secs = (double) time / 1000.0;
63 >            double secs = ((double)time) / 1000.0;
64  
65              System.out.println("Compute Time: " + secs);
66              System.out.println(fjp);
67 <
67 >            Thread.sleep(1000);
68          }
68
69      }
70  
71      static class Segment extends CyclicAction {
# Line 143 | Line 143 | public class FJPhaserJacobi {
143          public void compute() {
144              int rows = hiRow - loRow + 1;
145              int cols = hiCol - loCol + 1;
146 <            int rblocks = Math.round((float) rows / dimGran);
147 <            int cblocks = Math.round((float) cols / dimGran);
146 >            int rblocks = Math.round((float)rows / dimGran);
147 >            int cblocks = Math.round((float)cols / dimGran);
148  
149              int n = rblocks * cblocks;
150  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines