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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines