-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Common utilities and config for Data Parallel Haskell -- -- Common utilities and config for Data Parallel Haskell @package dph-base @version 0.5.1.1 -- | When tracePrimEnabled in Data.Array.Parallel.Config is -- True, DPH programs will print out what array primitives -- they're using at runtime. See tracePrim for details. module Data.Array.Parallel.Base.TracePrim -- | Print tracing information to console. -- -- This function is used to wrap the calls to DPH primitives defined in -- dph-prim-par:Data.Array.Parallel.Unlifted -- -- Tracing is only enabled when tracePrimEnabled in -- Data.Array.Parallel.Base.Config is True, otherwise it's -- a no-op. tracePrim :: TracePrim -> a -> a -- | Records information about the use of a primitive operator. -- -- These are the operator names that the vectoriser introduces. The -- actual implementation of each operator varies depending on what DPH -- backend we're using. We only trace operators that are at least O(n) in -- complexity. data TracePrim TraceReplicate :: Int -> TracePrim traceCount :: TracePrim -> Int TraceRepeat :: Int -> Int -> TracePrim traceCount :: TracePrim -> Int traceSrcLength :: TracePrim -> Int TraceIndex :: Int -> Int -> TracePrim traceIndex :: TracePrim -> Int traceSrcLength :: TracePrim -> Int TraceExtract :: Int -> Int -> Int -> TracePrim traceStart :: TracePrim -> Int traceSliceLength :: TracePrim -> Int traceSrcLength :: TracePrim -> Int TraceDrop :: Int -> Int -> TracePrim traceCount :: TracePrim -> Int traceSrcLength :: TracePrim -> Int TracePermute :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceBPermuteDft :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceBPermute :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceMBPermute :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceUpdate :: Int -> Int -> TracePrim traceSrcLength :: TracePrim -> Int traceModLength :: TracePrim -> Int TraceAppend :: Int -> TracePrim traceDstLength :: TracePrim -> Int TraceInterleave :: Int -> TracePrim traceDstLength :: TracePrim -> Int TracePack :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceCombine :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceCombine2 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceMap :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceFilter :: Int -> Int -> TracePrim traceSrcLength :: TracePrim -> Int traceDstLength :: TracePrim -> Int TraceZipWith :: Int -> Int -> TracePrim traceSrc1Length :: TracePrim -> Int traceSrc2Length :: TracePrim -> Int TraceFold :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceFold1 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceAnd :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceSum :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceScan :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceIndexed :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceEnumFromTo :: Int -> TracePrim traceDstLength :: TracePrim -> Int TraceEnumFromThenTo :: Int -> TracePrim traceDstLength :: TracePrim -> Int TraceEnumFromStepLen :: Int -> TracePrim traceDstLength :: TracePrim -> Int TraceEnumFromStepLenEach :: Int -> TracePrim traceDstLength :: TracePrim -> Int TraceMkSel2 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceTagsSel2 :: Int -> TracePrim traceDstLength :: TracePrim -> Int TraceIndicesSel2 :: Int -> TracePrim traceDstLength :: TracePrim -> Int TraceElementsSel2_0 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceElementsSel2_1 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceMkSelRep2 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceIndicesSelRep2 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceElementsSelRep2_0 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceElementsSelRep2_1 :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceReplicate_s :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceReplicate_rs :: Int -> Int -> TracePrim traceCount :: TracePrim -> Int traceSrcLength :: TracePrim -> Int TraceAppend_s :: Int -> TracePrim traceDstLength :: TracePrim -> Int TraceFold_s :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceFold1_s :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceFold_r :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceSum_r :: Int -> TracePrim traceSrcLength :: TracePrim -> Int TraceIndices_s :: Int -> TracePrim traceDstLength :: TracePrim -> Int instance Show TracePrim -- | Harness for DTrace. module Data.Array.Parallel.Base.DTrace traceLoopEntry :: String -> a -> a traceLoopExit :: String -> a -> a traceLoopST :: String -> ST s a -> ST s a traceLoopEntryST :: String -> ST s () traceLoopExitST :: String -> ST s () traceLoopIO :: String -> IO a -> IO a traceLoopEntryIO :: String -> IO () traceLoopExitIO :: String -> IO () traceFn :: String -> String -> a -> a traceArg :: Show a => String -> a -> b -> b traceF :: String -> a -> a -- | Basic functionality, imported by most modules. module Data.Array.Parallel.Base -- | Bounds check, enabled when debug = True. -- -- The first integer is the length of the array, and the second is the -- index. The second must be greater or equal to '0' and less than the -- first integer. If the not then error with the String. check :: String -> Int -> Int -> a -> a -- | Bounds check, enabled when debugCritical = True. -- -- This version is used to check operations that could corrupt the heap. -- -- The first integer is the length of the array, and the second is the -- index. The second must be greater or equal to '0' and less than the -- first integer. If the not then error with the String. checkCritical :: String -> Int -> Int -> a -> a -- | Length check, enabled when debug = True. -- -- Check that the second integer is greater or equal to `0' and less or -- equal than the first integer. If the not then error with the -- String. checkLen :: String -> Int -> Int -> a -> a -- | Equality check, enabled when debug = True. -- -- The two a values must be equal, else error. -- -- The first String gives the location of the error, and the -- second some helpful message. checkEq :: (Eq a, Show a) => String -> String -> a -> a -> b -> b -- | Given an array length, check it is not zero. checkNotEmpty :: String -> Int -> a -> a -- | Throw an error saying something was not intitialised. -- -- The String must contain a helpful message saying what module -- the error occured in, and the possible reasons for it. If not then a -- puppy dies at compile time. uninitialised :: String -> a -- | Given a value of an algebraic type, the tag tells us what data -- constructor was used to create it. type Tag = Int -- | Get the Tag of a Bool value. False is 0, -- True is 1. fromBool :: Bool -> Tag -- | Convert a Tag to a Bool value. toBool :: Tag -> Bool -- | Convert a Tag to an Int. This is identity at the value -- level. tagToInt :: Tag -> Int -- | Convert an Int to a Tag. This is identity at the value -- level. intToTag :: Int -> Tag showsApp :: Show a => Int -> String -> a -> ShowS readApp :: Read a => String -> ReadPrec a readsApp :: Read a => Int -> String -> ReadS a -- | Parsing of Strings, producing values. -- -- Minimal complete definition: readsPrec (or, for GHC only, -- readPrec) -- -- Derived instances of Read make the following assumptions, which -- derived instances of Text.Show.Show obey: -- -- -- -- For example, given the declarations -- --
--   infixr 5 :^:
--   data Tree a =  Leaf a  |  Tree a :^: Tree a
--   
-- -- the derived instance of Read in Haskell 98 is equivalent to -- --
--   instance (Read a) => Read (Tree a) where
--   
--           readsPrec d r =  readParen (d > app_prec)
--                            (\r -> [(Leaf m,t) |
--                                    ("Leaf",s) <- lex r,
--                                    (m,t) <- readsPrec (app_prec+1) s]) r
--   
--                         ++ readParen (d > up_prec)
--                            (\r -> [(u:^:v,w) |
--                                    (u,s) <- readsPrec (up_prec+1) r,
--                                    (":^:",t) <- lex s,
--                                    (v,w) <- readsPrec (up_prec+1) t]) r
--   
--             where app_prec = 10
--                   up_prec = 5
--   
-- -- Note that right-associativity of :^: is unused. -- -- The derived instance in GHC is equivalent to -- --
--   instance (Read a) => Read (Tree a) where
--   
--           readPrec = parens $ (prec app_prec $ do
--                                    Ident "Leaf" <- lexP
--                                    m <- step readPrec
--                                    return (Leaf m))
--   
--                        +++ (prec up_prec $ do
--                                    u <- step readPrec
--                                    Symbol ":^:" <- lexP
--                                    v <- step readPrec
--                                    return (u :^: v))
--   
--             where app_prec = 10
--                   up_prec = 5
--   
--           readListPrec = readListPrecDefault
--   
class Read a readsPrec :: Read a => Int -> ReadS a readList :: Read a => ReadS [a] readPrec :: Read a => ReadPrec a readListPrec :: Read a => ReadPrec [a] -- | The strict state-transformer monad. A computation of type -- ST s a transforms an internal state indexed by -- s, and returns a value of type a. The s -- parameter is either -- -- -- -- It serves to keep the internal states of different invocations of -- runST separate from each other and from invocations of -- Control.Monad.ST.stToIO. -- -- The >>= and >> operations are strict in the -- state (though not in values stored in the state). For example, -- --
--   runST (writeSTRef _|_ v >>= f) = _|_
--   
newtype ST s a :: * -> * -> * ST :: STRep s a -> ST s a -- | Return the value computed by a state transformer computation. The -- forall ensures that the internal state used by the ST -- computation is inaccessible to the rest of the program. runST :: (forall s. ST s a) -> a -- | Stream functions not implemented in Data.Vector module Data.Array.Parallel.Stream -- | Tag each element of an stream with its index in that stream. -- --
--   indexed [42,93,13]
--    = [(0,42), (1,93), (2,13)]
--   
indexedS :: Stream a -> Stream (Int, a) -- | Given a stream of pairs containing a count an an element, replicate -- element the number of times given by the count. -- -- The first parameter sets the size hint of the resulting stream. -- --
--   replicateEach 10 [(2,10), (5,20), (3,30)]
--     = [10,10,20,20,20,20,20,30,30,30]
--   
replicateEachS :: Int -> Stream (Int, a) -> Stream a -- | Repeat each element in the stream the given number of times. -- --
--   replicateEach 2 [10,20,30]
--    = [10,10,20,20,30,30]
--   
replicateEachRS :: Int -> Stream a -> Stream a -- | Interleave the elements of two streams. We alternate between the first -- and second streams, stopping when we can't find a matching element. -- --
--   interleave [2,3,4] [10,20,30] = [2,10,3,20,4,30]
--   interleave [2,3]   [10,20,30] = [2,10,3,20]
--   interleave [2,3,4] [10,20]    = [2,10,3,20,4]
--   
interleaveS :: Stream a -> Stream a -> Stream a -- | Combine two streams, using a tag stream to tell us which of the data -- streams to take the next element from. -- -- If there are insufficient elements in the data strams for the provided -- tag stream then error. -- --
--   combine2ByTag [0,1,1,0,0,1] [1,2,3] [4,5,6]
--    = [1,4,5,2,3,6]
--   
combine2ByTagS :: Stream Tag -> Stream a -> Stream a -> Stream a -- | Create a stream of integer ranges. The pairs in the input stream give -- the first and last value of each range. -- -- The first parameter gives the size hint for the resulting stream. -- --
--   enumFromToEach 11 [(2,5), (10,16), (20,22)]
--    = [2,3,4,5,10,11,12,13,14,15,16,20,21,22]
--   
enumFromToEachS :: Int -> Stream (Int, Int) -> Stream Int -- | Create a stream of integer ranges. The triples in the input stream -- give the first value, increment, length of each range. -- -- The first parameter gives the size hint for the resulting stream. -- --
--   enumFromStepLenEach [(1,1,5), (10,2,4), (20,3,5)]
--    = [1,2,3,4,5,10,12,14,16,20,23,26,29,32]
--   
enumFromStepLenEachS :: Int -> Stream (Int, Int, Int) -> Stream Int -- | Segmented Stream fold. Take segments from the given stream and fold -- each using the supplied function and initial element. -- --
--   foldSS (+) 0 [2, 3, 2] [10, 20, 30, 40, 50, 60, 70]
--    = [30,120,130]
--   
foldSS :: (a -> b -> a) -> a -> Stream Int -> Stream b -> Stream a -- | Like foldSS, but use the first member of each chunk as the -- initial element for the fold. fold1SS :: (a -> a -> a) -> Stream Int -> Stream a -> Stream a -- | Segmented Stream combine. Like combine2ByTagS, except that the -- tags select entire segments of each data stream, instead of selecting -- one element at a time. -- --
--   combineSS [True, True, False, True, False, False]
--             [2,1,3] [10,20,30,40,50,60]
--             [1,2,3] [11,22,33,44,55,66]
--    = [10,20,30,11,40,50,60,22,33,44,55,66]
--   
-- -- This says take two elements from the first stream, then another one -- element from the first stream, then one element from the second -- stream, then three elements from the first stream... combineSS :: Stream Bool -> Stream Int -> Stream a -> Stream Int -> Stream a -> Stream a -- | Segmented Strem append. Append corresponding segments from each -- stream. -- --
--   appendSS [2, 1, 3] [10, 20, 30, 40, 50, 60]
--            [1, 3, 2] [11, 22, 33, 44, 55, 66]
--    = [10,20,11,30,22,33,44,40,50,60,55,66]
--   
appendSS :: Stream Int -> Stream a -> Stream Int -> Stream a -> Stream a -- | Segmented Stream fold, with a fixed segment length. -- -- Like foldSS but use a fixed length for each segment. foldValuesR :: (a -> b -> a) -> a -> Int -> Stream b -> Stream a -- | Segmented Stream indices. -- --
--   indicesSS 15 4 [3, 5, 7]
--    = [4,5,6,0,1,2,3,4,0,1,2,3,4,5,6]
--   
-- -- Note that we can set the starting value of the first segment -- independently via the second argument of indicesSS. We use this when -- distributing arrays across worker threads, as a thread's chunk may not -- start exactly at a segment boundary, so the index of a thread's first -- data element may not be zero. indicesSS :: Int -> Int -> Stream Int -> Stream Int