#include "fusion-phases.h"
module Data.Array.Parallel.PArray.PData.Int () where
import Data.Array.Parallel.PArray.PData.Base
import Data.Typeable as T
import qualified Data.Array.Parallel.Unlifted as U
import qualified Data.Vector as V
import Text.PrettyPrint
import Prelude as P
import Data.Array.Parallel.Pretty
instance PR Int where
validPR _
= True
nfPR (PInt xx)
= xx `seq` ()
similarPR = (==)
coversPR weak (PInt uarr) ix
| weak = ix <= U.length uarr
| otherwise = ix < U.length uarr
pprpPR i
= int i
pprpDataPR (PInt uarr)
= text "PInt" <+> pprp uarr
typeRepPR x = T.typeOf x
typeRepDataPR _ = T.typeOf (5 :: Int)
typeRepDatasPR _ = T.typeOf (5 :: Int)
emptyPR
= PInt U.empty
replicatePR len x
= PInt (U.replicate len x)
replicatesPR segd (PInt arr)
= PInt (U.replicate_s segd arr)
appendPR (PInt arr1) (PInt arr2)
= PInt $ arr1 U.+:+ arr2
appendvsPR segdResult segd1 (PInts arr1) segd2 (PInts arr2)
= PInt $ U.append_vs segdResult segd1 arr1 segd2 arr2
lengthPR (PInt uarr)
= U.length uarr
indexPR (PInt uarr) ix
= U.index "indexPR[Int]" uarr ix
indexsPR (PInts pvecs) srcixs
= PInt $ U.map (\(src, ix) -> U.unsafeIndex2s pvecs src ix) srcixs
indexvsPR (PInts arrs) vsegd srcixs
= PInt $ U.indexs_avs arrs vsegd srcixs
extractPR (PInt arr) start len
= PInt $ U.extract arr start len
extractssPR (PInts arrs) ssegd
= PInt $ U.extracts_ass ssegd arrs
extractvsPR (PInts arrs) vsegd
= PInt $ U.extracts_avs vsegd arrs
packByTagPR (PInt arr1) arrTags tag
= PInt $ U.packByTag arr1 arrTags tag
combine2PR sel (PInt arr1) (PInt arr2)
= PInt $ U.combine2 (U.tagsSel2 sel)
(U.repSel2 sel)
arr1 arr2
fromVectorPR xx
= PInt $U.fromList $ V.toList xx
toVectorPR (PInt arr)
= V.fromList $ U.toList arr
emptydPR
= PInts $ U.emptys
singletondPR (PInt arr)
= PInts $ U.singletons arr
lengthdPR (PInts arrs)
= U.lengths arrs
indexdPR (PInts arrs) ix
= PInt $ arrs `U.unsafeIndexs` ix
appenddPR (PInts xs) (PInts ys)
= PInts $ xs `U.appends` ys
fromVectordPR pdatas
= PInts
$ U.fromVectors
$ V.map (\(PInt vec) -> vec) pdatas
toVectordPR (PInts vec)
= V.map PInt $ U.toVectors vec
deriving instance Show (PData Int)
deriving instance Show (PDatas Int)
instance PprPhysical (U.Array Int) where
pprp uarr
= text (show $ U.toList uarr)
instance PprVirtual (PData Int) where
pprv (PInt vec)
= text (show $ U.toList vec)