Simple parallel foreach and summation/reduction

Chris Katko ckatko at gmail.com
Mon Sep 24 07:26:10 UTC 2018


On Monday, 24 September 2018 at 07:13:24 UTC, Chris Katko wrote:
> On Monday, 24 September 2018 at 05:59:20 UTC, Chris Katko wrote:
>>         [...]
>
>
> Actually, I just realized/remembered that the error occurs 
> inside parallelism itself, and MANY times at that:
>
> [...]

This JUST occurred to me. When I use an outer taskPool.[a]map, am 
I NOT supposed to use the taskPool version of reduce?! But 
instead, the std.algorithm one?

Because this is running with both/all cores, and only using 2.7MB 
of RAM:

	sum = taskPool.reduce!(test)(
	map!(monte)(range)   //map, not taskPool.map
	);		

If that's the correct case, the docs did NOT make that obvious!

FYI, I went from ~5200 samples / mSec, to 7490 samples / mSec. 
36% difference for second "real" core. Better than nothing, I 
guess. I'll have to try it on my main machine with a proper CPU.


More information about the Digitalmars-d-learn mailing list