module Data.Array.Parallel.Unlifted.Distributed.Basics
(eqD, neqD, toD, fromD)
where
import Data.Array.Parallel.Unlifted.Distributed.Primitive
import Data.Array.Parallel.Unlifted.Distributed.Combinators
import Data.Array.Parallel.Unlifted.Distributed.Data.Bool
import Data.Array.Parallel.Unlifted.Distributed.Data.Scalar
import Control.Monad ( zipWithM_ )
here :: String -> String
here s = "Data.Array.Parallel.Unlifted.Distributed.Basics." ++ s
eqD :: (Eq a, DT a) => Gang -> Dist a -> Dist a -> Bool
eqD g dx dy
= andD g (zipWithD (What "eq") g (==) dx dy)
neqD :: (Eq a, DT a) => Gang -> Dist a -> Dist a -> Bool
neqD g dx dy
= orD g (zipWithD (What "neq") g (/=) dx dy)
toD :: DT a => Gang -> [a] -> Dist a
toD g xs
= newD g (\md -> zipWithM_ (writeMD md) [0 .. gangSize g 1] xs)
fromD :: DT a => Gang -> Dist a -> [a]
fromD g dt
= checkGangD (here "fromDT") g dt
$ map (indexD (here "fromD") dt)
[0 .. gangSize g 1]