module Data.Array.Repa.Repr.HintInterleave
(I, Array (..), hintInterleave)
where
import Data.Array.Repa.Eval.Load
import Data.Array.Repa.Eval.Target
import Data.Array.Repa.Eval.Interleaved
import Data.Array.Repa.Repr.Delayed
import Data.Array.Repa.Shape
import Data.Array.Repa.Base
import Debug.Trace
data I r1
instance Source r1 a => Source (I r1) a where
data Array (I r1) sh a
= AInterleave !(Array r1 sh a)
extent (AInterleave arr)
= extent arr
index (AInterleave arr) ix
= index arr ix
unsafeIndex (AInterleave arr) ix
= unsafeIndex arr ix
linearIndex (AInterleave arr) ix
= linearIndex arr ix
unsafeLinearIndex (AInterleave arr) ix
= unsafeLinearIndex arr ix
deepSeqArray (AInterleave arr) x
= deepSeqArray arr x
deriving instance Show (Array r1 sh e)
=> Show (Array (I r1) sh e)
deriving instance Read (Array r1 sh e)
=> Read (Array (I r1) sh e)
hintInterleave :: Array r1 sh e -> Array (I r1) sh e
hintInterleave = AInterleave
instance (Shape sh, Load D sh e)
=> Load (I D) sh e where
loadP (AInterleave (ADelayed sh getElem)) marr
= marr `deepSeqMVec`
do traceEventIO "Repa.loadP[Interleaved]: start"
fillInterleavedP (size sh) (unsafeWriteMVec marr) (getElem . fromIndex sh)
touchMVec marr
traceEventIO "Repa.loadP[Interleaved]: end"
loadS (AInterleave arr) marr
= loadS arr marr