futhark-0.21.9: 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 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 #

data ExpHint Source #

Constructors

NoHint 
Hint IxFun Space 

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

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 #

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 inner => MonadBuilder (AllocM fromrep torep) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Associated Types

type Rep (AllocM fromrep torep) Source #

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 #

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 :: Pat dec -> op -> ChunkMap Source #

opIsConst :: op -> Bool Source #

Instances

Instances details
SizeSubst () Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

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

opIsConst :: () -> Bool Source #

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

Defined in Futhark.Pass.ExplicitAllocations

Methods

opSizeSubst :: Pat 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 :: Pat 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 :: Pat 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 :: Pat dec -> HostOp rep op -> ChunkMap Source #

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