futhark
Safe HaskellNone
LanguageGHC2021

Futhark.Tools

Description

An unstructured grab-bag of various tools and inspection functions that didn't really fit anywhere else.

Synopsis

Documentation

redomapToMapAndReduce :: (MonadFreshNames m, LetDec rep ~ Type, Buildable rep, ExpDec rep ~ (), Op rep ~ SOAC rep) => Pat (LetDec rep) -> (SubExp, [Reduce rep], Lambda rep, [VName]) -> m (Stm rep, Stm rep) Source #

Turns a binding of a redomap into two seperate bindings, a map binding and a reduce binding (returned in that order).

Reuses the original pattern for the reduce, and creates a new pattern with new Idents for the result of the map.

scanomapToMapAndScan :: (MonadFreshNames m, Buildable rep, LetDec rep ~ Type, ExpDec rep ~ (), Op rep ~ SOAC rep) => Pat (LetDec rep) -> (SubExp, [Scan rep], Lambda rep, [VName]) -> m (Stm rep, Stm rep) Source #

maposcanomapToMapScanAndMap :: (MonadFreshNames m, Buildable rep, Op rep ~ SOAC rep) => Pat (LetDec rep) -> (SubExp, Lambda rep, [Scan rep], Lambda rep, [VName]) -> m (Stm rep, Stm rep, Stm rep) Source #

maposcanomapToMaposcanAndMap :: (MonadFreshNames m, Buildable rep, Op rep ~ SOAC rep) => Pat (LetDec rep) -> (SubExp, Lambda rep, [Scan rep], Lambda rep, [VName]) -> m (Stm rep, Stm rep) Source #

dissectScrema :: (MonadBuilder m, Op (Rep m) ~ SOAC (Rep m), Buildable (Rep m)) => Pat (LetDec (Rep m)) -> SubExp -> ScremaForm (Rep m) -> [VName] -> m () Source #

Turn a Screma into a maposcanomap (possibly with mapout parts) and a Redomap. This is used to handle Scremas that are so complicated that we cannot directly generate efficient parallel code for them. In essense, what happens is the opposite of horisontal fusion.

extractPostLambda :: (MonadBuilder m, Op (Rep m) ~ SOAC (Rep m), Buildable (Rep m)) => Pat (LetDec (Rep m)) -> SubExp -> [VName] -> ScremaForm (Rep m) -> m () Source #

Remove the post lambda from a screma, producing the screma with an identity post-lambda, and a new map screma that is just the post-lambda. You can apply this indefinitely in case the post-lambda is already an identity lambda, so be careful.

sequentialStreamWholeArray :: (MonadBuilder m, Buildable (Rep m)) => Pat (LetDec (Rep m)) -> SubExp -> [SubExp] -> Lambda (Rep m) -> [VName] -> m () Source #

Turn a stream SOAC into statements that apply the stream lambda to the entire input.

partitionChunkedFoldParameters :: Int -> [Param dec] -> (Param dec, [Param dec], [Param dec]) Source #

Split the parameters of a stream reduction lambda into the chunk size parameter, the accumulator parameters, and the input chunk parameters. The integer argument is how many accumulators are used.

withAcc :: (MonadBuilder m, LParam (Rep m) ~ Param Type) => [VName] -> Int -> ([VName] -> m [SubExp]) -> m (Exp (Rep m)) Source #

Construct a one-dimensional scatter-like WithAcc. The closure is invoked with the accumulators.

doScatter :: (MonadBuilder m, Buildable (Rep m), Op (Rep m) ~ SOAC (Rep m)) => Name -> Int -> [VName] -> [VName] -> ([LParam (Rep m)] -> m [SubExp]) -> m [VName] Source #

Perform a scatter-like operation using accumulators and map.

doHist :: (MonadBuilder m, Buildable (Rep m), Op (Rep m) ~ SOAC (Rep m)) => Name -> [HistOp (Rep m)] -> [VName] -> ([LParam (Rep m)] -> m [SubExp]) -> m [[VName]] Source #

Perform a histogram-like operation using accumulators and map.

addBinOp :: PrimType -> BinOp Source #

The most addition-like binary operator for some primitive type.

addLambda :: (OpC (Rep m) ~ SOAC, MonadBuilder m, Buildable (Rep m)) => TypeBase Shape NoMode -> m (Lambda (Rep m)) Source #

Construct a lambda for adding two values of the given type, Using SOACs to handle arrays.

Primitive expressions