[concurrency-interest] help show speed-up on a trivial but manual array-map operation?

Doug Lea dl at cs.oswego.edu
Fri Mar 9 08:11:02 EST 2012

On 03/08/12 21:40, Dan Grossman wrote:
> Hi all,
> Short version:
> Any help on why the attached program (also pasted at the bottom) runs
> the sequential version faster than the parallel version?  Apologies if
> I've missed something obvious.

Nothing that I'd call "obvious" but...

1. Microbenchmarking artifacts: The results of the
computations are never used so JVMs can kill some of the
code. The attached edited version includes a "checkSum" method
that combats this.

2. The 200K array size is relatively small compared to timing
precision so shows a big variance even on seq runs. Try 1 million.

3. The sequential loop form of adding elements along
constant-stride locations is heavily optimized on modern hardware.
Try different functions besides adding that disrupt some of the
point-wise hardware optimization. The attached version
includes a few choices. Even with above 2 changes, the
speedups for plain add are small, but those for sum
of squares or magnitudes are substantial. Having students play
around with  different choices might be instructive.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: VecAdd.java
Type: text/x-java
Size: 3949 bytes
Desc: not available
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120309/f8e8298b/attachment.bin>

More information about the Concurrency-interest mailing list