ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/Heat.java
(Generate patch)

Comparing jsr166/src/test/loops/Heat.java (file contents):
Revision 1.5 by jsr166, Mon Nov 29 20:58:06 2010 UTC vs.
Revision 1.9 by jsr166, Sat Sep 12 19:09:00 2015 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   // Adapted from a cilk benchmark
# Line 95 | Line 95 | public class Heat {
95      static final double dtdxsq = dt / (dx * dx);
96      static final double dtdysq = dt / (dy * dy);
97  
98 <
99 <    // the function being applied across the cells
98 >    /** the function being applied across the cells */
99      static final double f(double x, double y) {
100          return Math.sin(x) * Math.sin(y);
101      }
# Line 119 | Line 118 | public class Heat {
118          return Math.exp(-2*t) * Math.sin(x) * Math.sin(y);
119      }
120  
122
123
124
121      static final class Compute extends RecursiveAction {
122          final int lb;
123          final int ub;
# Line 149 | Line 145 | public class Heat {
145                  compstripe(oldm, newm);
146          }
147  
152
148          /** Updates all cells. */
149          final void compstripe(double[][] newMat, double[][] oldMat) {
150  
# Line 184 | Line 179 | public class Heat {
179                      nv[b] = cell
180                          + dtdysq * (prev    - twoc + next)
181                          + dtdxsq * (east[b] - twoc + west[b]);
187
182                  }
183              }
184  
185 <            edges(newMat, llb, lub,  tu + time * dt);
185 >            edges(newMat, llb, lub, tu + time * dt);
186          }
187  
188 <
195 <        // the original version from cilk
188 >        /** the original version from cilk */
189          final void origcompstripe(double[][] newMat, double[][] oldMat) {
190  
191              final int llb = (lb == 0)  ? 1 : lb;
# Line 205 | Line 198 | public class Heat {
198                      newMat[a][b] = cell
199                          + dtdxsq * (oldMat[a+1][b] - twoc + oldMat[a-1][b])
200                          + dtdysq * (oldMat[a][b+1] - twoc + oldMat[a][b-1]);
208
201                  }
202              }
203  
204              edges(newMat, llb, lub,  tu + time * dt);
205          }
206  
215
207          /** Initializes all cells. */
208          final void init() {
209              final int llb = (lb == 0) ? 1 : lb;
# Line 229 | Line 220 | public class Heat {
220              }
221  
222              edges(oldm, llb, lub, 0);
232
223          }
224  
225          /** Fills in edges with boundary values. */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines