futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | None
Language | GHC2021

Futhark.IR.GPU

Contents

- Module re-exports

Description

A representation with flat parallelism via GPU-oriented kernels.

Synopsis

- data GPU
- module Futhark.IR.Prop
- module Futhark.IR.Traversals
- module Futhark.IR.Pretty
- module Futhark.IR.Syntax
- module Futhark.IR.GPU.Op
- module Futhark.IR.GPU.Sizes
- data SOAC rep
  - = Stream SubExp [VName] [SubExp] (Lambda rep)
  - | Scatter SubExp [VName] (ScatterSpec VName) (Lambda rep)
  - | Hist SubExp [VName] [HistOp rep] (Lambda rep)
  - | JVP [SubExp] [SubExp] (Lambda rep)
  - | VJP [SubExp] [SubExp] (Lambda rep)
  - | Screma SubExp [VName] (ScremaForm rep)
- data Scan rep = Scan {
  - scanLambda :: Lambda rep
  - scanNeutral :: [SubExp]
  }
- data Reduce rep = Reduce {
  - redComm :: Commutativity
  - redLambda :: Lambda rep
  - redNeutral :: [SubExp]
  }
- data ScremaForm rep = ScremaForm {
  - scremaLambda :: Lambda rep
  - scremaScans :: [Scan rep]
  - scremaReduces :: [Reduce rep]
  }
- type ScatterSpec v = [(Shape, Int, v)]
- scremaType :: SubExp -> ScremaForm rep -> [Type]
- scanResults :: [Scan rep] -> Int
- singleScan :: Buildable rep => [Scan rep] -> Scan rep
- redResults :: [Reduce rep] -> Int
- singleReduce :: Buildable rep => [Reduce rep] -> Reduce rep
- soacType :: Typed (LParamInfo rep) => SOAC rep -> [Type]
- typeCheckSOAC :: Checkable rep => SOAC (Aliases rep) -> TypeM rep ()
- mkIdentityLambda :: (Buildable rep, MonadFreshNames m) => [Type] -> m (Lambda rep)
- isIdentityLambda :: Lambda rep -> Bool
- nilFn :: Buildable rep => Lambda rep
- scanomapSOAC :: [Scan rep] -> Lambda rep -> ScremaForm rep
- redomapSOAC :: [Reduce rep] -> Lambda rep -> ScremaForm rep
- scanSOAC :: (Buildable rep, MonadFreshNames m) => [Scan rep] -> m (ScremaForm rep)
- reduceSOAC :: (Buildable rep, MonadFreshNames m) => [Reduce rep] -> m (ScremaForm rep)
- mapSOAC :: Lambda rep -> ScremaForm rep
- isScanomapSOAC :: ScremaForm rep -> Maybe ([Scan rep], Lambda rep)
- isRedomapSOAC :: ScremaForm rep -> Maybe ([Reduce rep], Lambda rep)
- isScanSOAC :: ScremaForm rep -> Maybe [Scan rep]
- isReduceSOAC :: ScremaForm rep -> Maybe [Reduce rep]
- isMapSOAC :: ScremaForm rep -> Maybe (Lambda rep)
- ppScrema :: (PrettyRep rep, Pretty inp) => SubExp -> [inp] -> ScremaForm rep -> Doc ann
- ppHist :: (PrettyRep rep, Pretty inp) => SubExp -> [inp] -> [HistOp rep] -> Lambda rep -> Doc ann
- ppStream :: (PrettyRep rep, Pretty inp) => SubExp -> [inp] -> [SubExp] -> Lambda rep -> Doc ann
- ppScatter :: (PrettyRep rep, Pretty inp) => SubExp -> [inp] -> [(Shape, Int, VName)] -> Lambda rep -> Doc ann
- groupScatterResults :: ScatterSpec array -> [a] -> [(Shape, array, [([a], a)])]
- groupScatterResults' :: [(Shape, Int, array)] -> [a] -> [([a], a)]
- splitScatterResults :: [(Shape, Int, array)] -> [a] -> ([a], [a])
- data SOACMapper frep trep (m :: Type -> Type) = SOACMapper {
  - mapOnSOACSubExp :: SubExp -> m SubExp
  - mapOnSOACLambda :: Lambda frep -> m (Lambda trep)
  - mapOnSOACVName :: VName -> m VName
  }
- identitySOACMapper :: forall rep (m :: Type -> Type). Monad m => SOACMapper rep rep m
- mapSOACM :: Monad m => SOACMapper frep trep m -> SOAC frep -> m (SOAC trep)
- traverseSOACStms :: Monad m => OpStmsTraverser m (SOAC rep) rep

# Documentation

data GPU Source #

The phantom data type for the kernels representation.

#### Instances

Instances details

Analyse GPU Source # |
Instance details Defined in Futhark.Analysis.AccessPattern Methods analyseOp :: Op GPU -> Context GPU -> [VName] -> (Context GPU, IndexTable GPU)
PrimExpAnalysis GPU Source # |
Instance details Defined in Futhark.Analysis.PrimExp.Table Methods opPrimExp :: Scope GPU -> Op GPU -> State PrimExpTable () Source #
BuilderOps GPU Source # |
Instance details Defined in Futhark.IR.GPU Methods mkExpDecB :: (MonadBuilder m, Rep m ~ GPU) => Pat (LetDec GPU) -> Exp GPU -> m (ExpDec GPU) Source # mkBodyB :: (MonadBuilder m, Rep m ~ GPU) => Stms GPU -> Result -> m (Body GPU) Source # mkLetNamesB :: (MonadBuilder m, Rep m ~ GPU) => [VName] -> Exp GPU -> m (Stm GPU) Source #
Buildable GPU Source # |
Instance details Defined in Futhark.IR.GPU Methods mkExpPat :: [Ident] -> Exp GPU -> Pat (LetDec GPU) Source # mkExpDec :: Pat (LetDec GPU) -> Exp GPU -> ExpDec GPU Source # mkBody :: Stms GPU -> Result -> Body GPU Source # mkLetNames :: (MonadFreshNames m, HasScope GPU m) => [VName] -> Exp GPU -> m (Stm GPU) Source #
PrettyRep GPU Source # |
Instance details Defined in Futhark.IR.GPU Methods ppExpDec :: ExpDec GPU -> Exp GPU -> Maybe (Doc a) Source #
ASTRep GPU Source # |
Instance details Defined in Futhark.IR.GPU Methods expTypesFromPat :: (HasScope GPU m, Monad m) => Pat (LetDec GPU) -> m [BranchType GPU] Source #
RepTypes GPU Source # |

Instance details

Defined in Futhark.IR.GPU

Associated Types

type LetDec GPU |
Instance details Defined in Futhark.IR.GPU type LetDec GPU = Type
type ExpDec GPU |
Instance details Defined in Futhark.IR.GPU type ExpDec GPU = ()
type BodyDec GPU |
Instance details Defined in Futhark.IR.GPU type BodyDec GPU = ()
type FParamInfo GPU |
Instance details Defined in Futhark.IR.GPU type FParamInfo GPU = DeclType
type LParamInfo GPU |
Instance details Defined in Futhark.IR.GPU type LParamInfo GPU = Type
type RetType GPU |
Instance details Defined in Futhark.IR.GPU type RetType GPU = DeclExtType
type BranchType GPU |
Instance details Defined in Futhark.IR.GPU type BranchType GPU = ExtType
type OpC GPU |
Instance details Defined in Futhark.IR.GPU type OpC GPU = HostOp SOAC

HasSegOp GPU Source # |

Instance details

Defined in Futhark.IR.GPU

Associated Types

type SegOpLevel GPU |
Instance details Defined in Futhark.IR.GPU type SegOpLevel GPU = SegLevel

Methods

asSegOp :: Op GPU -> Maybe (SegOp (SegOpLevel GPU) GPU) Source #

segOp :: SegOp (SegOpLevel GPU) GPU -> Op GPU Source #

Checkable GPU Source # |

Instance details

Defined in Futhark.IR.GPU

Methods

checkExpDec :: ExpDec GPU -> TypeM GPU () Source #

checkBodyDec :: BodyDec GPU -> TypeM GPU () Source #

checkFParamDec :: VName -> FParamInfo GPU -> TypeM GPU () Source #

checkLParamDec :: VName -> LParamInfo GPU -> TypeM GPU () Source #

checkLetBoundDec :: VName -> LetDec GPU -> TypeM GPU () Source #

checkRetType :: [RetType GPU] -> TypeM GPU () Source #

matchPat :: Pat (LetDec (Aliases GPU)) -> Exp (Aliases GPU) -> TypeM GPU () Source #

primFParam :: VName -> PrimType -> TypeM GPU (FParam (Aliases GPU)) Source #

matchReturnType :: [RetType GPU] -> Result -> TypeM GPU () Source #

matchBranchType :: [BranchType GPU] -> Body (Aliases GPU) -> TypeM GPU () Source #

matchLoopResult :: [FParam (Aliases GPU)] -> Result -> TypeM GPU () Source #

checkOp :: Op (Aliases GPU) -> TypeM GPU () Source #

Transform GPU Source # |
Instance details Defined in Futhark.Optimise.ArrayLayout.Transform Methods onOp :: Monad m => SOACMapper GPU GPU m -> Op GPU -> m (Op GPU) transformOp :: LayoutTable -> ExpMap GPU -> Stm GPU -> Op GPU -> TransformM GPU (LayoutTable, ExpMap GPU)
Layout GPU Source # |
Instance details Defined in Futhark.Optimise.ArrayLayout.Layout Methods permutationFromDimAccess :: PrimExpTable -> SegOpName -> ArrayName -> IndexExprName -> [DimAccess GPU] -> Maybe Permutation
BuilderOps (Wise GPU) Source # |

Instance details

Defined in Futhark.IR.GPU.Simplify

Methods

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

mkBodyB :: (MonadBuilder m, Rep m ~ Wise GPU) => Stms (Wise GPU) -> Result -> m (Body (Wise GPU)) Source #

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

HasSOAC (Wise GPU) Source # |
Instance details Defined in Futhark.IR.GPU.Simplify Methods asSOAC :: Op (Wise GPU) -> Maybe (SOAC (Wise GPU)) Source # soacOp :: SOAC (Wise GPU) -> Op (Wise GPU) Source #
HasSegOp (Wise GPU) Source # |

Instance details

Defined in Futhark.IR.GPU.Simplify

Associated Types

type SegOpLevel (Wise GPU) |
Instance details Defined in Futhark.IR.GPU.Simplify type SegOpLevel (Wise GPU) = SegLevel

Methods

asSegOp :: Op (Wise GPU) -> Maybe (SegOp (SegOpLevel (Wise GPU)) (Wise GPU)) Source #

segOp :: SegOp (SegOpLevel (Wise GPU)) (Wise GPU) -> Op (Wise GPU) Source #

TraverseOpStms (Wise GPU) Source # |
Instance details Defined in Futhark.IR.GPU.Simplify Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise GPU)) (Wise GPU) Source #
type BodyDec GPU Source # |
Instance details Defined in Futhark.IR.GPU type BodyDec GPU = ()
type BranchType GPU Source # |
Instance details Defined in Futhark.IR.GPU type BranchType GPU = ExtType
type ExpDec GPU Source # |
Instance details Defined in Futhark.IR.GPU type ExpDec GPU = ()
type FParamInfo GPU Source # |
Instance details Defined in Futhark.IR.GPU type FParamInfo GPU = DeclType
type LParamInfo GPU Source # |
Instance details Defined in Futhark.IR.GPU type LParamInfo GPU = Type
type LetDec GPU Source # |
Instance details Defined in Futhark.IR.GPU type LetDec GPU = Type
type OpC GPU Source # |
Instance details Defined in Futhark.IR.GPU type OpC GPU = HostOp SOAC
type RetType GPU Source # |
Instance details Defined in Futhark.IR.GPU type RetType GPU = DeclExtType
type SegOpLevel GPU Source # |
Instance details Defined in Futhark.IR.GPU type SegOpLevel GPU = SegLevel
type SegOpLevel (Wise GPU) Source # |
Instance details Defined in Futhark.IR.GPU.Simplify type SegOpLevel (Wise GPU) = SegLevel

# Module re-exports

module Futhark.IR.Prop

module Futhark.IR.Traversals

module Futhark.IR.Pretty

module Futhark.IR.Syntax

module Futhark.IR.GPU.Op

module Futhark.IR.GPU.Sizes

data SOAC rep Source #

A second-order array combinator (SOAC).

Constructors

Stream SubExp [VName] [SubExp] (Lambda rep) |

Scatter SubExp [VName] (ScatterSpec VName) (Lambda rep)

    Scatter length inputs lambda spec

Scatter maps values from a set of input arrays to indices and values of a set of output arrays. It is able to write multiple values to multiple outputs each of which may have multiple dimensions.

inputs is a list of input arrays, all having size length, elements of which are applied to the lambda function. For instance, if there are two arrays, lambda will get two values as input, one from each array.

spec specifies the result of the lambda and which arrays to write to.

lambda is a function that takes inputs from inputs and returns values according to spec. It returns values in the following manner:

index_0, index_1, ..., index_n, value_0, value_1, ..., value_m

For each output in spec, lambda returns i * j index values and j output values, where i is the number of dimensions (rank) of the given output, and j is the number of output values written to the given output.

For example, given the following scatter specification:

([x1, y1, z1
  , 2, arr1), ([x2, y2], 1, arr2)]

lambda will produce 6 (3 * 2) index values and 2 output values for arr1, and 2 (2 * 1) index values and 1 output value for arr2. Additionally, the results are grouped, so the first 6 index values will correspond to the first two output values, and so on. For this example, lambda should return a total of 11 values, 8 index values and 3 output values. See also `splitScatterResults`.

Hist SubExp [VName] [HistOp rep] (Lambda rep)

    Hist length arrays dest-arrays-and-ops fun

The final lambda produces indexes and values for the `HistOp`s.

JVP [SubExp] [SubExp] (Lambda rep) |
VJP [SubExp] [SubExp] (Lambda rep) |
Screma SubExp [VName] (ScremaForm rep) | A combination of scan, reduction, and map. The first `SubExp` is the size of the input arrays.

#### Instances

Instances details

CanBeAliased SOAC Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods addOpAliases :: AliasableRep rep => AliasTable -> SOAC rep -> SOAC (Aliases rep) Source #
IsOp SOAC Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods safeOp :: ASTRep rep => SOAC rep -> Bool Source # cheapOp :: ASTRep rep => SOAC rep -> Bool Source # opDependencies :: ASTRep rep => SOAC rep -> [Names] Source #
AliasedOp SOAC Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods opAliases :: Aliased rep => SOAC rep -> [Names] Source # consumedInOp :: Aliased rep => SOAC rep -> Names Source #
TypedOp SOAC Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods opType :: HasScope rep m => SOAC rep -> m [ExtType] Source #
RephraseOp SOAC Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods rephraseInOp :: Monad m => Rephraser m from to -> SOAC from -> m (SOAC to) Source #
CanBeWise SOAC Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods addOpWisdom :: Informing rep => SOAC rep -> SOAC (Wise rep) Source #
OpMetrics (Op rep) => OpMetrics (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods opMetrics :: SOAC rep -> MetricsM () Source #
RepTypes rep => IndexOp (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods indexOp :: (ASTRep rep0, IndexOp (Op rep0)) => SymbolTable rep0 -> Int -> SOAC rep -> [TPrimExp Int64 VName] -> Maybe Indexed Source #
ASTRep rep => FreeIn (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods freeIn' :: SOAC rep -> FV Source #
(AliasableRep rep, CSEInOp (Op (Aliases rep))) => CSEInOp (SOAC (Aliases rep)) Source # |
Instance details Defined in Futhark.Optimise.CSE Methods cseInOp :: SOAC (Aliases rep) -> CSEM rep0 (SOAC (Aliases rep))
ASTRep rep => Rename (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods rename :: SOAC rep -> RenameM (SOAC rep) Source #
ASTRep rep => Substitute (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods substituteNames :: Map VName VName -> SOAC rep -> SOAC rep Source #
RepTypes rep => Show (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods showsPrec :: Int -> SOAC rep -> ShowS Source # show :: SOAC rep -> String Source # showList :: [SOAC rep] -> ShowS Source #
RepTypes rep => Eq (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods (==) :: SOAC rep -> SOAC rep -> Bool Source # (/=) :: SOAC rep -> SOAC rep -> Bool Source #
RepTypes rep => Ord (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods compare :: SOAC rep -> SOAC rep -> Ordering Source # (<) :: SOAC rep -> SOAC rep -> Bool Source # (<=) :: SOAC rep -> SOAC rep -> Bool Source # (>) :: SOAC rep -> SOAC rep -> Bool Source # (>=) :: SOAC rep -> SOAC rep -> Bool Source # max :: SOAC rep -> SOAC rep -> SOAC rep Source # min :: SOAC rep -> SOAC rep -> SOAC rep Source #
PrettyRep rep => Pretty (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods pretty :: SOAC rep -> Doc ann Source # prettyList :: [SOAC rep] -> Doc ann Source #

data Scan rep Source #

How to compute a single scan result.

Constructors

Scan |

Fields

- scanLambda :: Lambda rep
- scanNeutral :: [SubExp]

#### Instances

Instances details

ASTRep rep => FreeIn (Scan rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods freeIn' :: Scan rep -> FV Source #
RepTypes rep => Show (Scan rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods showsPrec :: Int -> Scan rep -> ShowS Source # show :: Scan rep -> String Source # showList :: [Scan rep] -> ShowS Source #
RepTypes rep => Eq (Scan rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods (==) :: Scan rep -> Scan rep -> Bool Source # (/=) :: Scan rep -> Scan rep -> Bool Source #
RepTypes rep => Ord (Scan rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods compare :: Scan rep -> Scan rep -> Ordering Source # (<) :: Scan rep -> Scan rep -> Bool Source # (<=) :: Scan rep -> Scan rep -> Bool Source # (>) :: Scan rep -> Scan rep -> Bool Source # (>=) :: Scan rep -> Scan rep -> Bool Source # max :: Scan rep -> Scan rep -> Scan rep Source # min :: Scan rep -> Scan rep -> Scan rep Source #
PrettyRep rep => Pretty (Scan rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods pretty :: Scan rep -> Doc ann Source # prettyList :: [Scan rep] -> Doc ann Source #

data Reduce rep Source #

How to compute a single reduction result.

Constructors

Reduce |

Fields

- redComm :: Commutativity
- redLambda :: Lambda rep
- redNeutral :: [SubExp]

#### Instances

Instances details

ASTRep rep => FreeIn (Reduce rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods freeIn' :: Reduce rep -> FV Source #
RepTypes rep => Show (Reduce rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods showsPrec :: Int -> Reduce rep -> ShowS Source # show :: Reduce rep -> String Source # showList :: [Reduce rep] -> ShowS Source #
RepTypes rep => Eq (Reduce rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods (==) :: Reduce rep -> Reduce rep -> Bool Source # (/=) :: Reduce rep -> Reduce rep -> Bool Source #
RepTypes rep => Ord (Reduce rep) Source # |

Instance details

Defined in Futhark.IR.SOACS.SOAC

Methods

compare :: Reduce rep -> Reduce rep -> Ordering Source #

(<) :: Reduce rep -> Reduce rep -> Bool Source #

(<=) :: Reduce rep -> Reduce rep -> Bool Source #

(>) :: Reduce rep -> Reduce rep -> Bool Source #

(>=) :: Reduce rep -> Reduce rep -> Bool Source #

max :: Reduce rep -> Reduce rep -> Reduce rep Source #

min :: Reduce rep -> Reduce rep -> Reduce rep Source #

PrettyRep rep => Pretty (Reduce rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods pretty :: Reduce rep -> Doc ann Source # prettyList :: [Reduce rep] -> Doc ann Source #

data ScremaForm rep Source #

The essential parts of a `Screma` factored out (everything except the input arrays).

Constructors

ScremaForm |

Fields

- scremaLambda :: Lambda rep

  The "main" lambda of the Screma. For a map, this is equivalent to `isMapSOAC`. Note that the meaning of the return value of this lambda depends crucially on exactly which Screma this is. The parameters will correspond exactly to elements of the input arrays, however.

- scremaScans :: [Scan rep]
- scremaReduces :: [Reduce rep]

#### Instances

Instances details

ASTRep rep => FreeIn (ScremaForm rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods freeIn' :: ScremaForm rep -> FV Source #
RepTypes rep => Show (ScremaForm rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods showsPrec :: Int -> ScremaForm rep -> ShowS Source # show :: ScremaForm rep -> String Source # showList :: [ScremaForm rep] -> ShowS Source #
RepTypes rep => Eq (ScremaForm rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods (==) :: ScremaForm rep -> ScremaForm rep -> Bool Source # (/=) :: ScremaForm rep -> ScremaForm rep -> Bool Source #
RepTypes rep => Ord (ScremaForm rep) Source # |

Instance details

Defined in Futhark.IR.SOACS.SOAC

Methods

compare :: ScremaForm rep -> ScremaForm rep -> Ordering Source #

(<) :: ScremaForm rep -> ScremaForm rep -> Bool Source #

(<=) :: ScremaForm rep -> ScremaForm rep -> Bool Source #

(>) :: ScremaForm rep -> ScremaForm rep -> Bool Source #

(>=) :: ScremaForm rep -> ScremaForm rep -> Bool Source #

max :: ScremaForm rep -> ScremaForm rep -> ScremaForm rep Source #

min :: ScremaForm rep -> ScremaForm rep -> ScremaForm rep Source #

type ScatterSpec v = [(Shape, Int, v)] Source #

How the results of a scatter operation should be written. Each element of the list consists of a `v` (often a `VName`) specifying which array to scatter to, a `Shape` describing the shape of that array, and an `Int` describing how many elements should be written to that array for each invocation of the scatter.

scremaType :: SubExp -> ScremaForm rep -> [Type] Source #

The types produced by a single `Screma`, given the size of the input array.

scanResults :: [Scan rep] -> Int Source #

How many reduction results are produced by these `Scan`s?

singleScan :: Buildable rep => [Scan rep] -> Scan rep Source #

Combine multiple scan operators to a single operator.

redResults :: [Reduce rep] -> Int Source #

How many reduction results are produced by these `Reduce`s?

singleReduce :: Buildable rep => [Reduce rep] -> Reduce rep Source #

Combine multiple reduction operators to a single operator.

soacType :: Typed (LParamInfo rep) => SOAC rep -> [Type] Source #

The type of a SOAC.

typeCheckSOAC :: Checkable rep => SOAC (Aliases rep) -> TypeM rep () Source #

Type-check a SOAC.

mkIdentityLambda :: (Buildable rep, MonadFreshNames m) => [Type] -> m (Lambda rep) Source #

Construct a lambda that takes parameters of the given types and simply returns them unchanged.

isIdentityLambda :: Lambda rep -> Bool Source #

Is the given lambda an identity lambda?

nilFn :: Buildable rep => Lambda rep Source #

A lambda with no parameters that returns no values.

scanomapSOAC :: [Scan rep] -> Lambda rep -> ScremaForm rep Source #

Construct a Screma with possibly multiple scans, and the given map function.

redomapSOAC :: [Reduce rep] -> Lambda rep -> ScremaForm rep Source #

Construct a Screma with possibly multiple reductions, and the given map function.

scanSOAC :: (Buildable rep, MonadFreshNames m) => [Scan rep] -> m (ScremaForm rep) Source #

Construct a Screma with possibly multiple scans, and identity map function.

reduceSOAC :: (Buildable rep, MonadFreshNames m) => [Reduce rep] -> m (ScremaForm rep) Source #

Construct a Screma with possibly multiple reductions, and identity map function.

mapSOAC :: Lambda rep -> ScremaForm rep Source #

Construct a Screma corresponding to a map.

isScanomapSOAC :: ScremaForm rep -> Maybe ([Scan rep], Lambda rep) Source #

Does this Screma correspond to a scan-map composition?

isRedomapSOAC :: ScremaForm rep -> Maybe ([Reduce rep], Lambda rep) Source #

Does this Screma correspond to a reduce-map composition?

isScanSOAC :: ScremaForm rep -> Maybe [Scan rep] Source #

Does this Screma correspond to pure scan?

isReduceSOAC :: ScremaForm rep -> Maybe [Reduce rep] Source #

Does this Screma correspond to a pure reduce?

isMapSOAC :: ScremaForm rep -> Maybe (Lambda rep) Source #

Does this Screma correspond to a simple map, without any reduction or scan results?

ppScrema :: (PrettyRep rep, Pretty inp) => SubExp -> [inp] -> ScremaForm rep -> Doc ann Source #

Prettyprint the given Screma.

ppHist :: (PrettyRep rep, Pretty inp) => SubExp -> [inp] -> [HistOp rep] -> Lambda rep -> Doc ann Source #

Prettyprint the given histogram operation.

ppStream :: (PrettyRep rep, Pretty inp) => SubExp -> [inp] -> [SubExp] -> Lambda rep -> Doc ann Source #

Prettyprint the given Stream.

ppScatter :: (PrettyRep rep, Pretty inp) => SubExp -> [inp] -> [(Shape, Int, VName)] -> Lambda rep -> Doc ann Source #

Prettyprint the given Scatter.

groupScatterResults :: ScatterSpec array -> [a] -> [(Shape, array, [([a], a)])] Source #

    groupScatterResults specification results

Blocks the index values and result values of results according to the specification.

This function is used for extracting and grouping the results of a scatter. In the SOACS representation, the lambda inside a `Scatter` returns all indices and values as one big list. This function groups each value with its corresponding indices (as determined by the `Shape` of the output array).

The elements of the resulting list correspond to the shape and name of the output parameters, in addition to a list of values written to that output parameter, along with the array indices marking where to write them to.

See `Scatter` for more information.

groupScatterResults' :: [(Shape, Int, array)] -> [a] -> [([a], a)] Source #

    groupScatterResults' specification results

Blocks the index values and result values of results according to the specification. This is the simpler version of `groupScatterResults`, which doesn't return any information about shapes or output arrays.

See `groupScatterResults` for more information,

splitScatterResults :: [(Shape, Int, array)] -> [a] -> ([a], [a]) Source #

    splitScatterResults specification results

Splits the results array into indices and values according to the specification.

See `groupScatterResults` for more information.

data SOACMapper frep trep (m :: Type -> Type) Source #

Like `Mapper`, but just for `SOAC`s.

Constructors

SOACMapper |

Fields

- mapOnSOACSubExp :: SubExp -> m SubExp
- mapOnSOACLambda :: Lambda frep -> m (Lambda trep)
- mapOnSOACVName :: VName -> m VName

identitySOACMapper :: forall rep (m :: Type -> Type). Monad m => SOACMapper rep rep m Source #

A mapper that simply returns the SOAC verbatim.

mapSOACM :: Monad m => SOACMapper frep trep m -> SOAC frep -> m (SOAC trep) Source #

Map a monadic action across the immediate children of a SOAC. The mapping does not descend recursively into subexpressions and is done left-to-right.

traverseSOACStms :: Monad m => OpStmsTraverser m (SOAC rep) rep Source #

A helper for defining `TraverseOpStms`.