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

Safe Haskell | None
Language | GHC2021

Futhark.Pass.ExplicitAllocations

Contents

- Module re-exports

Description

A generic transformation for adding memory allocations to a Futhark program. Specialised by specific representations in submodules.

Synopsis

- explicitAllocationsGeneric :: forall fromrep torep (inner :: Type -> Type). Allocable fromrep torep inner => Space -> (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Pass fromrep torep
- explicitAllocationsInStmsGeneric :: forall m torep fromrep (inner :: Type -> Type). (MonadFreshNames m, HasScope torep m, Allocable fromrep torep inner) => Space -> (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Stms fromrep -> m (Stms torep)
- data ExpHint
  - = NoHint
  - | Hint LMAD Space
- defaultExpHints :: (ASTRep rep, HasScope rep m) => Exp rep -> m [ExpHint]
- askDefaultSpace :: AllocM fromrep torep Space
- type Allocable fromrep torep (inner :: Type -> Type) = (PrettyRep fromrep, PrettyRep torep, Mem torep inner, LetDec torep ~ LetDecMem, FParamInfo fromrep ~ DeclType, LParamInfo fromrep ~ Type, BranchType fromrep ~ ExtType, RetType fromrep ~ DeclExtType, BodyDec fromrep ~ (), BodyDec torep ~ (), ExpDec torep ~ (), SizeSubst (inner torep), BuilderOps torep)
- data AllocM fromrep torep a
- data AllocEnv fromrep torep = AllocEnv {
  - allocSpace :: Space
  - envConsts :: Set VName
  - allocInOp :: Op fromrep -> AllocM fromrep torep (Op torep)
  - envExpHints :: Exp torep -> AllocM fromrep torep [ExpHint]
  }
- class SizeSubst op where
  - opIsConst :: op -> Bool
- allocInStms :: forall fromrep torep (inner :: Type -> Type) a. Allocable fromrep torep inner => Stms fromrep -> AllocM fromrep torep a -> AllocM fromrep torep a
- allocForArray :: forall fromrep torep (inner :: Type -> Type). Allocable fromrep torep inner => Type -> Space -> AllocM fromrep torep VName
- simplifiable :: (SimplifiableRep rep, LetDec rep ~ LetDecMem, ExpDec rep ~ (), BodyDec rep ~ (), Mem (Wise rep) inner, CanBeWise inner, RephraseOp inner, IsOp inner, OpReturns inner, AliasedOp inner, IndexOp (inner (Wise rep))) => (inner (Wise rep) -> UsageTable) -> (inner (Wise rep) -> SimpleM rep (inner (Wise rep), Stms (Wise rep))) -> SimpleOps rep
- mkLetNamesB' :: forall m (inner :: Type -> Type). (LetDec (Rep m) ~ LetDecMem, Mem (Rep m) inner, MonadBuilder m, ExpDec (Rep m) ~ ()) => Space -> ExpDec (Rep m) -> [VName] -> Exp (Rep m) -> m (Stm (Rep m))
- mkLetNamesB'' :: forall rep (inner :: Type -> Type) m. (Mem rep inner, LetDec rep ~ LetDecMem, OpReturns inner, ExpDec rep ~ (), Rep m ~ Wise rep, HasScope (Wise rep) m, MonadBuilder m, AliasedOp inner, RephraseOp (MemOp inner), CanBeWise inner, ASTConstraints (inner (Wise rep))) => Space -> [VName] -> Exp (Wise rep) -> m (Stm (Wise rep))
- module Control.Monad.Reader
- module Futhark.MonadFreshNames
- module Futhark.Pass
- module Futhark.Tools

# Documentation

explicitAllocationsGeneric :: forall fromrep torep (inner :: Type -> Type). Allocable fromrep torep inner => Space -> (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Pass fromrep torep Source #

explicitAllocationsInStmsGeneric :: forall m torep fromrep (inner :: Type -> Type). (MonadFreshNames m, HasScope torep m, Allocable fromrep torep inner) => Space -> (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Stms fromrep -> m (Stms torep) Source #

data ExpHint Source #

Constructors

NoHint |
Hint LMAD Space |

defaultExpHints :: (ASTRep rep, HasScope rep m) => Exp rep -> m [ExpHint] Source #

askDefaultSpace :: AllocM fromrep torep Space Source #

The space in which we allocate memory if we have no other preferences or constraints.

type Allocable fromrep torep (inner :: Type -> Type) = (PrettyRep fromrep, PrettyRep torep, Mem torep inner, LetDec torep ~ LetDecMem, FParamInfo fromrep ~ DeclType, LParamInfo fromrep ~ Type, BranchType fromrep ~ ExtType, RetType fromrep ~ DeclExtType, BodyDec fromrep ~ (), BodyDec torep ~ (), ExpDec torep ~ (), SizeSubst (inner torep), BuilderOps torep) Source #

data AllocM fromrep torep a Source #

Monad for adding allocations to an entire program.

#### Instances

Instances details

ASTRep torep => HasScope torep (AllocM fromrep torep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods lookupType :: VName -> AllocM fromrep torep Type Source # lookupInfo :: VName -> AllocM fromrep torep (NameInfo torep) Source # askScope :: AllocM fromrep torep (Scope torep) Source # asksScope :: (Scope torep -> a) -> AllocM fromrep torep a Source #
ASTRep torep => LocalScope torep (AllocM fromrep torep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods localScope :: Scope torep -> AllocM fromrep torep a -> AllocM fromrep torep a Source #
Allocable fromrep torep inner => MonadBuilder (AllocM fromrep torep) Source # |

Instance details

Defined in Futhark.Pass.ExplicitAllocations

Associated Types

type Rep (AllocM fromrep torep) |
Instance details Defined in Futhark.Pass.ExplicitAllocations type Rep (AllocM fromrep torep) = torep

Methods

mkExpDecM :: Pat (LetDec (Rep (AllocM fromrep torep))) -> Exp (Rep (AllocM fromrep torep)) -> AllocM fromrep torep (ExpDec (Rep (AllocM fromrep torep))) Source #

mkBodyM :: Stms (Rep (AllocM fromrep torep)) -> Result -> AllocM fromrep torep (Body (Rep (AllocM fromrep torep))) Source #

mkLetNamesM :: [VName] -> Exp (Rep (AllocM fromrep torep)) -> AllocM fromrep torep (Stm (Rep (AllocM fromrep torep))) Source #

addStm :: Stm (Rep (AllocM fromrep torep)) -> AllocM fromrep torep () Source #

addStms :: Stms (Rep (AllocM fromrep torep)) -> AllocM fromrep torep () Source #

collectStms :: AllocM fromrep torep a -> AllocM fromrep torep (a, Stms (Rep (AllocM fromrep torep))) Source #

certifying :: Certs -> AllocM fromrep torep a -> AllocM fromrep torep a Source #

MonadFreshNames (AllocM fromrep torep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods getNameSource :: AllocM fromrep torep VNameSource Source # putNameSource :: VNameSource -> AllocM fromrep torep () Source #
Applicative (AllocM fromrep torep) Source # |

Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

pure :: a -> AllocM fromrep torep a Source #

(<*>) :: AllocM fromrep torep (a -> b) -> AllocM fromrep torep a -> AllocM fromrep torep b Source #

liftA2 :: (a -> b -> c) -> AllocM fromrep torep a -> AllocM fromrep torep b -> AllocM fromrep torep c Source #

(*>) :: AllocM fromrep torep a -> AllocM fromrep torep b -> AllocM fromrep torep b Source #

(<*) :: AllocM fromrep torep a -> AllocM fromrep torep b -> AllocM fromrep torep a Source #

Functor (AllocM fromrep torep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods fmap :: (a -> b) -> AllocM fromrep torep a -> AllocM fromrep torep b Source # (<$) :: a -> AllocM fromrep torep b -> AllocM fromrep torep a Source #
Monad (AllocM fromrep torep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods (>>=) :: AllocM fromrep torep a -> (a -> AllocM fromrep torep b) -> AllocM fromrep torep b Source # (>>) :: AllocM fromrep torep a -> AllocM fromrep torep b -> AllocM fromrep torep b Source # return :: a -> AllocM fromrep torep a Source #
MonadReader (AllocEnv fromrep torep) (AllocM fromrep torep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods ask :: AllocM fromrep torep (AllocEnv fromrep torep) Source # local :: (AllocEnv fromrep torep -> AllocEnv fromrep torep) -> AllocM fromrep torep a -> AllocM fromrep torep a Source # reader :: (AllocEnv fromrep torep -> a) -> AllocM fromrep torep a Source #
type Rep (AllocM fromrep torep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations type Rep (AllocM fromrep torep) = torep

data AllocEnv fromrep torep Source #

Constructors

AllocEnv |

Fields

- allocSpace :: Space

  When allocating memory, put it in this memory space. This is primarily used to ensure that group-wide statements store their results in shared memory.

- envConsts :: Set VName

  The set of names that are known to be constants at kernel compile time.

- allocInOp :: Op fromrep -> AllocM fromrep torep (Op torep)
- envExpHints :: Exp torep -> AllocM fromrep torep [ExpHint]

#### Instances

Instances details

MonadReader (AllocEnv fromrep torep) (AllocM fromrep torep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods ask :: AllocM fromrep torep (AllocEnv fromrep torep) Source # local :: (AllocEnv fromrep torep -> AllocEnv fromrep torep) -> AllocM fromrep torep a -> AllocM fromrep torep a Source # reader :: (AllocEnv fromrep torep -> a) -> AllocM fromrep torep a Source #

class SizeSubst op where Source #

Minimal complete definition

Nothing

Methods

opIsConst :: op -> Bool Source #

#### Instances

Instances details

SizeSubst (HostOp rep op) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations.GPU Methods opIsConst :: HostOp rep op -> Bool Source #
SizeSubst (MCOp rep op) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations.MC Methods opIsConst :: MCOp rep op -> Bool Source #
SizeSubst (op rep) => SizeSubst (MemOp op rep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods opIsConst :: MemOp op rep -> Bool Source #
SizeSubst (NoOp rep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations Methods opIsConst :: NoOp rep -> Bool Source #
SizeSubst (SegOp lvl rep) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations.SegOp Methods opIsConst :: SegOp lvl rep -> Bool Source #

allocInStms :: forall fromrep torep (inner :: Type -> Type) a. Allocable fromrep torep inner => Stms fromrep -> AllocM fromrep torep a -> AllocM fromrep torep a Source #

allocForArray :: forall fromrep torep (inner :: Type -> Type). Allocable fromrep torep inner => Type -> Space -> AllocM fromrep torep VName Source #

Allocate memory for a value of the given type.

simplifiable :: (SimplifiableRep rep, LetDec rep ~ LetDecMem, ExpDec rep ~ (), BodyDec rep ~ (), Mem (Wise rep) inner, CanBeWise inner, RephraseOp inner, IsOp inner, OpReturns inner, AliasedOp inner, IndexOp (inner (Wise rep))) => (inner (Wise rep) -> UsageTable) -> (inner (Wise rep) -> SimpleM rep (inner (Wise rep), Stms (Wise rep))) -> SimpleOps rep Source #

mkLetNamesB' :: forall m (inner :: Type -> Type). (LetDec (Rep m) ~ LetDecMem, Mem (Rep m) inner, MonadBuilder m, ExpDec (Rep m) ~ ()) => Space -> ExpDec (Rep m) -> [VName] -> Exp (Rep m) -> m (Stm (Rep m)) Source #

mkLetNamesB'' :: forall rep (inner :: Type -> Type) m. (Mem rep inner, LetDec rep ~ LetDecMem, OpReturns inner, ExpDec rep ~ (), Rep m ~ Wise rep, HasScope (Wise rep) m, MonadBuilder m, AliasedOp inner, RephraseOp (MemOp inner), CanBeWise inner, ASTConstraints (inner (Wise rep))) => Space -> [VName] -> Exp (Wise rep) -> m (Stm (Wise rep)) Source #

# Module re-exports

module Control.Monad.Reader

module Futhark.MonadFreshNames

module Futhark.Pass

module Futhark.Tools