<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Please post the full code somewhere. The second one really should
scale better, and I want to understand in context how you're
parallelizing this.<br>
<br>
On 3/6/2011 11:34 AM, Russel Winder wrote:
<blockquote cite="mid:1299429248.3068.124.camel@anglides"
type="cite">
<pre wrap="">On Thu, 2011-03-03 at 09:40 -0500, David Simcha wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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))
);
</pre>
</blockquote>
<pre wrap="">
(The above is a slight oversimplification of the situation I have
but . . . )
Sadly this doesn't seem to work. I tried:
immutable pi = 4.0 * taskPool.reduce ! ( "a + b" ) ( 0.0 , taskPool.map ! ( partialSum ) ( inputData ) ) * delta ;
and this works fine showing good scaling. However:
immutable pi = 4.0 * taskPool.reduce ! ( "a + b" ) ( 0.0 , map ! ( partialSum ) ( inputData ) ) * delta ;
forces serialization so no speed up.
</pre>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
phobos mailing list
<a class="moz-txt-link-abbreviated" href="mailto:phobos@puremagic.com">phobos@puremagic.com</a>
<a class="moz-txt-link-freetext" href="http://lists.puremagic.com/mailman/listinfo/phobos">http://lists.puremagic.com/mailman/listinfo/phobos</a></pre>
</blockquote>
<br>
</body>
</html>