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 |
5 |
– |
*/ |
6 |
– |
|
1 |
|
// Barrier version of Jacobi iteration |
2 |
|
|
3 |
|
import java.util.concurrent.*; |
10 |
– |
//import jsr166y.*; |
4 |
|
|
5 |
|
public class FJPhaserJacobi { |
6 |
|
|
19 |
|
} |
20 |
|
|
21 |
|
catch (Exception e) { |
22 |
< |
System.out.println("Usage: java FJPhaserJacobi <matrix size> <max steps>"); |
22 |
> |
System.out.println("Usage: java ThreadPhaserJacobi <matrix size> <max steps>"); |
23 |
|
return; |
24 |
|
} |
25 |
|
|
26 |
|
ForkJoinPool fjp = new ForkJoinPool(); |
27 |
+ |
// int granularity = (n * n / fjp.getParallelism()) / 2; |
28 |
|
int granularity = n * n / fjp.getParallelism(); |
29 |
|
dimGran = (int)(Math.sqrt(granularity)); |
30 |
|
|
137 |
|
public void compute() { |
138 |
|
int rows = hiRow - loRow + 1; |
139 |
|
int cols = hiCol - loCol + 1; |
140 |
< |
int rblocks = Math.round((float)rows / dimGran); |
141 |
< |
int cblocks = Math.round((float)cols / dimGran); |
140 |
> |
int rblocks = (int)(Math.round((float)rows / dimGran)); |
141 |
> |
int cblocks = (int)(Math.round((float)cols / dimGran)); |
142 |
|
|
143 |
|
int n = rblocks * cblocks; |
144 |
|
|