[Haskell] Implicit parallel functional programming

Keith Wansbrough Keith.Wansbrough at cl.cam.ac.uk
Thu Jan 20 06:04:02 EST 2005

> First, there is a claim that functional languages facilitate parallel
> execution, which is undeniably true if the implementation is something
> like that of Haskell (no assignment statements mean no memory contention,
> etc.). 

Careful here... no assignments in the source language doesn't
translate to no assignments in the implementation.  For example,
laziness relies fundamentally on mutation: when you begin evaluating a
thunk, the thunk is overwritten with a "black hole" tag; once
evaluation is complete, the thunk is overwritten again with the
resulting value.  If another thread attempts to evaluate the same
thunk, it is added to a queue stored in the black hole, which is woken
when the black hole is overwritten.  (If the same thread attempts to
evaluate the thunk, the RTS prints "<< Loop >>" to warn you of an
infinite loop.)

Notice that, at least in a naive implementation, that blackhole update
must be synchronised across all processors - you don't want to
processors to evaluate the same thunk in parallel by accident because
of a race.

So there certainly is memory contention.  Whether this can be
addressed in some way is a question for those more qualified than I...

--KW 8-)

More information about the Haskell mailing list