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 |
|
// Adapted from a cilk benchmark |
47 |
|
return; |
48 |
|
} |
49 |
|
|
50 |
< |
ForkJoinPool g = procs == 0? new ForkJoinPool() : |
50 |
> |
ForkJoinPool g = (procs == 0) ? new ForkJoinPool() : |
51 |
|
new ForkJoinPool(procs); |
52 |
|
|
53 |
|
System.out.print("parallelism = " + g.getParallelism()); |
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
< |
/** Update all cells **/ |
153 |
> |
/** Updates all cells. */ |
154 |
|
final void compstripe(double[][] newMat, double[][] oldMat) { |
155 |
|
|
156 |
|
// manually mangled to reduce array indexing |
184 |
|
nv[b] = cell |
185 |
|
+ dtdysq * (prev - twoc + next) |
186 |
|
+ dtdxsq * (east[b] - twoc + west[b]); |
187 |
– |
|
187 |
|
} |
188 |
|
} |
189 |
|
|
190 |
< |
edges(newMat, llb, lub, tu + time * dt); |
190 |
> |
edges(newMat, llb, lub, tu + time * dt); |
191 |
|
} |
192 |
|
|
193 |
|
|
204 |
|
newMat[a][b] = cell |
205 |
|
+ dtdxsq * (oldMat[a+1][b] - twoc + oldMat[a-1][b]) |
206 |
|
+ dtdysq * (oldMat[a][b+1] - twoc + oldMat[a][b-1]); |
208 |
– |
|
207 |
|
} |
208 |
|
} |
209 |
|
|
211 |
|
} |
212 |
|
|
213 |
|
|
214 |
< |
/** Initialize all cells **/ |
214 |
> |
/** Initializes all cells. */ |
215 |
|
final void init() { |
216 |
|
final int llb = (lb == 0) ? 1 : lb; |
217 |
|
final int lub = (ub == nx) ? nx - 1 : ub; |
218 |
|
|
219 |
< |
for (int a = llb; a < lub; a++) { /* inner nodes */ |
219 |
> |
for (int a = llb; a < lub; a++) { /* inner nodes */ |
220 |
|
double[] ov = oldm[a]; |
221 |
|
double x = xu + a * dx; |
222 |
|
double y = yu; |
227 |
|
} |
228 |
|
|
229 |
|
edges(oldm, llb, lub, 0); |
232 |
– |
|
230 |
|
} |
231 |
|
|
232 |
< |
/** Fill in edges with boundary values **/ |
232 |
> |
/** Fills in edges with boundary values. */ |
233 |
|
final void edges(double [][] m, int llb, int lub, double t) { |
234 |
|
|
235 |
|
for (int a = llb; a < lub; a++) { |