Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
It is well known that fully parallel loops can always be interchanged inwards with a sequential loop. This module implements that transformation.
This is also where we implement loop-switching (for branches), which is semantically similar to interchange.
Synopsis
- data SeqLoop = SeqLoop [Int] (Pat Type) [(FParam SOACS, SubExp)] LoopForm (Body SOACS)
- interchangeLoops :: (MonadFreshNames m, HasScope SOACS m) => KernelNest -> SeqLoop -> m (Stms SOACS)
- data Branch = Branch [Int] (Pat Type) [SubExp] [Case (Body SOACS)] (Body SOACS) (MatchDec (BranchType SOACS))
- interchangeBranch :: (MonadFreshNames m, HasScope SOACS m) => KernelNest -> Branch -> m (Stm SOACS)
- data WithAccStm = WithAccStm [Int] (Pat Type) [(Shape, [VName], Maybe (Lambda SOACS, [SubExp]))] (Lambda SOACS)
- interchangeWithAcc :: (MonadFreshNames m, LocalScope SOACS m) => KernelNest -> WithAccStm -> m (Stm SOACS)
Documentation
An encoding of a sequential do-loop with no existential context, alongside its result pattern.
interchangeLoops :: (MonadFreshNames m, HasScope SOACS m) => KernelNest -> SeqLoop -> m (Stms SOACS) Source #
Given a (parallel) map nesting and an inner sequential loop, move
the maps inside the sequential loop. The result is several
statements - one of these will be the loop, which will then contain
statements with map
expressions.
An encoding of a branch with alongside its result pattern.
interchangeBranch :: (MonadFreshNames m, HasScope SOACS m) => KernelNest -> Branch -> m (Stm SOACS) Source #
Given a (parallel) map nesting and an inner branch, move the maps
inside the branch. The result is the resulting branch expression,
which will then contain statements with map
expressions.
data WithAccStm Source #
An encoding of a WithAcc with alongside its result pattern.
interchangeWithAcc :: (MonadFreshNames m, LocalScope SOACS m) => KernelNest -> WithAccStm -> m (Stm SOACS) Source #
Given a (parallel) map nesting and an inner withacc, move the
maps inside the branch. The result is the resulting withacc
expression, which will then contain statements with map
expressions.