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

Comparing jsr166/src/test/loops/FJJacobi.java (file contents):
Revision 1.4 by jsr166, Tue Nov 3 01:04:02 2009 UTC vs.
Revision 1.11 by dl, Mon Apr 9 13:18:06 2012 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   // Jacobi iteration on a mesh. Based loosely on a Filaments demo
8  
9   import java.util.concurrent.*;
10 //import jsr166y.*;
10  
11   public class FJJacobi {
12  
13 <    static final int DEFAULT_GRANULARITY = 4096; // 1024;
13 >    //    static final int DEFAULT_GRANULARITY = 4096;
14 >    static final int DEFAULT_GRANULARITY = 256;
15  
16      /**
17       * The maximum number of matrix cells
18       * at which to stop recursing down and instead directly update.
19 <     **/
20 <
19 >     */
20      static final double EPSILON = 0.0001;  // convergence criterion
21  
22      public static void main(String[] args) throws Exception {
# Line 47 | Line 46 | public class FJJacobi {
46          double[][] a = new double[dim][dim];
47          double[][] b = new double[dim][dim];
48          // Initialize interiors to small value
49 <        double smallVal = 1.0/dim;
49 >        double smallVal = EPSILON; // 1.0/dim;
50          for (int i = 1; i < dim-1; ++i) {
51              for (int j = 1; j < dim-1; ++j)
52                  a[i][j] = smallVal;
53          }
54 <
55 <        int nreps = 3;
54 >        // Fill all edges with 1's.
55 >        for (int k = 0; k < dim; ++k) {
56 >            a[k][0] = 1.0;
57 >            a[k][n+1] = 1.0;
58 >            a[0][k] = 1.0;
59 >            a[n+1][k] = 1.0;
60 >            b[k][0] = 1.0;
61 >            b[k][n+1] = 1.0;
62 >            b[0][k] = 1.0;
63 >            b[n+1][k] = 1.0;
64 >        }
65 >        int nreps = 10;
66          for (int rep = 0; rep < nreps; ++rep) {
58            // Fill all edges with 1's.
59            for (int k = 0; k < dim; ++k) {
60                a[k][0] += 1.0;
61                a[k][n+1] += 1.0;
62                a[0][k] += 1.0;
63                a[n+1][k] += 1.0;
64            }
67              Driver driver = new Driver(a, b, 1, n, 1, n, steps, granularity);
68  
69              long startTime = System.currentTimeMillis();
70              fjp.invoke(driver);
71  
72              long time = System.currentTimeMillis() - startTime;
73 <            double secs = (double) time / 1000.0;
73 >            double secs = ((double)time) / 1000.0;
74  
75              System.out.println("Compute Time: " + secs);
74            System.out.println("Workers: " + fjp.getPoolSize());
76              System.out.println(fjp);
77          }
78      }
# Line 88 | Line 89 | public class FJJacobi {
89              if (tryUnfork())
90                  compute();
91              else {
92 <                //                quietlyJoin();
92 <                quietlyHelpJoin();
92 >                quietlyJoin();
93                  reinitialize();
94              }
95              double m = maxDiff;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines