Forgot to mention, though:  The more idiomatic/shorter way to write something like this would be to perform a reduction on a (non-parallel, lazy, random access) std.parallelism.Map.  The map function will be evaluated in parallel naturally, as the parallel reduction is performed.  Maybe this should be an example in the docs for reduce.  In your pi example:

// Nested function inside main().
double calculateTerm(int i) {
    immutable x = (i - 0.5) * delta ;
    return 1.0 / (1.0 + x * x);
}

immutable sum = taskPool.reduce!"a + b"(
    std.algorithm.map!calculateTerm(iota(n))
);



On 3/3/2011 8:58 AM, David Simcha wrote:
Unfortunately I already played around with this, and it seems it absolutely requires double precision, or else it blows up numerically.  I want to avoid double precision in my benchmarks so that stack alignment artifacts will not creep in.

On 3/3/2011 4:30 AM, Russel Winder wrote:
On Sat, 2011-02-26 at 14:54 -0500, David Simcha wrote:
BTW, is it ok if I include your pi calculating benchmark in the
benchmarks folder, too?  (I may modify it to make it slightly more
idiomatic.)
No problem.

It would be interesting to see what changes you make: idiomatic is
always good :-) 
_______________________________________________ phobos mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/phobos


_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to