futhark-0.19.7: An optimising compiler for a functional, array-oriented language.
Safe HaskellNone
LanguageHaskell2010

Futhark.Pass.ExplicitAllocations

Description

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

Synopsis

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 #

data ExpHint Source #

Constructors

NoHint 
Hint IxFun Space 

defaultExpHints :: (Monad m, ASTRep rep) => Exp rep -> m [ExpHint] 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 #

Minimal complete definition

askDefaultSpace, askConsts

Methods

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.

default dimAllocationSize :: m ~ AllocM fromrep rep => SubExp -> m SubExp Source #

askConsts :: m (Set VName) Source #

Get those names that are known to be constants at run-time.

expHints :: Exp rep -> m [ExpHint] Source #

Instances

Instances details
Allocable fromrep torep => Allocator torep (AllocM fromrep torep) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

addAllocStm :: AllocStm -> AllocM fromrep torep () Source #

askDefaultSpace :: AllocM fromrep torep Space Source #

dimAllocationSize :: SubExp -> AllocM fromrep torep SubExp Source #

askConsts :: AllocM fromrep torep (Set VName) Source #

expHints :: Exp torep -> AllocM fromrep torep [ExpHint] Source #

data AllocM fromrep torep a Source #

Monad for adding allocations to an entire program.

Instances

Instances details
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 #

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 #

Allocable fromrep torep => Allocator torep (AllocM fromrep torep) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

addAllocStm :: AllocStm -> AllocM fromrep torep () Source #

askDefaultSpace :: AllocM fromrep torep Space Source #

dimAllocationSize :: SubExp -> AllocM fromrep torep SubExp Source #

askConsts :: AllocM fromrep torep (Set VName) Source #

expHints :: Exp torep -> AllocM fromrep torep [ExpHint] 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 #

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

return :: a -> AllocM fromrep torep a #

Functor (AllocM fromrep torep) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

fmap :: (a -> b) -> AllocM fromrep torep a -> AllocM fromrep torep b #

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

Applicative (AllocM fromrep torep) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

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 # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

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 # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Associated Types

type Rep (AllocM fromrep torep) Source #

Methods

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 # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

ask :: AllocM fromrep torep (AllocEnv fromrep torep) #

local :: (AllocEnv fromrep torep -> AllocEnv fromrep torep) -> AllocM fromrep torep a -> AllocM fromrep torep a #

reader :: (AllocEnv fromrep torep -> a) -> AllocM fromrep torep a #

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

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) #

local :: (AllocEnv fromrep torep -> AllocEnv fromrep torep) -> AllocM fromrep torep a -> AllocM fromrep torep a #

reader :: (AllocEnv fromrep torep -> a) -> AllocM fromrep torep a #

class SizeSubst op where Source #

Minimal complete definition

opSizeSubst

Methods

opSizeSubst :: PatternT dec -> op -> ChunkMap Source #

opIsConst :: op -> Bool Source #

Instances

Instances details
SizeSubst () Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

opSizeSubst :: PatternT dec -> () -> ChunkMap Source #

opIsConst :: () -> Bool Source #

SizeSubst op => SizeSubst (MemOp op) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

opSizeSubst :: PatternT dec -> MemOp op -> ChunkMap Source #

opIsConst :: MemOp op -> Bool Source #

SizeSubst (SegOp lvl rep) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.SegOp

Methods

opSizeSubst :: PatternT dec -> SegOp lvl rep -> ChunkMap Source #

opIsConst :: SegOp lvl rep -> Bool Source #

SizeSubst (MCOp rep op) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.MC

Methods

opSizeSubst :: PatternT dec -> MCOp rep op -> ChunkMap Source #

opIsConst :: MCOp rep op -> Bool Source #

SizeSubst (HostOp rep op) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.GPU

Methods

opSizeSubst :: PatternT dec -> HostOp rep op -> ChunkMap Source #

opIsConst :: HostOp rep op -> Bool 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