futhark-0.22.4: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
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 => HasScope (torep :: k2) (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 #

ASTRep torep => LocalScope (torep :: k2) (AllocM fromrep torep) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

localScope :: Scope torep -> AllocM fromrep torep a -> AllocM fromrep torep a Source #

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 #

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 #

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 #

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 #

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 #

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

  • aggressiveReuse :: Bool

    Aggressively try to reuse memory in do-loops - should be True inside kernels, False outside.

  • allocSpace :: Space

    When allocating memory, put it in this memory space. This is primarily used to ensure that group-wide statements store their results in local memory.

  • envConsts :: Set VName

    The set of names that are known to be constants at kernel compile time.

  • allocInOp :: Op fromrep -> AllocM fromrep torep (Op torep)
     
  • envExpHints :: Exp torep -> AllocM fromrep torep [ExpHint]
     

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

Nothing

Methods

opIsConst :: op -> Bool Source #

Instances

Instances details
SizeSubst () Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

opIsConst :: () -> Bool Source #

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

Defined in Futhark.Pass.ExplicitAllocations

Methods

opIsConst :: MemOp op -> Bool Source #

SizeSubst (HostOp rep op) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.GPU

Methods

opIsConst :: HostOp rep op -> Bool Source #

SizeSubst (MCOp rep op) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.MC

Methods

opIsConst :: MCOp rep op -> Bool Source #

SizeSubst (SegOp lvl rep) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.SegOp

Methods

opIsConst :: SegOp lvl rep -> 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, LetDec rep ~ LetDecMem, ExpDec rep ~ (), BodyDec rep ~ (), OpReturns (OpWithWisdom inner), AliasedOp (OpWithWisdom inner), IndexOp (OpWithWisdom inner), 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'' :: (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 #

Module re-exports