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 |
|
} |
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(); |
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); |
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); |