17 |
|
/** |
18 |
|
* Sequential version, for performance comparison |
19 |
|
*/ |
20 |
< |
static long seqMapReduce(long[] array, |
20 |
> |
static long seqMapReduce(long[] array, |
21 |
|
LongOp mapper, |
22 |
|
LongReducer reducer, |
23 |
|
long base) { |
24 |
|
long n = array.length; |
25 |
|
long x = base; |
26 |
< |
for (int i = 0; i < n; ++i) |
26 |
> |
for (int i = 0; i < n; ++i) |
27 |
|
x = reducer.op(x, mapper.op(array[i])); |
28 |
|
return x; |
29 |
|
} |
32 |
|
static final class GetNext implements LongOp { |
33 |
|
public long op(long seed) { |
34 |
|
long x = seed; |
35 |
< |
x ^= x << 13; |
36 |
< |
x ^= x >>> 7; |
35 |
> |
x ^= x << 13; |
36 |
> |
x ^= x >>> 7; |
37 |
|
x ^= (x << 17); |
38 |
|
return x; |
39 |
|
} |
52 |
|
int n = 1 << 18; |
53 |
|
int reps = 1 << 8; |
54 |
|
long[] array = new long[n]; |
55 |
< |
for (int i = 0; i < n; ++i) |
55 |
> |
for (int i = 0; i < n; ++i) |
56 |
|
array[i] = i + 1L; |
57 |
|
ForkJoinPool fjp = new ForkJoinPool(1); |
58 |
|
ParallelLongArray pa = ParallelLongArray.createUsingHandoff(array, fjp); |
120 |
|
for (int i = 0; i < array.length; ++i) |
121 |
|
array[i] = s++; |
122 |
|
} |
123 |
< |
|
123 |
> |
|
124 |
|
} |