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 |
43 |
|
System.out.println(usage); |
44 |
|
return; |
45 |
|
} |
46 |
< |
ForkJoinPool pool = procs == 0? new ForkJoinPool() : |
46 |
> |
ForkJoinPool pool = (procs == 0) ? new ForkJoinPool() : |
47 |
|
new ForkJoinPool(procs); |
48 |
|
System.out.println("procs: " + pool.getParallelism() + |
49 |
|
" n: " + n + " runs: " + runs); |
72 |
|
pool.shutdown(); |
73 |
|
} |
74 |
|
|
77 |
– |
|
75 |
|
static void randomInit(double[][] M, int n) { |
76 |
|
java.util.Random rng = new java.util.Random(); |
77 |
|
for (int i = 0; i < n; ++i) |
102 |
|
System.out.println("Max difference = " + maxDiff); |
103 |
|
} |
104 |
|
|
108 |
– |
|
105 |
|
// Blocks record underlying matrix, and offsets into current block |
106 |
|
static final class Block { |
107 |
|
final double[][] m; |
214 |
|
Block L10 = new Block(L.m, L.loRow+h, L.loCol); |
215 |
|
Block L11 = new Block(L.m, L.loRow+h, L.loCol+h); |
216 |
|
|
221 |
– |
|
217 |
|
Seq3 s1 = |
218 |
|
seq(new Lower(h, L00, M00), |
219 |
|
new Schur(h, L10, M00, M10), |
229 |
|
} |
230 |
|
} |
231 |
|
|
237 |
– |
|
232 |
|
static final class Upper extends RecursiveAction { |
233 |
|
final int size; |
234 |
|
final Block U; |
252 |
|
} |
253 |
|
} |
254 |
|
|
261 |
– |
|
255 |
|
public void compute() { |
256 |
|
if (size == BLOCK_SIZE) { |
257 |
|
upper(); |
284 |
|
} |
285 |
|
} |
286 |
|
|
294 |
– |
|
287 |
|
static final class LowerUpper extends RecursiveAction { |
288 |
|
final int size; |
289 |
|
final Block M; |
371 |
|
thr.invoke(); |
372 |
|
} |
373 |
|
} |
382 |
– |
|
383 |
– |
|
384 |
– |
|
374 |
|
} |
386 |
– |
|