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

data ExpHint Source #

Constructors

NoHint 
Hint IxFun Space 

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

Minimal complete definition

askDefaultSpace, askConsts

Methods

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.

default dimAllocationSize :: m ~ AllocM fromlore lore => SubExp -> m SubExp Source #

askConsts :: m (Set VName) Source #

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

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

Instances

Instances details
Allocable fromlore tolore => Allocator tolore (AllocM fromlore tolore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

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

Instances details
ASTLore tolore => LocalScope tolore (AllocM fromlore tolore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

localScope :: Scope tolore -> AllocM fromlore tolore a -> AllocM fromlore tolore a Source #

ASTLore tolore => HasScope tolore (AllocM fromlore tolore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

lookupType :: VName -> AllocM fromlore tolore Type Source #

lookupInfo :: VName -> AllocM fromlore tolore (NameInfo tolore) Source #

askScope :: AllocM fromlore tolore (Scope tolore) Source #

asksScope :: (Scope tolore -> a) -> AllocM fromlore tolore a Source #

Allocable fromlore tolore => Allocator tolore (AllocM fromlore tolore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

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

Defined in Futhark.Pass.ExplicitAllocations

Methods

(>>=) :: AllocM fromlore tolore a -> (a -> AllocM fromlore tolore b) -> AllocM fromlore tolore b #

(>>) :: AllocM fromlore tolore a -> AllocM fromlore tolore b -> AllocM fromlore tolore b #

return :: a -> AllocM fromlore tolore a #

Functor (AllocM fromlore tolore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

fmap :: (a -> b) -> AllocM fromlore tolore a -> AllocM fromlore tolore b #

(<$) :: a -> AllocM fromlore tolore b -> AllocM fromlore tolore a #

Applicative (AllocM fromlore tolore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

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

Defined in Futhark.Pass.ExplicitAllocations

Methods

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

Defined in Futhark.Pass.ExplicitAllocations

Associated Types

type Lore (AllocM fromlore tolore) Source #

Methods

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

Defined in Futhark.Pass.ExplicitAllocations

Methods

ask :: AllocM fromlore tolore (AllocEnv fromlore tolore) #

local :: (AllocEnv fromlore tolore -> AllocEnv fromlore tolore) -> AllocM fromlore tolore a -> AllocM fromlore tolore a #

reader :: (AllocEnv fromlore tolore -> a) -> AllocM fromlore tolore a #

type Lore (AllocM fromlore tolore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

type Lore (AllocM fromlore tolore) = tolore

data AllocEnv fromlore tolore Source #

Constructors

AllocEnv 

Fields

  • chunkMap :: ChunkMap
     
  • 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 fromlore -> AllocM fromlore tolore (Op tolore)
     
  • envExpHints :: Exp tolore -> AllocM fromlore tolore [ExpHint]
     

Instances

Instances details
MonadReader (AllocEnv fromlore tolore) (AllocM fromlore tolore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations

Methods

ask :: AllocM fromlore tolore (AllocEnv fromlore tolore) #

local :: (AllocEnv fromlore tolore -> AllocEnv fromlore tolore) -> AllocM fromlore tolore a -> AllocM fromlore tolore a #

reader :: (AllocEnv fromlore tolore -> a) -> AllocM fromlore tolore 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 lore) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.SegOp

Methods

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

opIsConst :: SegOp lvl lore -> Bool Source #

SizeSubst (MCOp lore op) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.MC

Methods

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

opIsConst :: MCOp lore op -> Bool Source #

SizeSubst (HostOp lore op) Source # 
Instance details

Defined in Futhark.Pass.ExplicitAllocations.Kernels

Methods

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

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