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 fromlore tolore, Allocator tolore (AllocM fromlore tolore)) => (Op fromlore -> AllocM fromlore tolore (Op tolore)) -> (Exp tolore -> AllocM fromlore tolore [ExpHint]) -> Pass fromlore tolore
- explicitAllocationsInStmsGeneric :: (MonadFreshNames m, HasScope tolore m, Allocable fromlore tolore) => (Op fromlore -> AllocM fromlore tolore (Op tolore)) -> (Exp tolore -> AllocM fromlore tolore [ExpHint]) -> Stms fromlore -> m (Stms tolore)
- data ExpHint
- defaultExpHints :: (Monad m, ASTLore lore) => Exp lore -> m [ExpHint]
- type Allocable fromlore tolore = (PrettyLore fromlore, PrettyLore tolore, Mem tolore, FParamInfo fromlore ~ DeclType, LParamInfo fromlore ~ Type, BranchType fromlore ~ ExtType, RetType fromlore ~ DeclExtType, BodyDec fromlore ~ (), BodyDec tolore ~ (), ExpDec tolore ~ (), SizeSubst (Op tolore), BinderOps tolore)
- class (MonadFreshNames m, HasScope lore m, Mem lore) => Allocator lore m where
- addAllocStm :: AllocStm -> m ()
- askDefaultSpace :: m Space
- dimAllocationSize :: SubExp -> m SubExp
- askConsts :: m (Set VName)
- expHints :: Exp lore -> m [ExpHint]
- data AllocM fromlore tolore a
- data AllocEnv fromlore tolore = AllocEnv {}
- class SizeSubst op where
- opSizeSubst :: PatternT dec -> op -> ChunkMap
- opIsConst :: op -> Bool
- allocInStms :: Allocable fromlore tolore => Stms fromlore -> (Stms tolore -> AllocM fromlore tolore a) -> AllocM fromlore tolore a
- allocForArray :: Allocator lore m => Type -> Space -> m VName
- simplifiable :: (SimplifiableLore lore, ExpDec lore ~ (), BodyDec lore ~ (), Op lore ~ MemOp inner, Allocator lore (PatAllocM lore)) => (OpWithWisdom inner -> UsageTable) -> (inner -> SimpleM lore (OpWithWisdom inner, Stms (Wise lore))) -> SimpleOps lore
- arraySizeInBytesExp :: Type -> PrimExp VName
- mkLetNamesB' :: (Op (Lore m) ~ MemOp inner, MonadBinder m, ExpDec (Lore m) ~ (), Allocator (Lore m) (PatAllocM (Lore m))) => ExpDec (Lore m) -> [VName] -> Exp (Lore m) -> m (Stm (Lore m))
- mkLetNamesB'' :: (Op (Lore m) ~ MemOp inner, ExpDec lore ~ (), HasScope (Wise lore) m, Allocator lore (PatAllocM lore), MonadBinder m, CanBeWise (Op lore)) => [VName] -> Exp (Wise lore) -> m (Stm (Wise lore))
- module Control.Monad.Reader
- module Futhark.MonadFreshNames
- module Futhark.Pass
- module Futhark.Tools
Documentation
explicitAllocationsGeneric :: (Allocable fromlore tolore, Allocator tolore (AllocM fromlore tolore)) => (Op fromlore -> AllocM fromlore tolore (Op tolore)) -> (Exp tolore -> AllocM fromlore tolore [ExpHint]) -> Pass fromlore tolore Source #
explicitAllocationsInStmsGeneric :: (MonadFreshNames m, HasScope tolore m, Allocable fromlore tolore) => (Op fromlore -> AllocM fromlore tolore (Op tolore)) -> (Exp tolore -> AllocM fromlore tolore [ExpHint]) -> Stms fromlore -> m (Stms tolore) Source #
type Allocable fromlore tolore = (PrettyLore fromlore, PrettyLore tolore, Mem tolore, FParamInfo fromlore ~ DeclType, LParamInfo fromlore ~ Type, BranchType fromlore ~ ExtType, RetType fromlore ~ DeclExtType, BodyDec fromlore ~ (), BodyDec tolore ~ (), ExpDec tolore ~ (), SizeSubst (Op tolore), BinderOps tolore) Source #
class (MonadFreshNames m, HasScope lore m, Mem lore) => Allocator lore m where Source #
addAllocStm :: AllocStm -> m () Source #
default addAllocStm :: (Allocable fromlore lore, m ~ AllocM fromlore lore) => 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.
Instances
Allocable fromlore tolore => Allocator tolore (AllocM fromlore tolore) Source # | |
Defined in Futhark.Pass.ExplicitAllocations addAllocStm :: AllocStm -> AllocM fromlore tolore () Source # askDefaultSpace :: AllocM fromlore tolore Space Source # dimAllocationSize :: SubExp -> AllocM fromlore tolore SubExp Source # askConsts :: AllocM fromlore tolore (Set VName) Source # expHints :: Exp tolore -> AllocM fromlore tolore [ExpHint] Source # |
data AllocM fromlore tolore a Source #
Monad for adding allocations to an entire program.
Instances
ASTLore tolore => LocalScope tolore (AllocM fromlore tolore) Source # | |
Defined in Futhark.Pass.ExplicitAllocations | |
ASTLore tolore => HasScope tolore (AllocM fromlore tolore) Source # | |
Defined in Futhark.Pass.ExplicitAllocations | |
Allocable fromlore tolore => Allocator tolore (AllocM fromlore tolore) Source # | |
Defined in Futhark.Pass.ExplicitAllocations addAllocStm :: AllocStm -> AllocM fromlore tolore () Source # askDefaultSpace :: AllocM fromlore tolore Space Source # dimAllocationSize :: SubExp -> AllocM fromlore tolore SubExp Source # askConsts :: AllocM fromlore tolore (Set VName) Source # expHints :: Exp tolore -> AllocM fromlore tolore [ExpHint] Source # | |
Monad (AllocM fromlore tolore) Source # | |
Functor (AllocM fromlore tolore) Source # | |
Applicative (AllocM fromlore tolore) Source # | |
Defined in Futhark.Pass.ExplicitAllocations pure :: a -> AllocM fromlore tolore a # (<*>) :: AllocM fromlore tolore (a -> b) -> AllocM fromlore tolore a -> AllocM fromlore tolore b # liftA2 :: (a -> b -> c) -> AllocM fromlore tolore a -> AllocM fromlore tolore b -> AllocM fromlore tolore c # (*>) :: AllocM fromlore tolore a -> AllocM fromlore tolore b -> AllocM fromlore tolore b # (<*) :: AllocM fromlore tolore a -> AllocM fromlore tolore b -> AllocM fromlore tolore a # | |
MonadFreshNames (AllocM fromlore tolore) Source # | |
Defined in Futhark.Pass.ExplicitAllocations getNameSource :: AllocM fromlore tolore VNameSource Source # putNameSource :: VNameSource -> AllocM fromlore tolore () Source # | |
(Allocable fromlore tolore, Allocator tolore (AllocM fromlore tolore)) => MonadBinder (AllocM fromlore tolore) Source # | |
Defined in Futhark.Pass.ExplicitAllocations mkExpDecM :: Pattern (Lore (AllocM fromlore tolore)) -> Exp (Lore (AllocM fromlore tolore)) -> AllocM fromlore tolore (ExpDec (Lore (AllocM fromlore tolore))) Source # mkBodyM :: Stms (Lore (AllocM fromlore tolore)) -> Result -> AllocM fromlore tolore (Body (Lore (AllocM fromlore tolore))) Source # mkLetNamesM :: [VName] -> Exp (Lore (AllocM fromlore tolore)) -> AllocM fromlore tolore (Stm (Lore (AllocM fromlore tolore))) Source # addStm :: Stm (Lore (AllocM fromlore tolore)) -> AllocM fromlore tolore () Source # addStms :: Stms (Lore (AllocM fromlore tolore)) -> AllocM fromlore tolore () Source # collectStms :: AllocM fromlore tolore a -> AllocM fromlore tolore (a, Stms (Lore (AllocM fromlore tolore))) Source # certifying :: Certificates -> AllocM fromlore tolore a -> AllocM fromlore tolore a Source # | |
MonadReader (AllocEnv fromlore tolore) (AllocM fromlore tolore) Source # | |
type Lore (AllocM fromlore tolore) Source # | |
Defined in Futhark.Pass.ExplicitAllocations |
data AllocEnv fromlore tolore Source #
AllocEnv | |
|
Instances
MonadReader (AllocEnv fromlore tolore) (AllocM fromlore tolore) Source # | |
allocInStms :: Allocable fromlore tolore => Stms fromlore -> (Stms tolore -> AllocM fromlore tolore a) -> AllocM fromlore tolore a Source #
allocForArray :: Allocator lore m => Type -> Space -> m VName Source #
Allocate memory for a value of the given type.
simplifiable :: (SimplifiableLore lore, ExpDec lore ~ (), BodyDec lore ~ (), Op lore ~ MemOp inner, Allocator lore (PatAllocM lore)) => (OpWithWisdom inner -> UsageTable) -> (inner -> SimpleM lore (OpWithWisdom inner, Stms (Wise lore))) -> SimpleOps lore Source #
mkLetNamesB' :: (Op (Lore m) ~ MemOp inner, MonadBinder m, ExpDec (Lore m) ~ (), Allocator (Lore m) (PatAllocM (Lore m))) => ExpDec (Lore m) -> [VName] -> Exp (Lore m) -> m (Stm (Lore m)) Source #
mkLetNamesB'' :: (Op (Lore m) ~ MemOp inner, ExpDec lore ~ (), HasScope (Wise lore) m, Allocator lore (PatAllocM lore), MonadBinder m, CanBeWise (Op lore)) => [VName] -> Exp (Wise lore) -> m (Stm (Wise lore)) Source #
Module re-exports
module Control.Monad.Reader
module Futhark.MonadFreshNames
module Futhark.Pass
module Futhark.Tools