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.1 by dl, Sun Sep 19 12:55:37 2010 UTC vs.
Revision 1.7 by jsr166, Wed Dec 31 16:44:01 2014 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;
9  
10  
11   /**
12   * LU matrix decomposition demo
13   * Based on those in Cilk and Hood
14 < **/
16 <
14 > */
15   public final class LU {
16  
17      /** for time conversion */
18      static final long NPS = (1000L * 1000 * 1000);
19  
20      // granularity is hard-wired as compile-time constant here
21 <    static final int BLOCK_SIZE = 16;
21 >    static final int BLOCK_SIZE = 16;
22      static final boolean CHECK = false; // set true to check answer
23  
24      public static void main(String[] args) throws Exception {
# Line 35 | Line 33 | public final class LU {
33                  procs = Integer.parseInt(args[0]);
34              if (args.length > 1)
35                  n = Integer.parseInt(args[1]);
36 <            if (args.length > 2)
36 >            if (args.length > 2)
37                  runs = Integer.parseInt(args[2]);
38          } catch (Exception e) {
39              System.out.println(usage);
# Line 46 | Line 44 | public final class LU {
44              System.out.println(usage);
45              return;
46          }
47 <        ForkJoinPool pool = procs == 0? new ForkJoinPool() :
47 >        ForkJoinPool pool = (procs == 0) ? new ForkJoinPool() :
48              new ForkJoinPool(procs);
49 <        System.out.println("procs: " + pool.getParallelism() +
49 >        System.out.println("procs: " + pool.getParallelism() +
50                             " n: " + n + " runs: " + runs);
51          for (int run = 0; run < runs; ++run) {
52              double[][] m = new double[n][n];
# Line 161 | Line 159 | public final class LU {
159                  Block W01 = new Block(W.m, W.loRow,   W.loCol+h);
160                  Block W10 = new Block(W.m, W.loRow+h, W.loCol);
161                  Block W11 = new Block(W.m, W.loRow+h, W.loCol+h);
162 <        
162 >
163                  Seq2 s3 = seq(new Schur(h, V10, W01, M11),
164                                new Schur(h, V11, W11, M11));
165                  s3.fork();
# Line 219 | Line 217 | public final class LU {
217                  Block L10 = new Block(L.m, L.loRow+h, L.loCol);
218                  Block L11 = new Block(L.m, L.loRow+h, L.loCol+h);
219  
220 <                
221 <                Seq3 s1 =
220 >
221 >                Seq3 s1 =
222                      seq(new Lower(h, L00, M00),
223                          new Schur(h, L10, M00, M10),
224                          new Lower(h, L11, M10));
225 <                Seq3 s2 =
225 >                Seq3 s2 =
226                      seq(new Lower(h, L00, M01),
227                          new Schur(h, L10, M01, M11),
228                          new Lower(h, L11, M11));
# Line 277 | Line 275 | public final class LU {
275                  Block U10 = new Block(U.m, U.loRow+h, U.loCol);
276                  Block U11 = new Block(U.m, U.loRow+h, U.loCol+h);
277  
278 <                Seq3 s1 =
278 >                Seq3 s1 =
279                      seq(new Upper(h, U00, M00),
280                          new Schur(h, M00, U01, M01),
281                          new Upper(h, U11, M01));
282 <                Seq3 s2 =
282 >                Seq3 s2 =
283                      seq(new Upper(h, U00, M10),
284                          new Schur(h, M10, U01, M11),
285                          new Upper(h, U11, M11));
# Line 291 | Line 289 | public final class LU {
289              }
290          }
291      }
292 <    
292 >
293  
294      static final class LowerUpper extends RecursiveAction {
295          final int size;
# Line 339 | Line 337 | public final class LU {
337          }
338      }
339  
340 <    static Seq2 seq(RecursiveAction task1,
341 <                               RecursiveAction task2) {
342 <        return new Seq2(task1, task2);
340 >    static Seq2 seq(RecursiveAction task1,
341 >                               RecursiveAction task2) {
342 >        return new Seq2(task1, task2);
343      }
344  
345      static final class Seq2 extends RecursiveAction {
# Line 357 | Line 355 | public final class LU {
355          }
356      }
357  
358 <    static Seq3 seq(RecursiveAction task1,
358 >    static Seq3 seq(RecursiveAction task1,
359                      RecursiveAction task2,
360 <                    RecursiveAction task3) {
361 <        return new Seq3(task1, task2, task3);
360 >                    RecursiveAction task3) {
361 >        return new Seq3(task1, task2, task3);
362      }
363  
364      static final class Seq3 extends RecursiveAction {
365          final RecursiveAction fst;
366          final RecursiveAction snd;
367          final RecursiveAction thr;
368 <        public Seq3(RecursiveAction task1,
368 >        public Seq3(RecursiveAction task1,
369                      RecursiveAction task2,
370                      RecursiveAction task3) {
371              fst = task1;
# Line 380 | Line 378 | public final class LU {
378              thr.invoke();
379          }
380      }
383
384
385
381   }
387  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines