[Haskell-cafe] Re: Parallel Pi

Daniel Fischer daniel.is.fischer at web.de
Sun Mar 21 10:45:52 EDT 2010

-----Ursprüngliche Nachricht-----
Von: Simon Marlow <marlowsd at gmail.com>
Gesendet: 19.03.2010 09:24:12
An: Daniel Fischer <daniel.is.fischer at web.de>
Betreff: Re: Parallel Pi

>On 18/03/10 22:52, Daniel Fischer wrote:
>> Am Donnerstag 18 März 2010 22:44:55 schrieb Simon Marlow:
>>> On 17/03/10 21:30, Daniel Fischer wrote:
>>> It works for me (GHC 6.12.1):
>>>     SPARKS: 1 (1 converted, 0 pruned)
>>>     INIT  time    0.00s  (  0.00s elapsed)
>>>     MUT   time    9.05s  (  4.54s elapsed)
>>>     GC    time    0.12s  (  0.09s elapsed)
>>>     EXIT  time    0.00s  (  0.01s elapsed)
>>>     Total time    9.12s  (  4.63s elapsed)
>>> wall-clock speedup of 1.93 on 2 cores.
>> Is that Artyom's original code or with the pseq'ed length?
>Your fixed version.

Good. So I can at least continue to believe I have a rough idea of how GHC behaves.

>> And, with -N2, I also have a productivity of 193.5%, but the elapsed time
>> is larger than the elapsed time for -N1. How long does it take with -N1 for
>> you?
>The 1.93 speedup was compared to the time for -N1 (8.98s in my case).
>>> What hardware are you using there?
>> 3.06GHz Pentium 4, 2 cores.
>> I have mixed results with parallelism, some programmes get a speed-up of
>> nearly a factor 2 (wall-clock time), others 1.4, 1.5 or so, yet others take
>> about the same wall-clock time as the single threaded programme, some -
>> like this - take longer despite using both cores intensively.
>I suspect it's something specific to that processor, probably 
>cache-related.  Perhaps we've managed to put some data frequently 
>accessed by both CPUs on the same cache line.  I'd have to do some 
>detailed profiling on that processor to find out though.  If you're have 
>the time and inclination, install oprofile and look for things like 
>"memory ordering stalls".

It seems that I've just been fooled by /proc/cpuinfo listing it as two and having something like 190% cpu usage in top/time.
Being oblivious of almost everything hardware-related, I naively took it at face value.
In fact it's probably just one hyperthreaded CPU, so since the two threads here do exactly the same type of work, it's natural then that it doesn't give a speed-up.

>>> Have you tried changing any GC settings?
>> I've played around a little with -qg and -qb and -C, but that showed little
>> influence. Any tips what else might be worth a try?
>-A would be the other thing to try.
>	Simon
>>> Cheers,
>>> 	Simon

More information about the Haskell-Cafe mailing list