| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Futhark.Pass.Flatten.General
Description
Various general utilities used in flattening.
Synopsis
- readInputVar :: Segments -> DistEnv -> [SubExp] -> DistInputs -> VName -> FlattenM VName
- readInputs :: Segments -> DistEnv -> [SubExp] -> DistInputs -> FlattenM ()
- readInput :: Segments -> DistEnv -> [SubExp] -> DistInputs -> SubExp -> FlattenM SubExp
- readNeutral :: Segments -> DistEnv -> DistInputs -> SubExp -> FlattenM SubExp
- readTypeDims :: Segments -> DistEnv -> [SubExp] -> DistInputs -> TypeBase Shape o -> FlattenM [SubExp]
- ensureDenseIrregular :: SegLevel -> Name -> IrregularRep -> FlattenM IrregularRep
- liftResult :: SegLevel -> Segments -> DistInputs -> DistEnv -> SubExpRes -> FlattenM Result
- liftDistResultRep :: SegLevel -> Segments -> DistInputs -> DistEnv -> DistResult -> SubExpRes -> FlattenM ResRep
- liftSubExp :: SegLevel -> Segments -> DistInputs -> DistEnv -> SubExp -> FlattenM (Type, ResRep)
- liftSubExpPreserveRep :: Segments -> DistInputs -> DistEnv -> SubExp -> FlattenM (Type, ResRep)
- liftSubExpRegular :: SegLevel -> Segments -> DistInputs -> DistEnv -> Shape -> SubExp -> FlattenM VName
- liftVarRegular :: SegLevel -> Segments -> DistInputs -> DistEnv -> Shape -> VName -> FlattenM VName
- isRegularInputArr :: DistEnv -> DistInputs -> VName -> Bool
- liftParam :: MonadFreshNames m => SubExp -> FParam SOACS -> m ([FParam GPU], ResRep)
- liftRegularParam :: MonadFreshNames m => SubExp -> FParam SOACS -> m (FParam GPU, ResRep)
- liftRegResult :: SegLevel -> Segments -> SubExp -> DistInputs -> DistEnv -> RetType SOACS -> SubExpRes -> FlattenM Result
- needsIrregularRetType :: DistInputs -> RetType SOACS -> Bool
- mkIrregFromReg :: SegLevel -> Segments -> VName -> FlattenM IrregularRep
- flattenIrregularRep :: SegLevel -> IrregularRep -> FlattenM IrregularRep
- distCerts :: DistInputs -> StmAux a -> DistEnv -> Certs
- dataArr :: SegLevel -> Segments -> DistEnv -> DistInputs -> SubExp -> FlattenM VName
- getIrregRep :: SegLevel -> Segments -> DistEnv -> DistInputs -> VName -> FlattenM IrregularRep
- scatterIrregular :: SegLevel -> VName -> VName -> (VName, IrregularRep) -> FlattenM VName
- scatterRegular :: SegLevel -> VName -> (VName, VName) -> FlattenM VName
- module Futhark.Pass.Flatten.Monad
- module Futhark.Pass.Flatten.Builtins
- scopeOfDistInputs :: DistInputs -> Scope GPU
- lookupInputType :: DistInputs -> VName -> FlattenM Type
- subExpInputType :: DistInputs -> SubExp -> FlattenM Type
- localiseInputs :: DistEnv -> DistInputs -> FlattenM (DistInputs, DistEnv, Int)
- replicateForDims :: Segments -> Shape -> VName -> FlattenM VName
- liftBodyWithDistResults :: FlattenOps -> Segments -> DistInputs -> DistEnv -> DistStms -> [DistResult] -> Result -> FlattenM Result
- distResultsToResReps :: [DistResult] -> [VName] -> [ResRep]
- resultToResReps :: [TypeBase s o] -> [VName] -> [ResRep]
- resultToResRepsByDistResult :: [DistResult] -> [VName] -> [ResRep]
- irregularRepToFlatArrs :: SubExp -> IrregularRep -> FlattenM [VName]
- distributeAndFlattenBody :: FlattenOps -> Segments -> Name -> DistEnv -> DistInputs -> [DistResult] -> Body SOACS -> FlattenM [ResRep]
- splitInput :: SegLevel -> Segments -> DistEnv -> DistInputs -> VName -> Map VName ResRep -> VName -> FlattenM (Type, VName, ResRep)
- isVariant :: DistInputs -> SubExp -> Bool
- segmentDims :: Segments -> [TPrimExp Int64 VName]
- flattenDistStm :: FlattenOps -> Segments -> DistEnv -> DistStm -> FlattenM DistEnv
- flattenScalarStm :: FlattenOps -> Segments -> DistEnv -> DistInputs -> [DistResult] -> Stm SOACS -> FlattenM DistEnv
- distributeBodyWith :: FlattenOps -> Scope rep -> Segments -> DistInputs -> Body SOACS -> (DistInputs, DistStms)
- distributeMapWith :: FlattenOps -> Scope rep -> Pat Type -> Segments -> [MapArray t] -> Lambda SOACS -> (Distributed, Map ResTag t)
- atSegLevel :: SegLevel -> FlattenOps -> FlattenOps
Reading inputs
readInputVar :: Segments -> DistEnv -> [SubExp] -> DistInputs -> VName -> FlattenM VName Source #
readInputs :: Segments -> DistEnv -> [SubExp] -> DistInputs -> FlattenM () Source #
readNeutral :: Segments -> DistEnv -> DistInputs -> SubExp -> FlattenM SubExp Source #
Read the neutral element of a reduction or scan operator. The neutral element of an operator is unique because we assume uniform operators, so a valid program must have the same value in every segment, and we can read it from the first one. This is the case even if the neutral element is nonuniform, which is useless but allowed. The segment space may however be empty, in which case we produce a blank value instead; it is never used then, but an unconditional read would be out of bounds.
readTypeDims :: Segments -> DistEnv -> [SubExp] -> DistInputs -> TypeBase Shape o -> FlattenM [SubExp] Source #
Building blocks
ensureDenseIrregular :: SegLevel -> Name -> IrregularRep -> FlattenM IrregularRep Source #
liftResult :: SegLevel -> Segments -> DistInputs -> DistEnv -> SubExpRes -> FlattenM Result Source #
liftDistResultRep :: SegLevel -> Segments -> DistInputs -> DistEnv -> DistResult -> SubExpRes -> FlattenM ResRep Source #
liftSubExp :: SegLevel -> Segments -> DistInputs -> DistEnv -> SubExp -> FlattenM (Type, ResRep) Source #
liftSubExpPreserveRep :: Segments -> DistInputs -> DistEnv -> SubExp -> FlattenM (Type, ResRep) Source #
liftSubExpRegular :: SegLevel -> Segments -> DistInputs -> DistEnv -> Shape -> SubExp -> FlattenM VName Source #
Like liftSubExp but always returns a Regular result with the
given expected shape. Reshapes the underlying data if necessary.
liftVarRegular :: SegLevel -> Segments -> DistInputs -> DistEnv -> Shape -> VName -> FlattenM VName Source #
isRegularInputArr :: DistEnv -> DistInputs -> VName -> Bool Source #
Can this input array be lifted to a regular array? This holds unless it is
represented irregularly. The uniform alternatives lift their inputs regularly
(via liftSubExpRegular), which is only valid when the inputs are actually
regular.
liftRegularParam :: MonadFreshNames m => SubExp -> FParam SOACS -> m (FParam GPU, ResRep) Source #
liftRegResult :: SegLevel -> Segments -> SubExp -> DistInputs -> DistEnv -> RetType SOACS -> SubExpRes -> FlattenM Result Source #
needsIrregularRetType :: DistInputs -> RetType SOACS -> Bool Source #
mkIrregFromReg :: SegLevel -> Segments -> VName -> FlattenM IrregularRep Source #
flattenIrregularRep :: SegLevel -> IrregularRep -> FlattenM IrregularRep Source #
Flatten the arrays of an IrregularRep to be entirely one-dimensional.
dataArr :: SegLevel -> Segments -> DistEnv -> DistInputs -> SubExp -> FlattenM VName Source #
Only sensible for variables of uniform type.
getIrregRep :: SegLevel -> Segments -> DistEnv -> DistInputs -> VName -> FlattenM IrregularRep Source #
Get the irregular representation of a var.
scatterIrregular :: SegLevel -> VName -> VName -> (VName, IrregularRep) -> FlattenM VName Source #
Write back the irregular results of a branch to a (partially) blank space
The offsets variable is the offsets of the final result, whereas irregRep
is the irregular representation of the result.
scatterRegular :: SegLevel -> VName -> (VName, VName) -> FlattenM VName Source #
Write back the regular results to a (partially) blank space
module Futhark.Pass.Flatten.Monad
Various
scopeOfDistInputs :: DistInputs -> Scope GPU Source #
lookupInputType :: DistInputs -> VName -> FlattenM Type Source #
subExpInputType :: DistInputs -> SubExp -> FlattenM Type Source #
localiseInputs :: DistEnv -> DistInputs -> FlattenM (DistInputs, DistEnv, Int) Source #
replicateForDims :: Segments -> Shape -> VName -> FlattenM VName Source #
Replicate an array to insert new inner dimensions after the existing segment dimensions.
liftBodyWithDistResults :: FlattenOps -> Segments -> DistInputs -> DistEnv -> DistStms -> [DistResult] -> Result -> FlattenM Result Source #
distResultsToResReps :: [DistResult] -> [VName] -> [ResRep] Source #
resultToResReps :: [TypeBase s o] -> [VName] -> [ResRep] Source #
This function walks through the *unlifted* result types and uses the *lifted* results to construct the corresponding res reps.
See the liftResult function for the opposite process i.e.
turning ResReps into results.
resultToResRepsByDistResult :: [DistResult] -> [VName] -> [ResRep] Source #
irregularRepToFlatArrs :: SubExp -> IrregularRep -> FlattenM [VName] Source #
Convert an irregular representation to its flat constituents (number of data elements, segments, flags, offsets, elements), with the structure arrays reshaped to be one-dimensional of the given width. This is the form in which irregular values are passed to lifted functions and carried through loops.
distributeAndFlattenBody :: FlattenOps -> Segments -> Name -> DistEnv -> DistInputs -> [DistResult] -> Body SOACS -> FlattenM [ResRep] Source #
Distribute a body and lift the distributed statements, giving back representations of the body results.
splitInput :: SegLevel -> Segments -> DistEnv -> DistInputs -> VName -> Map VName ResRep -> VName -> FlattenM (Type, VName, ResRep) Source #
Take the elements at index is from an input v. The representation of
v can be overridden through the provided mapping, which takes precedence
over what the environment says.
flattenDistStm :: FlattenOps -> Segments -> DistEnv -> DistStm -> FlattenM DistEnv Source #
Flatten a single DistStm, producing an updated environment.
flattenScalarStm :: FlattenOps -> Segments -> DistEnv -> DistInputs -> [DistResult] -> Stm SOACS -> FlattenM DistEnv Source #
Flatten a single scalar statement, producing an updated environment.
distributeBodyWith :: FlattenOps -> Scope rep -> Segments -> DistInputs -> Body SOACS -> (DistInputs, DistStms) Source #
distributeBody with the settings in the given FlattenOps.
distributeMapWith :: FlattenOps -> Scope rep -> Pat Type -> Segments -> [MapArray t] -> Lambda SOACS -> (Distributed, Map ResTag t) Source #
distributeMap with the settings in the given FlattenOps.
atSegLevel :: SegLevel -> FlattenOps -> FlattenOps Source #
Continue flattening at the given seg level, adjusting the irregularity
handling mode to match. Intrablock code cannot use the machinery for
flattening irregular arrays, as it produces SegOps whose sizes are bound
inside the enclosing kernel. SequentialiseIrregularAll is requested by the
user rather than implied by the level, so we keep it if provided.