I may be talking out of my other end here, but... if you want something like parMap to calculate all the pixels in parallel, then... can't you use parMap itself?

   Something like:

weirdParMap action = sequence_ . map action . parMap (id $!)

This evaluates all the elements of the list using parMap (the expensive part, right?), and then sequentially applies the action on the current thread.

JCAB

On Sun, 15 Apr 2007 12:56:02 -0700, Mitar <[EMAIL PROTECTED]> wrote:

Hi!

On 4/15/07, Spencer Janssen <[EMAIL PROTECTED]> wrote:
This version will fork a new thread for each action:

\begin{code}
import Control.Concurrent
import Control.Monad

parSequence_ xs = do
    m <- newEmptyMVar
    mapM_ (\x -> forkIO x >> putMVar m ()) xs
    replicateM_ (length xs) (takeMVar m)

parMapM_ f xs = parSequence_ $ map f xs
\end{code}

OpenGL bindings successfully crash. The functional calculations in f
should be done in parallel, but those few OpenGL actions should still
be done sequentially. I am attaching the code in question. It is a
simple voxel raycasting engine.

(Any suggestions on other memory/performance improvements are more
than welcome.)


Mitar


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to