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, Allocator torep (AllocM fromrep torep)) => (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) => (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 = (PrettyRep fromrep, PrettyRep torep, Mem torep, FParamInfo fromrep ~ DeclType, LParamInfo fromrep ~ Type, BranchType fromrep ~ ExtType, RetType fromrep ~ DeclExtType, BodyDec fromrep ~ (), BodyDec torep ~ (), ExpDec torep ~ (), SizeSubst (Op torep), BinderOps torep)
- class (MonadFreshNames m, LocalScope rep m, Mem rep) => Allocator rep m where
- addAllocStm :: AllocStm -> m ()
- askDefaultSpace :: m Space
- dimAllocationSize :: SubExp -> m SubExp
- askConsts :: m (Set VName)
- expHints :: Exp rep -> m [ExpHint]
- data AllocM fromrep torep a
- data AllocEnv fromrep torep = AllocEnv {}
- class SizeSubst op where
- opSizeSubst :: PatternT dec -> op -> ChunkMap
- opIsConst :: op -> Bool
- allocInStms :: Allocable fromrep torep => Stms fromrep -> AllocM fromrep torep a -> AllocM fromrep torep a
- allocForArray :: Allocator rep m => Type -> Space -> m VName
- simplifiable :: (SimplifiableRep rep, ExpDec rep ~ (), BodyDec rep ~ (), Op rep ~ MemOp inner, Allocator rep (PatAllocM rep)) => (OpWithWisdom inner -> UsageTable) -> (inner -> SimpleM rep (OpWithWisdom inner, Stms (Wise rep))) -> SimpleOps rep
- arraySizeInBytesExp :: Type -> PrimExp VName
- mkLetNamesB' :: (Op (Rep m) ~ MemOp inner, MonadBinder m, ExpDec (Rep m) ~ (), Allocator (Rep m) (PatAllocM (Rep m))) => ExpDec (Rep m) -> [VName] -> Exp (Rep m) -> m (Stm (Rep m))
- mkLetNamesB'' :: (Op (Rep m) ~ MemOp inner, ExpDec rep ~ (), HasScope (Wise rep) m, Allocator rep (PatAllocM rep), MonadBinder m, CanBeWise (Op rep)) => [VName] -> Exp (Wise rep) -> m (Stm (Wise rep))
- module Control.Monad.Reader
- module Futhark.MonadFreshNames
- module Futhark.Pass
- module Futhark.Tools
Documentation
explicitAllocationsGeneric :: (Allocable fromrep torep, Allocator torep (AllocM fromrep torep)) => (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) => (Op fromrep -> AllocM fromrep torep (Op torep)) -> (Exp torep -> AllocM fromrep torep [ExpHint]) -> Stms fromrep -> m (Stms torep) Source #
type Allocable fromrep torep = (PrettyRep fromrep, PrettyRep torep, Mem torep, FParamInfo fromrep ~ DeclType, LParamInfo fromrep ~ Type, BranchType fromrep ~ ExtType, RetType fromrep ~ DeclExtType, BodyDec fromrep ~ (), BodyDec torep ~ (), ExpDec torep ~ (), SizeSubst (Op torep), BinderOps torep) Source #
class (MonadFreshNames m, LocalScope rep m, Mem rep) => Allocator rep m where Source #
addAllocStm :: AllocStm -> m () Source #
default addAllocStm :: (Allocable fromrep rep, m ~ AllocM fromrep rep) => AllocStm -> m () Source #
askDefaultSpace :: m Space Source #
dimAllocationSize :: SubExp -> m SubExp Source #
The subexpression giving the number of elements we should
allocate space for. See ChunkMap
comment.
askConsts :: m (Set VName) Source #
Get those names that are known to be constants at run-time.
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 # | |
Allocable fromrep torep => Allocator torep (AllocM fromrep torep) Source # | |
Defined in Futhark.Pass.ExplicitAllocations | |
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, Allocator torep (AllocM fromrep torep)) => MonadBinder (AllocM fromrep torep) Source # | |
Defined in Futhark.Pass.ExplicitAllocations mkExpDecM :: Pattern (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 :: Certificates -> 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 => Stms fromrep -> AllocM fromrep torep a -> AllocM fromrep torep a Source #
allocForArray :: Allocator rep m => Type -> Space -> m VName Source #
Allocate memory for a value of the given type.
simplifiable :: (SimplifiableRep rep, ExpDec rep ~ (), BodyDec rep ~ (), Op rep ~ MemOp inner, Allocator rep (PatAllocM rep)) => (OpWithWisdom inner -> UsageTable) -> (inner -> SimpleM rep (OpWithWisdom inner, Stms (Wise rep))) -> SimpleOps rep Source #
mkLetNamesB' :: (Op (Rep m) ~ MemOp inner, MonadBinder m, ExpDec (Rep m) ~ (), Allocator (Rep m) (PatAllocM (Rep m))) => ExpDec (Rep m) -> [VName] -> Exp (Rep m) -> m (Stm (Rep m)) Source #
mkLetNamesB'' :: (Op (Rep m) ~ MemOp inner, ExpDec rep ~ (), HasScope (Wise rep) m, Allocator rep (PatAllocM rep), MonadBinder m, CanBeWise (Op rep)) => [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