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

Comparing jsr166/src/test/extra166y/LongMapReduceDemo.java (file contents):
Revision 1.2 by jsr166, Mon Nov 16 04:16:43 2009 UTC vs.
Revision 1.3 by dl, Thu Nov 25 12:38:35 2010 UTC

# Line 35 | Line 35 | public class LongMapReduceDemo {
35              x ^= x << 13;
36              x ^= x >>> 7;
37              x ^= (x << 17);
38 +            x ^= x << 13;
39 +            x ^= x >>> 7;
40 +            x ^= (x << 17);
41 +            x ^= x << 13;
42 +            x ^= x >>> 7;
43 +            x ^= (x << 17);
44 +            x ^= x << 13;
45 +            x ^= x >>> 7;
46 +            x ^= (x << 17);
47              return x;
48          }
49      }
# Line 50 | Line 59 | public class LongMapReduceDemo {
59  
60      public static void main(String[] args) throws Exception {
61          int n = 1 << 18;
62 <        int reps = 1 << 8;
62 >        int reps = 1 << 10;
63          long[] array = new long[n];
64          for (int i = 0; i < n; ++i)
65              array[i] = i + 1L;
66 <        ForkJoinPool fjp = new ForkJoinPool(1);
66 >        ForkJoinPool fjp = new ForkJoinPool();
67          ParallelLongArray pa = ParallelLongArray.createUsingHandoff(array, fjp);
68          final GetNext getNext = new GetNext();
69          final Accum accum = new Accum();
# Line 76 | Line 85 | public class LongMapReduceDemo {
85              elapsed = (double)(now - last) / NPS;
86              last = now;
87              System.out.printf("sequential:    %7.3f\n", elapsed);
88 <            for (int i = 2; i <= NCPU; i <<= 1) {
88 >            for (int i = NCPU; i >= 1; i >>>= 1) {
89                  resetSeeds(array, rseed);
90                  long sum = 0;
82                fjp.setParallelism(i);
91                  last = System.nanoTime();
92                  for (int k = 0; k < reps; ++k) {
93                      sum += pa.withMapping(getNext).reduce(accum, zero);
# Line 93 | Line 101 | public class LongMapReduceDemo {
101                  System.out.printf("poolSize %3d:  %7.3f\n", fjp.getParallelism(), elapsed);
102                  if (sum != seqsum) throw new Error("checksum");
103              }
104 <            for (int i = NCPU; i >= 1; i >>>= 1) {
104 >            for (int i = 2; i <= NCPU; i <<= 1) {
105                  resetSeeds(array, rseed);
106                  long sum = 0;
107 <                fjp.setParallelism(i);
107 >                //                fjp.setParallelism(i);
108                  last = System.nanoTime();
109                  for (int k = 0; k < reps; ++k) {
110                      sum += pa.withMapping(getNext).reduce(accum, zero);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines