On Apr 19, 2008, at 11:50 , Andrew Coppin wrote:
Bulat Ziganshin wrote:
there are plenty of reasons: first, -threaded make i/o overlapped
with calculations.
Not with -N1.
Depending on how it's implemented (I not being a ghc guru), possibly
even with -N1 as long as it's using the thread-capable runtime.
(Note that "make -j2" is known to be optimal on single-processor
machines, specifically because I/O tends to overlap with CPU.)
second, parallel version may exhibit better cpu
cache behavior - such as processing all data in cache before sending
it back to memory
Again, with -N1, it is *still* only using 1 CPU core.
And again, this may well be an effect of using the thread-*capable*
runtime. You can't generally multiplex memory accesses in SMP, so
you may well want to delay and batch operations to/from main memory
as much as possible to reduce lock contention for memory access.
Well, based on the results I've seen so far, it seems that
parallelism is a complete waste of time because it doesn't gain you
anything. And that doesn't make a lot of sense...
Easy parallelism is still an unsolved problem; naive parallelism
generally is no better than sequential and often worse, because naive
parallelism generally fails to account for lock / resource
contention. (Note that resource locking will be done by the threaded
runtime even with only one thread, so you will see some slowdowns
especially in I/O-related code.) Haskell can only help you so much
with this; you need to design your algorithms to parallel properly.
In addition, laziness can result in naive parallelism being a no-op
because the only thing parallelized is some operation that trivially
returns a lazy thunk that is later forced in the main thread.
Careful strictness analysis is necessary in non-strict languages to
make sure you are actually parallelizing what you want to.
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university KF8NH
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe