futhark-0.25.15: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
LanguageGHC2021

Futhark.Pass.ExtractKernels.Interchange

Description

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

Documentation

data SeqLoop Source #

An encoding of a sequential do-loop with no existential context, alongside its result pattern.

Constructors

SeqLoop [Int] (Pat Type) [(FParam SOACS, SubExp)] LoopForm (Body SOACS) 

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.

data Branch Source #

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.

Constructors

WithAccStm [Int] (Pat Type) [(Shape, [VName], Maybe (Lambda SOACS, [SubExp]))] (Lambda SOACS) 

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.