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

Comparing jsr166/src/test/loops/BoxedLongSort.java (file contents):
Revision 1.7 by dl, Mon Apr 9 13:18:06 2012 UTC vs.
Revision 1.12 by jsr166, Mon Aug 10 03:13:33 2015 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 import java.util.concurrent.*;
7   import java.util.*;
8 + import java.util.concurrent.*;
9  
10   class BoxedLongSort {
11      static final long NPS = (1000L * 1000 * 1000);
# Line 68 | Line 68 | class BoxedLongSort {
68              long now = System.nanoTime();
69              double total = (double)(now - start) / NPS;
70              double elapsed = (double)(now - last) / NPS;
71 <            System.out.printf("Arrays.sort   time:  %7.3f total %9.3f\n",
71 >            System.out.printf("Arrays.sort   time:  %7.3f total %9.3f\n",
72                                elapsed, total);
73              if (i == 0)
74                  checkSorted(a);
# Line 90 | Line 90 | class BoxedLongSort {
90              //            pool.invoke(new TaskChecker());
91              double total = (double)(now - start) / NPS;
92              double elapsed = (double)(now - last) / NPS;
93 <            System.out.printf("Parallel sort time:  %7.3f total %9.3f\n",
93 >            System.out.printf("Parallel sort time:  %7.3f total %9.3f\n",
94                                elapsed, total);
95              if (i == 0)
96                  checkSorted(a);
# Line 165 | Line 165 | class BoxedLongSort {
165           * and finding index of right closest to split point.
166           * Uses left-spine decomposition to generate all
167           * merge tasks before bottomming out at base case.
168         *
168           */
169          public final void compute() {
170              Merger rights = null;
# Line 202 | Line 201 | class BoxedLongSort {
201                      Long al = a[l], ar;
202                      if (r >= rFence ||
203                          al.longValue() <= (ar = a[r]).longValue()) {
204 <                        ++l; t = al;
205 <                    }
206 <                    else {
207 <                        ++r; t = ar;
204 >                        ++l; t = al;
205 >                    }
206 >                    else {
207 >                        ++r; t = ar;
208                      }
209                  }
210                  else if (r < rFence)
211                      t = a[r++];
212 <                else
212 >                else
213                      break;
214                  w[k++] = t;
215              }
# Line 218 | Line 217 | class BoxedLongSort {
217              //            merge(nleft, nright);
218              if (rights != null)
219                  collectRights(rights);
221
220          }
221  
222          final void merge(int nleft, int nright) {
# Line 290 | Line 288 | class BoxedLongSort {
288          }
289      }
290  
293
291      static final class RandomRepacker extends RecursiveAction {
292          final Long[] src;
293          final Long[] dst;
294          final int lo, hi, size;
295 <        RandomRepacker(Long[] src, Long[] dst,
295 >        RandomRepacker(Long[] src, Long[] dst,
296                         int lo, int hi, int size) {
297              this.src = src; this.dst = dst;
298              this.lo = lo; this.hi = hi; this.size = size;
299          }
300 <        
300 >
301          public final void compute() {
302              Long[] s = src;
303              Long[] d = dst;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines