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 |
– |
// Barrier version of Jacobi iteration |
8 |
– |
|
7 |
|
import java.util.concurrent.*; |
10 |
– |
//import jsr166y.*; |
8 |
|
|
9 |
+ |
/** Barrier version of Jacobi iteration */ |
10 |
|
public class FJPhaserJacobi { |
11 |
|
|
12 |
|
static int dimGran; |
24 |
|
} |
25 |
|
|
26 |
|
catch (Exception e) { |
27 |
< |
System.out.println("Usage: java FJPhaserJacobi <matrix size> <max steps>"); |
27 |
> |
System.out.println("Usage: java ThreadPhaserJacobi <matrix size> <max steps>"); |
28 |
|
return; |
29 |
|
} |
30 |
|
|
31 |
|
ForkJoinPool fjp = new ForkJoinPool(); |
32 |
+ |
// int granularity = (n * n / fjp.getParallelism()) / 2; |
33 |
|
int granularity = n * n / fjp.getParallelism(); |
34 |
< |
dimGran = (int) Math.sqrt(granularity); |
34 |
> |
dimGran = (int)(Math.sqrt(granularity)); |
35 |
|
|
36 |
|
// allocate enough space for edges |
37 |
|
int dim = n+2; |
58 |
|
fjp.invoke(driver); |
59 |
|
|
60 |
|
long time = System.currentTimeMillis() - startTime; |
61 |
< |
double secs = (double) time / 1000.0; |
61 |
> |
double secs = ((double)time) / 1000.0; |
62 |
|
|
63 |
|
System.out.println("Compute Time: " + secs); |
64 |
|
System.out.println(fjp); |
66 |
– |
|
65 |
|
} |
68 |
– |
|
66 |
|
} |
67 |
|
|
68 |
|
static class Segment extends CyclicAction { |
140 |
|
public void compute() { |
141 |
|
int rows = hiRow - loRow + 1; |
142 |
|
int cols = hiCol - loCol + 1; |
143 |
< |
int rblocks = Math.round((float) rows / dimGran); |
144 |
< |
int cblocks = Math.round((float) cols / dimGran); |
143 |
> |
int rblocks = Math.round((float)rows / dimGran); |
144 |
> |
int cblocks = Math.round((float)cols / dimGran); |
145 |
|
|
146 |
|
int n = rblocks * cblocks; |
147 |
|
|