Hi Matthias,
At 2:26 pm 18/3/98, Haskell List Moderator wrote:
>After this long introduction my question:
>Suppose a polymorphic closure is evaluated in parallel by another
>processing element. If the resulting type is a type which uses a
>vectored return, the remote processor needs to know this type in
>order to send a result back or store it for later demands from other
>processors. The trick from the sequential STGM does not work, since
>there is no return-frame on the remote processor.
Firstly note that the semantics of
par a e
is to spark a and return b. That is, nothing can actually demand the
result of the
child process (though the closure it evaluates may be shared, with essentially
the same effect!).
Polymorphic par is a bit of a pain (which has had different solutions at
different
points in time, including not being allowed!), and I'm not sure I remember
all the details of the current implementation. Note, however, that if you're
returning a value that doesn't update a closure (i.e. a polymorphic par
that isn't used) you can safely discard it. The par is transformed into
something like
par (case a of _ -> ()) e
The discarding happens as a consquence of stack underflow on the
new stack that is created for the thread evaluating the case.
Vectored returns must be capable of dealing with stack underflow
(you can create a generic return vector that will deal with all
possible vectored cases, setting all returns to "StgUnderflow", and push
this onto the bottom of the thread stack).
If 'a' happens to be shared, then there will be an update frame
for 'a' somewhere that will ensure the update is carried out
correctly. There's no need to pass registers around!
A neater solution might be to overload par, but this would have a
rather unpleasant consequence on the source program (lots of new
overloading)!
Simon may remember the details, and confirm that this is a correct
description. I suppose this should have been written up somewhere,
but it seemed like a fairly minor technical point at the time!
Regards,
Kevin
----------
Division of Computer Science, Tel: +44-1334 463241 (Direct)
School of Mathematical Fax: +44-1334 463278
and Computational Sciences, URL:
http://www.dcs.st-and.ac.uk/~kh/kh.html
University of St. Andrews, Fife, KY16 9SS.