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

Comparing jsr166/src/test/loops/LU.java (file contents):
Revision 1.2 by jsr166, Mon Sep 20 20:42:37 2010 UTC vs.
Revision 1.9 by dl, Sat Sep 12 18:59:08 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   //import jsr166y.*;
8   import java.util.concurrent.*;
9 import java.util.concurrent.TimeUnit;
10
9  
10   /**
11   * LU matrix decomposition demo
12   * Based on those in Cilk and Hood
13 < **/
16 <
13 > */
14   public final class LU {
15  
16      /** for time conversion */
# Line 29 | Line 26 | public final class LU {
26  
27          int procs = 0;
28          int n = 2048;
29 <        int runs = 5;
29 >        int runs = 32;
30          try {
31              if (args.length > 0)
32                  procs = Integer.parseInt(args[0]);
# Line 46 | Line 43 | public final class LU {
43              System.out.println(usage);
44              return;
45          }
46 <        ForkJoinPool pool = procs == 0? new ForkJoinPool() :
46 >        ForkJoinPool pool = (procs == 0) ? ForkJoinPool.commonPool() :
47              new ForkJoinPool(procs);
48          System.out.println("procs: " + pool.getParallelism() +
49                             " n: " + n + " runs: " + runs);
# Line 67 | Line 64 | public final class LU {
64              pool.invoke(new LowerUpper(n, M));
65              long time = System.nanoTime() - start;
66              double secs = ((double)time) / NPS;
67 <            System.out.printf("\tTime: %7.3f\n", secs);
67 >            System.out.printf("Time: %7.3f ", secs);
68 >            if ((run & 3) == 3) System.out.println();
69  
70              if (CHECK) check(m, copy, n);
71          }
# Line 75 | Line 73 | public final class LU {
73          pool.shutdown();
74      }
75  
78
76      static void randomInit(double[][] M, int n) {
77          java.util.Random rng = new java.util.Random();
78          for (int i = 0; i < n; ++i)
# Line 106 | Line 103 | public final class LU {
103          System.out.println("Max difference = " + maxDiff);
104      }
105  
109
106      // Blocks record underlying matrix, and offsets into current block
107      static final class Block {
108          final double[][] m;
# Line 219 | Line 215 | public final class LU {
215                  Block L10 = new Block(L.m, L.loRow+h, L.loCol);
216                  Block L11 = new Block(L.m, L.loRow+h, L.loCol+h);
217  
222
218                  Seq3 s1 =
219                      seq(new Lower(h, L00, M00),
220                          new Schur(h, L10, M00, M10),
# Line 235 | Line 230 | public final class LU {
230          }
231      }
232  
238
233      static final class Upper extends RecursiveAction {
234          final int size;
235          final Block U;
# Line 259 | Line 253 | public final class LU {
253              }
254          }
255  
262
256          public void compute() {
257              if (size == BLOCK_SIZE) {
258                  upper();
# Line 292 | Line 285 | public final class LU {
285          }
286      }
287  
295
288      static final class LowerUpper extends RecursiveAction {
289          final int size;
290          final Block M;
# Line 380 | Line 372 | public final class LU {
372              thr.invoke();
373          }
374      }
383
384
385
375   }
387

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines