| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Futhark.IR.SOACS.Simplify
Contents
Synopsis
- simplifySOACS :: Prog SOACS -> PassM (Prog SOACS)
- simplifyLambda :: (HasScope SOACS m, MonadFreshNames m) => Lambda SOACS -> m (Lambda SOACS)
- simplifyFun :: MonadFreshNames m => SymbolTable (Wise SOACS) -> FunDef SOACS -> m (FunDef SOACS)
- simplifyStms :: (HasScope SOACS m, MonadFreshNames m) => Stms SOACS -> m (Stms SOACS)
- simplifyConsts :: MonadFreshNames m => Stms SOACS -> m (Stms SOACS)
- simpleSOACS :: SimpleOps SOACS
- simplifySOAC :: SimplifiableRep rep => SimplifyOp rep (SOAC (Wise rep))
- soacRules :: RuleBook (Wise SOACS)
- class HasSOAC rep where
- simplifyKnownIterationSOAC :: (Buildable rep, BuilderOps rep, HasSOAC rep, AliasableRep rep) => TopDownRuleOp rep
- removeReplicateMapping :: (Aliased rep, Buildable rep, BuilderOps rep, HasSOAC rep) => TopDownRuleOp rep
- removeUnusedSOACInput :: (Aliased rep, Buildable rep, BuilderOps rep, HasSOAC rep) => TopDownRuleOp rep
- liftIdentityMapping :: (Buildable rep, BuilderOps rep, HasSOAC rep) => TopDownRuleOp rep
- simplifyMapIota :: (Buildable rep, BuilderOps rep, HasSOAC rep) => TopDownRuleOp rep
- data SOACS
- eliminate :: Buildable rep => Names -> Stms rep -> Stms rep
- eliminateWithDeps :: Buildable rep => Names -> Stms rep -> (Names, Stms rep)
- eliminateByRes :: Buildable rep => Lambda rep -> Lambda rep
- prunePreLambdaResults :: Buildable rep => ScremaForm rep -> ScremaForm rep
- dedupInput :: (Buildable rep, Ord a) => [a] -> ScremaForm rep -> ([a], ScremaForm rep)
Documentation
simplifyLambda :: (HasScope SOACS m, MonadFreshNames m) => Lambda SOACS -> m (Lambda SOACS) Source #
simplifyFun :: MonadFreshNames m => SymbolTable (Wise SOACS) -> FunDef SOACS -> m (FunDef SOACS) Source #
simplifyStms :: (HasScope SOACS m, MonadFreshNames m) => Stms SOACS -> m (Stms SOACS) Source #
simplifyConsts :: MonadFreshNames m => Stms SOACS -> m (Stms SOACS) Source #
simplifySOAC :: SimplifiableRep rep => SimplifyOp rep (SOAC (Wise rep)) Source #
class HasSOAC rep where Source #
Does this rep contain SOACs in its Ops? A rep must be an
instance of this class for the simplification rules to work.
simplifyKnownIterationSOAC :: (Buildable rep, BuilderOps rep, HasSOAC rep, AliasableRep rep) => TopDownRuleOp rep Source #
removeReplicateMapping :: (Aliased rep, Buildable rep, BuilderOps rep, HasSOAC rep) => TopDownRuleOp rep Source #
Remove all arguments to the map that are simply replicates. These can be turned into free variables instead.
removeUnusedSOACInput :: (Aliased rep, Buildable rep, BuilderOps rep, HasSOAC rep) => TopDownRuleOp rep Source #
Remove inputs that are not used inside the SOAC.
liftIdentityMapping :: (Buildable rep, BuilderOps rep, HasSOAC rep) => TopDownRuleOp rep Source #
simplifyMapIota :: (Buildable rep, BuilderOps rep, HasSOAC rep) => TopDownRuleOp rep Source #
The rep for the basic representation.
Instances
eliminate :: Buildable rep => Names -> Stms rep -> Stms rep Source #
Eliminate statements if it is not an dependency used to form the names given.
eliminateWithDeps :: Buildable rep => Names -> Stms rep -> (Names, Stms rep) Source #
As eliminate, but also return everything the retained statements and the
results depend upon. A lambda parameter is live exactly when it is in this
set, which saves traversing the pruned body again just to find its free
variables. The pair is lazy in its second component, so a caller that only
wants to know what is live need not pay for rebuilding the statements.
eliminateByRes :: Buildable rep => Lambda rep -> Lambda rep Source #
Eliminate statements inside a lambda if they are not used to compute the result.
prunePreLambdaResults :: Buildable rep => ScremaForm rep -> ScremaForm rep Source #
Prunes all unused results from the pre-lambda in a ScremaForm with scans or reduces (fixed-point).
Repeatedly prunes unused scan and map results until no further changes occur. This is necessary because eliminating some results may make other results unused.
Example: If a map result is only used by a scan operation, and that scan's results don't contribute to the post-lambda's results, then the first pass removes the scan results, and the second pass can then remove the map result.
Returns: A ScremaForm with all transitively unused pre-lambda results eliminated.
Arguments
| :: (Buildable rep, Ord a) | |
| => [a] | Inputs |
| -> ScremaForm rep | Screma |
| -> ([a], ScremaForm rep) | Deduplicated inputs and new screma |
Removes duplicate inputs from a ScremaForm's lambda parameters.
When the same input appears multiple times in the input list (with corresponding duplicate lambda parameters), this function: 1. Keeps only one copy of each distinct input 2. Creates let-bindings in the lambda body to alias the duplicates
Example: If inputs [x, y, x] map to lambda params [a, b, c], the result will have inputs [x, y] with params [a, b], and a let-binding c = a.
Arguments: * Input list that corresponds 1:1 with the lambda's parameters * ScremaForm containing the lambda to transform
Returns: * Deduplicated input list * Modified ScremaForm with updated lambda (fewer params, additional bindings)
Orphan instances
| BuilderOps (Wise SOACS) Source # | |
Methods mkExpDecB :: (MonadBuilder m, Rep m ~ Wise SOACS) => Pat (LetDec (Wise SOACS)) -> Exp (Wise SOACS) -> m (ExpDec (Wise SOACS)) Source # mkBodyB :: (MonadBuilder m, Rep m ~ Wise SOACS, IsResult res) => Stms (Wise SOACS) -> [res] -> m (GBody (Wise SOACS) res) Source # mkLetNamesB :: (MonadBuilder m, Rep m ~ Wise SOACS) => [VName] -> Exp (Wise SOACS) -> m (Stm (Wise SOACS)) Source # | |
| TraverseOpStms (Wise SOACS) Source # | |
Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise SOACS)) (Wise SOACS) Source # | |