Commit 045415a1 authored by chak@cse.unsw.edu.au.'s avatar chak@cse.unsw.edu.au.
Browse files

Start using the VECTORISE pragma

- Moved most of GHC.PArr (except [::] def and some primitives)
  to Data.Array.Parallel in dph-common
- Data.Array.Parallel uses the new VECTORISE pragma
- Gutted Data.Array.Parallel.Prelude.Base.PArr; should be removed
parent 9b201194
This diff is collapsed.
......@@ -2,10 +2,24 @@ module Data.Array.Parallel.Lifted (
module Data.Array.Parallel.Lifted.PArray,
module Data.Array.Parallel.Lifted.Instances,
(:->), ($:), ($:^)
(:->), ($:), ($:^),
fromPArrayPA, toPArrayPA, fromNestedPArrayPA,
) where
import Data.Array.Parallel.Lifted.PArray
import Data.Array.Parallel.Lifted.Closure
import Data.Array.Parallel.Lifted.Instances
fromPArrayPA :: PA a => PArray a :-> PArray a
{-# INLINE fromPArrayPA #-}
fromPArrayPA = closure1 (\x -> x) (\xs -> xs)
toPArrayPA :: PA a => PArray a :-> PArray a
{-# INLINE toPArrayPA #-}
toPArrayPA = closure1 (\x -> x) (\xs -> xs)
fromNestedPArrayPA :: PA a => (PArray (PArray a) :-> PArray (PArray a))
{-# INLINE fromNestedPArrayPA #-}
fromNestedPArrayPA = closure1 (\xs -> xs) (\xss -> xss)
module Data.Array.Parallel.Prelude (
module Data.Array.Parallel.Prelude.Base.PArr
module Data.Array.Parallel
, module Data.Array.Parallel.Prelude.Bool
......@@ -8,10 +8,10 @@ module Data.Array.Parallel.Prelude (
, nestUSegdPA'
) where
import Data.Array.Parallel.Prelude.Bool
import Data.Array.Parallel hiding (sumP, productP, maximumP, minimumP, enumFromToP,
enumFromThenToP)
import Data.Array.Parallel.Prelude.Base.PArr
import Data.Array.Parallel.Prelude.Base.Int
import Data.Array.Parallel.Prelude.Bool
import Data.Array.Parallel.Lifted.PArray
import Data.Array.Parallel.Lifted.Closure
......
module Data.Array.Parallel.Prelude.Base (
-- module Data.Array.Parallel.Prelude.Base.Int
--, module Data.Array.Parallel.Prelude.Base.Double
--,
module Data.Array.Parallel.Prelude.Base.PArr
, module Data.Array.Parallel.Lifted
-- module Data.Array.Parallel.Prelude.Base.PArr
-- , module Data.Array.Parallel.Lifted
) where
import Data.Array.Parallel.Prelude.Base.Int
import Data.Array.Parallel.Prelude.Base.Word8
import Data.Array.Parallel.Prelude.Base.Float
import Data.Array.Parallel.Prelude.Base.Double
import Data.Array.Parallel.Prelude.Base.Bool
import Data.Array.Parallel.Prelude.Base.Tuple
import Data.Array.Parallel.Prelude.Base.PArr
import Data.Array.Parallel.Lifted
-- import Data.Array.Parallel.Prelude.Base.PArr
-- import Data.Array.Parallel.Lifted
......@@ -35,7 +35,7 @@ module Data.Array.Parallel.Prelude.Base.Double (
truncateV, roundV, ceilingV, floorV
) where
import Data.Array.Parallel.Prelude.Base.PArr
import qualified Data.Array.Parallel as PArr
import Data.Array.Parallel.Lifted.Combinators
import Data.Array.Parallel.Lifted.Instances
......@@ -45,7 +45,6 @@ import Data.Array.Parallel.Lifted.PArray
import Prelude (Double, Int, Bool)
import qualified Prelude as P
import qualified GHC.PArr
infixr 8 **
infixl 7 *, /
......@@ -91,8 +90,8 @@ minimumPA = closure1 (scalar_fold1 P.min) (scalar_fold1s P.min)
maximumPA = closure1 (scalar_fold1 P.max) (scalar_fold1s P.max)
minimumP, maximumP :: [:Double:] -> Double
minimumP = GHC.PArr.minimumP
maximumP = GHC.PArr.maximumP
minimumP = PArr.minimumP
maximumP = PArr.maximumP
minIndexPA :: PArray Double :-> Int
{-# INLINE minIndexPA #-}
......@@ -146,8 +145,8 @@ sumPA = closure1 (scalar_fold (+) 0) (scalar_folds (+) 0)
productPA = closure1 (scalar_fold (*) 1) (scalar_folds (*) 1)
sumP, productP :: [:Double:] -> Double
sumP = GHC.PArr.sumP
productP = GHC.PArr.productP
sumP = PArr.sumP
productP = PArr.productP
(/) :: Double -> Double -> Double
(/) = (P./)
......
......@@ -35,7 +35,7 @@ module Data.Array.Parallel.Prelude.Base.Float (
truncateV, roundV, ceilingV, floorV
) where
import Data.Array.Parallel.Prelude.Base.PArr
import qualified Data.Array.Parallel as PArr
import Data.Array.Parallel.Lifted.Combinators
import Data.Array.Parallel.Lifted.Instances
......@@ -45,7 +45,6 @@ import Data.Array.Parallel.Lifted.PArray
import Prelude (Float, Int, Bool)
import qualified Prelude as P
import qualified GHC.PArr
infixr 8 **
infixl 7 *, /
......@@ -91,8 +90,8 @@ minimumPA = closure1 (scalar_fold1 P.min) (scalar_fold1s P.min)
maximumPA = closure1 (scalar_fold1 P.max) (scalar_fold1s P.max)
minimumP, maximumP :: [:Float:] -> Float
minimumP = GHC.PArr.minimumP
maximumP = GHC.PArr.maximumP
minimumP = PArr.minimumP
maximumP = PArr.maximumP
minIndexPA :: PArray Float :-> Int
{-# INLINE minIndexPA #-}
......@@ -146,8 +145,8 @@ sumPA = closure1 (scalar_fold (+) 0) (scalar_folds (+) 0)
productPA = closure1 (scalar_fold (*) 1) (scalar_folds (*) 1)
sumP, productP :: [:Float:] -> Float
sumP = GHC.PArr.sumP
productP = GHC.PArr.productP
sumP = PArr.sumP
productP = PArr.productP
(/) :: Float -> Float -> Float
(/) = (P./)
......
......@@ -21,17 +21,14 @@ module Data.Array.Parallel.Prelude.Base.Int (
enumFromToPA, enumFromToP
) where
import Data.Array.Parallel.Prelude.Base.PArr
import qualified Data.Array.Parallel as PArr
import Data.Array.Parallel.Lifted.Combinators
import Data.Array.Parallel.Lifted.Instances
import Data.Array.Parallel.Lifted.Scalar
import Data.Array.Parallel.Lifted.Closure
import Data.Array.Parallel.Lifted.PArray
import Prelude (Int, Bool)
import qualified Prelude as P
import qualified GHC.PArr
infixl 7 *
infixl 6 +, -
......@@ -77,8 +74,8 @@ minimumPA = closure1 (scalar_fold1 P.min) (scalar_fold1s P.min)
maximumPA = closure1 (scalar_fold1 P.max) (scalar_fold1s P.max)
minimumP, maximumP :: [:Int:] -> Int
minimumP = GHC.PArr.minimumP
maximumP = GHC.PArr.maximumP
minimumP = PArr.minimumP
maximumP = PArr.maximumP
minIndexPA :: PArray Int :-> Int
{-# INLINE minIndexPA #-}
......@@ -133,8 +130,8 @@ sumPA = closure1 (scalar_fold (+) 0) (scalar_folds (+) 0)
productPA = closure1 (scalar_fold (*) 1) (scalar_folds (*) 1)
sumP, productP :: [:Int:] -> Int
sumP = GHC.PArr.sumP
productP = GHC.PArr.productP
sumP = PArr.sumP
productP = PArr.productP
divV, modV :: Int :-> Int :-> Int
......@@ -160,5 +157,5 @@ enumFromToPA = enumFromToPA_Int
enumFromToP :: Int -> Int -> [:Int:]
{-# NOINLINE enumFromToP #-}
enumFromToP n m = [:n..m:]
-- enumFromToP n m = [:n..m:]
enumFromToP n m = PArr.enumFromToP n m
{-# LANGUAGE ParallelArrays #-}
module Data.Array.Parallel.Prelude.Base.PArr (
singletonP,
(!:), sliceP,
emptyP,
lengthP,
(+:+), concatP,
mapP, filterP,
zipWithP, zipP, unzipP,
replicateP,
combineP,
updateP,
bpermuteP,
indexedP,
fromPArrayP, fromPArrayPA,
toPArrayP, toPArrayPA,
fromNestedPArrayP, fromNestedPArrayPA
-- FIXME: REMOVE THIS MODULE: clients should better imported these from Data.Array.Parallel
module Data.Array.Parallel
) where
import GHC.PArr hiding ( bpermuteP )
import Data.Array.Parallel.Lifted
import Data.Array.Parallel.Lifted.Closure
fromPArrayP :: PArray a -> [:a:]
{-# NOINLINE fromPArrayP #-}
fromPArrayP _
= singletonP (error "dph-common uses of fromPArrayP must be vectorised")
fromPArrayPA :: PA a => PArray a :-> PArray a
{-# INLINE fromPArrayPA #-}
fromPArrayPA = closure1 (\x -> x) (\xs -> xs)
toPArrayP :: [:a:] -> PArray a
{-# NOINLINE toPArrayP #-}
toPArrayP _
= error "dph-common: uses of toPArrayP must be vectorised"
toPArrayPA :: PA a => PArray a :-> PArray a
{-# INLINE toPArrayPA #-}
toPArrayPA = closure1 (\x -> x) (\xs -> xs)
fromNestedPArrayP :: PArray (PArray a) -> [:[:a:]:]
{-# NOINLINE fromNestedPArrayP #-}
fromNestedPArrayP _
= singletonP (error "dph-common: uses of fromNestedPArrayP must be vectorised")
fromNestedPArrayPA :: PA a => (PArray (PArray a) :-> PArray (PArray a))
{-# INLINE fromNestedPArrayPA #-}
fromNestedPArrayPA = closure1 (\xs -> xs) (\xss -> xss)
combineP:: [:a:] -> [:a:] -> [:Int:] -> [:a:]
combineP xs _ _ = xs
updateP :: [:a:] -> [:(Int,a):] -> [:a:]
updateP xs _ = xs
bpermuteP :: [:a:] -> [:Int:] -> [:a:]
bpermuteP xs _ = xs
indexedP :: [:a:] -> [:(Int,a):]
{-# NOINLINE indexedP #-}
indexedP xs = zipP [:0 .. lengthP xs-1:] xs
import Data.Array.Parallel
......@@ -2,7 +2,6 @@ module Data.Array.Parallel.Prelude.Base.Tuple (
tup2, tup3
) where
import Data.Array.Parallel.Lifted.Combinators
import Data.Array.Parallel.Lifted.Repr
import Data.Array.Parallel.Lifted.Closure
import Data.Array.Parallel.Lifted.PArray
......
......@@ -21,7 +21,7 @@ module Data.Array.Parallel.Prelude.Base.Word8 (
toIntV, fromIntV
) where
import Data.Array.Parallel.Prelude.Base.PArr
import qualified Data.Array.Parallel as PArr
import Data.Array.Parallel.Lifted.Combinators
import Data.Array.Parallel.Lifted.Instances
......@@ -32,7 +32,6 @@ import Data.Array.Parallel.Lifted.PArray
import Prelude (Int, Bool)
import Data.Word (Word8)
import qualified Prelude as P
import qualified GHC.PArr
infixl 7 *
infixl 6 +, -
......@@ -78,8 +77,8 @@ minimumPA = closure1 (scalar_fold1 P.min) (scalar_fold1s P.min)
maximumPA = closure1 (scalar_fold1 P.max) (scalar_fold1s P.max)
minimumP, maximumP :: [:Word8:] -> Word8
minimumP = GHC.PArr.minimumP
maximumP = GHC.PArr.maximumP
minimumP = PArr.minimumP
maximumP = PArr.maximumP
minIndexPA :: PArray Word8 :-> Int
{-# INLINE minIndexPA #-}
......@@ -133,8 +132,8 @@ sumPA = closure1 (scalar_fold (+) 0) (scalar_folds (+) 0)
productPA = closure1 (scalar_fold (*) 1) (scalar_folds (*) 1)
sumP, productP :: [:Word8:] -> Word8
sumP = GHC.PArr.sumP
productP = GHC.PArr.productP
sumP = PArr.sumP
productP = PArr.productP
divV, modV :: Word8 :-> Word8 :-> Word8
{-# INLINE divV #-}
......
......@@ -5,10 +5,10 @@ module Data.Array.Parallel.Prelude.Bool (
otherwise, (&&), (||), not, andP, orP
) where
import Data.Array.Parallel.Prelude.Base
-- import Data.Array.Parallel.Prelude.Base
import Data.Array.Parallel.Prelude.Base.Bool
import qualified Prelude as P
-- import qualified Prelude as P
import Prelude (Bool(..), (&&), (||), not)
otherwise :: Bool
......
......@@ -8,6 +8,6 @@ module Data.Array.Parallel.Prelude.Int (
) where
import Data.Array.Parallel.Prelude.Base.Int
import qualified Data.Array.Parallel.Prelude.Base
-- import qualified Data.Array.Parallel.Prelude.Base
import Prelude (Int)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment