module EdenExt where import Control.Parallel.Eden import Control.Parallel.Eden.EdenSkel.Auxiliary --for unshuffle (define it here to get rid of dependency) import Control.Monad spawnMX :: (Trans a, Trans b) => [[Process a b]] -> [[a]] -> [[b]] spawnMX pss xss = runPA $ sequence $ zipWith3 (\is ps xs -> sequence (zipWith3 instantiateAt is ps xs)) iss pss xss where iss = (unshuffle (length (zip pss xss)) [selfPe+1..]) fetchMX :: Trans a => [[RD a]] -> [[a]] fetchMX rda = runPA $ mapM (mapM fetchPA) rda fetch4 :: (Trans a, Trans b, Trans c, Trans d) => (RD a,RD b,RD c,RD d) -> (a,b,c,d) fetch4 (a,b,c,d) = runPA $ do a' <- fetchPA a b' <- fetchPA b c' <- fetchPA c d' <- fetchPA d return (a',b',c',d') -- this can be implemented directly using release, we use releasePA only because of the similarity to fetch4 release5 :: (Trans a, Trans b, Trans c, Trans d, Trans e) =>(a,b,c,d,e) -> (RD a,RD b,RD c,RD d,RD e) release5 (a,b,c,d,e) = runPA $ do a' <- releasePA a b' <- releasePA b c' <- releasePA c d' <- releasePA d e' <- releasePA e return (a',b',c',d',e')