Safe Haskell | None |
---|---|
Language | Haskell2010 |
A generic transformation for adding memory allocations to a Futhark program. Specialised by specific representations in submodules.
Synopsis
- explicitAllocationsGeneric :: Allocable fromrep torep inner => (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Pass fromrep torep
- explicitAllocationsInStmsGeneric :: (MonadFreshNames m, HasScope torep m, Allocable fromrep torep inner) => (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Stms fromrep -> m (Stms torep)
- data ExpHint
- defaultExpHints :: (Monad m, ASTRep rep) => Exp rep -> m [ExpHint]
- type Allocable fromrep torep inner = (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, BuilderOps torep)
- data AllocM fromrep torep a
- data AllocEnv fromrep torep = AllocEnv {}
- class SizeSubst op where
- opSizeSubst :: Pat dec -> op -> ChunkMap
- opIsConst :: op -> Bool
- allocInStms :: Allocable fromrep torep inner => Stms fromrep -> AllocM fromrep torep a -> AllocM fromrep torep a
- allocForArray :: Allocable fromrep torep inner => Type -> Space -> AllocM fromrep torep VName
- simplifiable :: (SimplifiableRep rep, ExpDec rep ~ (), BodyDec rep ~ (), Mem rep inner) => (OpWithWisdom inner -> UsageTable) -> (OpWithWisdom inner -> SimpleM rep (OpWithWisdom inner, Stms (Wise rep))) -> SimpleOps rep
- arraySizeInBytesExp :: Type -> PrimExp VName
- mkLetNamesB' :: (LetDec (Rep m) ~ LetDecMem, Mem (Rep m) inner, MonadBuilder m, ExpDec (Rep m) ~ ()) => ExpDec (Rep m) -> [VName] -> Exp (Rep m) -> m (Stm (Rep m))
- mkLetNamesB'' :: (BuilderOps rep, Mem rep inner, LetDec rep ~ LetDecMem, OpReturns (OpWithWisdom inner), ExpDec rep ~ (), Rep m ~ Wise rep, HasScope (Wise rep) m, MonadBuilder m, CanBeWise inner) => [VName] -> Exp (Wise rep) -> m (Stm (Wise rep))
- dimAllocationSize :: ChunkMap -> SubExp -> SubExp
- type ChunkMap = Map VName SubExp
- module Control.Monad.Reader
- module Futhark.MonadFreshNames
- module Futhark.Pass
- module Futhark.Tools
Documentation
explicitAllocationsGeneric :: Allocable fromrep torep inner => (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Pass fromrep torep Source #
explicitAllocationsInStmsGeneric :: (MonadFreshNames m, HasScope torep m, Allocable fromrep torep inner) => (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Stms fromrep -> m (Stms torep) Source #
type Allocable fromrep torep inner = (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, BuilderOps torep) Source #
data AllocM fromrep torep a Source #
Monad for adding allocations to an entire program.
Instances
ASTRep torep => LocalScope torep (AllocM fromrep torep) Source # | |
Defined in Futhark.Pass.ExplicitAllocations | |
ASTRep torep => HasScope torep (AllocM fromrep torep) Source # | |
Monad (AllocM fromrep torep) Source # | |
Functor (AllocM fromrep torep) Source # | |
Applicative (AllocM fromrep torep) Source # | |
Defined in Futhark.Pass.ExplicitAllocations pure :: a -> AllocM fromrep torep a # (<*>) :: AllocM fromrep torep (a -> b) -> AllocM fromrep torep a -> AllocM fromrep torep b # liftA2 :: (a -> b -> c) -> AllocM fromrep torep a -> AllocM fromrep torep b -> AllocM fromrep torep c # (*>) :: AllocM fromrep torep a -> AllocM fromrep torep b -> AllocM fromrep torep b # (<*) :: AllocM fromrep torep a -> AllocM fromrep torep b -> AllocM fromrep torep a # | |
MonadFreshNames (AllocM fromrep torep) Source # | |
Defined in Futhark.Pass.ExplicitAllocations getNameSource :: AllocM fromrep torep VNameSource Source # putNameSource :: VNameSource -> AllocM fromrep torep () Source # | |
Allocable fromrep torep inner => MonadBuilder (AllocM fromrep torep) Source # | |
Defined in Futhark.Pass.ExplicitAllocations 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 # | |
MonadReader (AllocEnv fromrep torep) (AllocM fromrep torep) Source # | |
type Rep (AllocM fromrep torep) Source # | |
Defined in Futhark.Pass.ExplicitAllocations |
data AllocEnv fromrep torep Source #
AllocEnv | |
|
Instances
MonadReader (AllocEnv fromrep torep) (AllocM fromrep torep) Source # | |
allocInStms :: Allocable fromrep torep inner => Stms fromrep -> AllocM fromrep torep a -> AllocM fromrep torep a Source #
allocForArray :: Allocable fromrep torep inner => Type -> Space -> AllocM fromrep torep VName Source #
Allocate memory for a value of the given type.
simplifiable :: (SimplifiableRep rep, ExpDec rep ~ (), BodyDec rep ~ (), Mem rep inner) => (OpWithWisdom inner -> UsageTable) -> (OpWithWisdom inner -> SimpleM rep (OpWithWisdom inner, Stms (Wise rep))) -> SimpleOps rep Source #
mkLetNamesB' :: (LetDec (Rep m) ~ LetDecMem, Mem (Rep m) inner, MonadBuilder m, ExpDec (Rep m) ~ ()) => ExpDec (Rep m) -> [VName] -> Exp (Rep m) -> m (Stm (Rep m)) Source #
mkLetNamesB'' :: (BuilderOps rep, Mem rep inner, LetDec rep ~ LetDecMem, OpReturns (OpWithWisdom inner), ExpDec rep ~ (), Rep m ~ Wise rep, HasScope (Wise rep) m, MonadBuilder m, CanBeWise inner) => [VName] -> Exp (Wise rep) -> m (Stm (Wise rep)) Source #
dimAllocationSize :: ChunkMap -> SubExp -> SubExp Source #
The subexpression giving the number of elements we should
allocate space for. See ChunkMap
comment.
type ChunkMap = Map VName SubExp Source #
A mapping from chunk names to their maximum size. XXX FIXME HACK: This is part of a hack to add loop-invariant allocations to reduce kernels, because memory expansion does not use range analysis yet (it should).
Module re-exports
module Control.Monad.Reader
module Futhark.MonadFreshNames
module Futhark.Pass
module Futhark.Tools