futhark
Safe HaskellNone
LanguageGHC2021

Futhark.IR.SOACS.Simplify

Synopsis

Documentation

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.

Methods

asSOAC :: Op rep -> Maybe (SOAC rep) Source #

soacOp :: SOAC rep -> Op rep Source #

Instances

Instances details
HasSOAC (Wise GPU) Source # 
Instance details

Defined in Futhark.IR.GPU.Simplify

HasSOAC (Wise SOACS) Source # 
Instance details

Defined in Futhark.IR.SOACS.Simplify

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.

data SOACS Source #

The rep for the basic representation.

Instances

Instances details
Analyse SOACS Source # 
Instance details

Defined in Futhark.Analysis.AccessPattern

BuilderOps SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

Methods

mkExpDecB :: (MonadBuilder m, Rep m ~ SOACS) => Pat (LetDec SOACS) -> Exp SOACS -> m (ExpDec SOACS) Source #

mkBodyB :: (MonadBuilder m, Rep m ~ SOACS, IsResult res) => Stms SOACS -> [res] -> m (GBody SOACS res) Source #

mkLetNamesB :: (MonadBuilder m, Rep m ~ SOACS) => [VName] -> Exp SOACS -> m (Stm SOACS) Source #

Buildable SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

PrettyRep SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

Methods

ppExpDec :: ExpDec SOACS -> Exp SOACS -> Maybe (Doc a) Source #

ASTRep SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

RepTypes SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

Associated Types

type LetDec SOACS 
Instance details

Defined in Futhark.IR.SOACS

type ExpDec SOACS 
Instance details

Defined in Futhark.IR.SOACS

type ExpDec SOACS = ()
type BodyDec SOACS 
Instance details

Defined in Futhark.IR.SOACS

type BodyDec SOACS = ()
type FParamInfo SOACS 
Instance details

Defined in Futhark.IR.SOACS

type LParamInfo SOACS 
Instance details

Defined in Futhark.IR.SOACS

type RetType SOACS 
Instance details

Defined in Futhark.IR.SOACS

type BranchType SOACS 
Instance details

Defined in Futhark.IR.SOACS

type OpC SOACS 
Instance details

Defined in Futhark.IR.SOACS

type OpC SOACS = SOAC
TraverseOpStms SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

Checkable SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

HasScope SOACS ADM Source # 
Instance details

Defined in Futhark.AD.Rev.Monad

HasScope SOACS InternaliseM Source # 
Instance details

Defined in Futhark.Internalise.Monad

LocalScope SOACS ADM Source # 
Instance details

Defined in Futhark.AD.Rev.Monad

Methods

localScope :: Scope SOACS -> ADM a -> ADM a Source #

LocalScope SOACS InternaliseM Source # 
Instance details

Defined in Futhark.Internalise.Monad

HasScope SOACS (ImpM rep r op) Source # 
Instance details

Defined in Futhark.CodeGen.ImpGen

Methods

lookupType :: VName -> ImpM rep r op Type Source #

lookupInfo :: VName -> ImpM rep r op (NameInfo SOACS) Source #

askScope :: ImpM rep r op (Scope SOACS) Source #

asksScope :: (Scope SOACS -> a) -> ImpM rep r op a Source #

BuilderOps (Wise SOACS) Source # 
Instance details

Defined in Futhark.IR.SOACS.Simplify

HasSOAC (Wise SOACS) Source # 
Instance details

Defined in Futhark.IR.SOACS.Simplify

TraverseOpStms (Wise SOACS) Source # 
Instance details

Defined in Futhark.IR.SOACS.Simplify

type BodyDec SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

type BodyDec SOACS = ()
type BranchType SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

type ExpDec SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

type ExpDec SOACS = ()
type FParamInfo SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

type LParamInfo SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

type LetDec SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

type OpC SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

type OpC SOACS = SOAC
type RetType SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

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.

dedupInput Source #

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 # 
Instance details

TraverseOpStms (Wise SOACS) Source # 
Instance details