futhark-0.12.1: An optimising compiler for a functional, array-oriented language.

Safe HaskellNone
LanguageHaskell2010

Futhark.Representation.Kernels.Kernel

Contents

Synopsis

Documentation

data GenReduceOp lore Source #

Constructors

GenReduceOp 

Fields

Instances
Annotations lore => Eq (GenReduceOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

(==) :: GenReduceOp lore -> GenReduceOp lore -> Bool #

(/=) :: GenReduceOp lore -> GenReduceOp lore -> Bool #

Annotations lore => Ord (GenReduceOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

compare :: GenReduceOp lore -> GenReduceOp lore -> Ordering #

(<) :: GenReduceOp lore -> GenReduceOp lore -> Bool #

(<=) :: GenReduceOp lore -> GenReduceOp lore -> Bool #

(>) :: GenReduceOp lore -> GenReduceOp lore -> Bool #

(>=) :: GenReduceOp lore -> GenReduceOp lore -> Bool #

max :: GenReduceOp lore -> GenReduceOp lore -> GenReduceOp lore #

min :: GenReduceOp lore -> GenReduceOp lore -> GenReduceOp lore #

Annotations lore => Show (GenReduceOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

showsPrec :: Int -> GenReduceOp lore -> ShowS #

show :: GenReduceOp lore -> String #

showList :: [GenReduceOp lore] -> ShowS #

data SegRedOp lore Source #

Constructors

SegRedOp 

Fields

Instances
Annotations lore => Eq (SegRedOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

(==) :: SegRedOp lore -> SegRedOp lore -> Bool #

(/=) :: SegRedOp lore -> SegRedOp lore -> Bool #

Annotations lore => Ord (SegRedOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

compare :: SegRedOp lore -> SegRedOp lore -> Ordering #

(<) :: SegRedOp lore -> SegRedOp lore -> Bool #

(<=) :: SegRedOp lore -> SegRedOp lore -> Bool #

(>) :: SegRedOp lore -> SegRedOp lore -> Bool #

(>=) :: SegRedOp lore -> SegRedOp lore -> Bool #

max :: SegRedOp lore -> SegRedOp lore -> SegRedOp lore #

min :: SegRedOp lore -> SegRedOp lore -> SegRedOp lore #

Annotations lore => Show (SegRedOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

showsPrec :: Int -> SegRedOp lore -> ShowS #

show :: SegRedOp lore -> String #

showList :: [SegRedOp lore] -> ShowS #

segRedResults :: [SegRedOp lore] -> Int Source #

How many reduction results are produced by these SegRedOps?

data KernelBody lore Source #

The body of a Kernel.

Instances
Annotations lore => Eq (KernelBody lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

(==) :: KernelBody lore -> KernelBody lore -> Bool #

(/=) :: KernelBody lore -> KernelBody lore -> Bool #

Annotations lore => Ord (KernelBody lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

compare :: KernelBody lore -> KernelBody lore -> Ordering #

(<) :: KernelBody lore -> KernelBody lore -> Bool #

(<=) :: KernelBody lore -> KernelBody lore -> Bool #

(>) :: KernelBody lore -> KernelBody lore -> Bool #

(>=) :: KernelBody lore -> KernelBody lore -> Bool #

max :: KernelBody lore -> KernelBody lore -> KernelBody lore #

min :: KernelBody lore -> KernelBody lore -> KernelBody lore #

Annotations lore => Show (KernelBody lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

showsPrec :: Int -> KernelBody lore -> ShowS #

show :: KernelBody lore -> String #

showList :: [KernelBody lore] -> ShowS #

PrettyLore lore => Pretty (KernelBody lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

ppr :: KernelBody lore -> Doc #

pprPrec :: Int -> KernelBody lore -> Doc #

pprList :: [KernelBody lore] -> Doc #

Attributes lore => FreeIn (KernelBody lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

freeIn' :: KernelBody lore -> FV Source #

Attributes lore => Substitute (KernelBody lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Attributes lore => Rename (KernelBody lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

rename :: KernelBody lore -> RenameM (KernelBody lore) Source #

data KernelResult Source #

Constructors

Returns SubExp

Each "worker" in the kernel returns this. Whether this is a result-per-thread or a result-per-group depends on the SegLevel.

WriteReturns [SubExp] VName [([SubExp], SubExp)] 
ConcatReturns SplitOrdering SubExp SubExp VName 
TileReturns [(SubExp, SubExp)] VName 
Instances
Eq KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Ord KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Show KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Pretty KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

FreeIn KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Substitute KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Rename KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Simplifiable KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Simplify

data SplitOrdering Source #

How an array is split into chunks.

Instances
Eq SplitOrdering Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Ord SplitOrdering Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Show SplitOrdering Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

FreeIn SplitOrdering Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Substitute SplitOrdering Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Rename SplitOrdering Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Simplifiable SplitOrdering Source # 
Instance details

Defined in Futhark.Representation.Kernels.Simplify

Segmented operations

data SegOp lore Source #

Constructors

SegMap SegLevel SegSpace [Type] (KernelBody lore) 
SegRed SegLevel SegSpace [SegRedOp lore] [Type] (KernelBody lore)

The KernelSpace must always have at least two dimensions, implying that the result of a SegRed is always an array.

SegScan SegLevel SegSpace (Lambda lore) [SubExp] [Type] (KernelBody lore) 
SegGenRed SegLevel SegSpace [GenReduceOp lore] [Type] (KernelBody lore) 
Instances
Annotations lore => Eq (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

(==) :: SegOp lore -> SegOp lore -> Bool #

(/=) :: SegOp lore -> SegOp lore -> Bool #

Annotations lore => Ord (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

compare :: SegOp lore -> SegOp lore -> Ordering #

(<) :: SegOp lore -> SegOp lore -> Bool #

(<=) :: SegOp lore -> SegOp lore -> Bool #

(>) :: SegOp lore -> SegOp lore -> Bool #

(>=) :: SegOp lore -> SegOp lore -> Bool #

max :: SegOp lore -> SegOp lore -> SegOp lore #

min :: SegOp lore -> SegOp lore -> SegOp lore #

Annotations lore => Show (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

showsPrec :: Int -> SegOp lore -> ShowS #

show :: SegOp lore -> String #

showList :: [SegOp lore] -> ShowS #

PrettyLore lore => Pretty (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

ppr :: SegOp lore -> Doc #

pprPrec :: Int -> SegOp lore -> Doc #

pprList :: [SegOp lore] -> Doc #

TypedOp (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

opType :: HasScope t m => SegOp lore -> m [ExtType] Source #

(Attributes lore, FreeIn (LParamAttr lore)) => FreeIn (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

freeIn' :: SegOp lore -> FV Source #

Attributes lore => Substitute (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

substituteNames :: Map VName VName -> SegOp lore -> SegOp lore Source #

Attributes lore => Rename (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

rename :: SegOp lore -> RenameM (SegOp lore) Source #

Attributes lore => IsOp (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

safeOp :: SegOp lore -> Bool Source #

cheapOp :: SegOp lore -> Bool Source #

(Attributes lore, Attributes (Aliases lore), CanBeAliased (Op lore)) => CanBeAliased (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Associated Types

type OpWithAliases (SegOp lore) :: Type Source #

(Attributes lore, Aliased lore) => AliasedOp (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

opAliases :: SegOp lore -> [Names] Source #

consumedInOp :: SegOp lore -> Names Source #

OpMetrics (Op lore) => OpMetrics (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

opMetrics :: SegOp lore -> MetricsM () Source #

(Attributes lore, CanBeRanged (Op lore)) => CanBeRanged (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Associated Types

type OpWithRanges (SegOp lore) :: Type Source #

Attributes inner => RangedOp (SegOp inner) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

opRanges :: SegOp inner -> [Range] Source #

(CanBeWise (Op lore), Attributes lore) => CanBeWise (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Associated Types

type OpWithWisdom (SegOp lore) :: Type Source #

Methods

removeOpWisdom :: OpWithWisdom (SegOp lore) -> SegOp lore Source #

Attributes lore => IndexOp (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

indexOp :: (Attributes lore0, IndexOp (Op lore0)) => SymbolTable lore0 -> Int -> SegOp lore -> [PrimExp VName] -> Maybe (PrimExp VName, Certificates) Source #

(Attributes lore, Aliased lore, CSEInOp (Op lore)) => CSEInOp (SegOp lore) Source # 
Instance details

Defined in Futhark.Optimise.CSE

Methods

cseInOp :: SegOp lore -> CSEM lore0 (SegOp lore)

type OpWithAliases (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

type OpWithAliases (SegOp lore) = SegOp (Aliases lore)
type OpWithRanges (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

type OpWithRanges (SegOp lore) = SegOp (Ranges lore)
type OpWithWisdom (SegOp lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

type OpWithWisdom (SegOp lore) = SegOp (Wise lore)

data SegLevel Source #

At which level the *body* of a SegOp executes.

Constructors

SegThread 
SegGroup 
SegThreadScalar

Like SegThread, but with the invariant that the results produced are only used within the same physical thread later on, and can thus be kept in registers. May only occur within an enclosing SegGroup construct.

data SegVirt Source #

Do we need group-virtualisation when generating code for the segmented operation? In most cases, we do, but for some simple kernels, we compute the full number of groups in advance, and then virtualisation is an unnecessary (but generally very small) overhead. This only really matters for fairly trivial but very wide map kernels where each thread performs constant-time work on scalars.

Constructors

SegVirt 
SegNoVirt 

typeCheckSegOp :: Checkable lore => Maybe SegLevel -> SegOp (Aliases lore) -> TypeM lore () Source #

data SegSpace Source #

Index space of a SegOp.

Constructors

SegSpace 

Fields

Generic traversal

data SegOpMapper flore tlore m Source #

Like Mapper, but just for SegOps.

Constructors

SegOpMapper 

Fields

identitySegOpMapper :: Monad m => SegOpMapper lore lore m Source #

A mapper that simply returns the SegOp verbatim.

mapSegOpM :: (Applicative m, Monad m) => SegOpMapper flore tlore m -> SegOp flore -> m (SegOp tlore) Source #

data SegOpWalker lore m Source #

Like Walker, but just for SegOps.

Constructors

SegOpWalker 

Fields

identitySegOpWalker :: Monad m => SegOpWalker lore m Source #

A no-op traversal.

walkSegOpM :: Monad m => SegOpWalker lore m -> SegOp lore -> m () Source #

As mapSegOpM, but ignoring the results.

Host operations

data HostOp lore op Source #

A host-level operation; parameterised by what else it can do.

Constructors

SplitSpace SplitOrdering SubExp SubExp SubExp

SplitSpace o w i elems_per_thread.

Computes how to divide array elements to threads in a kernel. Returns the number of elements in the chunk that the current thread should take.

w is the length of the outer dimension in the array. i is the current thread index. Each thread takes at most elems_per_thread elements.

If the order o is SplitContiguous, thread with index i should receive elements i*elems_per_tread, i*elems_per_thread + 1, ..., i*elems_per_thread + (elems_per_thread-1).

If the order o is SplitStrided stride, the thread will receive elements i, i+stride, i+2*stride, ..., i+(elems_per_thread-1)*stride.

GetSize Name SizeClass

Produce some runtime-configurable size.

GetSizeMax SizeClass

The maximum size of some class.

CmpSizeLe Name SizeClass SubExp

Compare size (likely a threshold) with some Int32 value.

SegOp (SegOp lore)

A segmented operation.

OtherOp op 
Instances
(Annotations lore, Eq op) => Eq (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

(==) :: HostOp lore op -> HostOp lore op -> Bool #

(/=) :: HostOp lore op -> HostOp lore op -> Bool #

(Annotations lore, Ord op) => Ord (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

compare :: HostOp lore op -> HostOp lore op -> Ordering #

(<) :: HostOp lore op -> HostOp lore op -> Bool #

(<=) :: HostOp lore op -> HostOp lore op -> Bool #

(>) :: HostOp lore op -> HostOp lore op -> Bool #

(>=) :: HostOp lore op -> HostOp lore op -> Bool #

max :: HostOp lore op -> HostOp lore op -> HostOp lore op #

min :: HostOp lore op -> HostOp lore op -> HostOp lore op #

(Annotations lore, Show op) => Show (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

showsPrec :: Int -> HostOp lore op -> ShowS #

show :: HostOp lore op -> String #

showList :: [HostOp lore op] -> ShowS #

(PrettyLore lore, Pretty op) => Pretty (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

ppr :: HostOp lore op -> Doc #

pprPrec :: Int -> HostOp lore op -> Doc #

pprList :: [HostOp lore op] -> Doc #

TypedOp op => TypedOp (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

opType :: HasScope t m => HostOp lore op -> m [ExtType] Source #

(Attributes lore, FreeIn op) => FreeIn (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

freeIn' :: HostOp lore op -> FV Source #

(Attributes lore, Substitute op) => Substitute (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

substituteNames :: Map VName VName -> HostOp lore op -> HostOp lore op Source #

(Attributes lore, Rename op) => Rename (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

rename :: HostOp lore op -> RenameM (HostOp lore op) Source #

(Attributes lore, IsOp op) => IsOp (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

safeOp :: HostOp lore op -> Bool Source #

cheapOp :: HostOp lore op -> Bool Source #

(CanBeAliased (Op lore), CanBeAliased op, Attributes lore) => CanBeAliased (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Associated Types

type OpWithAliases (HostOp lore op) :: Type Source #

Methods

removeOpAliases :: OpWithAliases (HostOp lore op) -> HostOp lore op Source #

addOpAliases :: HostOp lore op -> OpWithAliases (HostOp lore op) Source #

(Aliased lore, AliasedOp op, Attributes lore) => AliasedOp (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

opAliases :: HostOp lore op -> [Names] Source #

consumedInOp :: HostOp lore op -> Names Source #

(OpMetrics (Op lore), OpMetrics op) => OpMetrics (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

opMetrics :: HostOp lore op -> MetricsM () Source #

(CanBeRanged (Op lore), CanBeRanged op, Attributes lore) => CanBeRanged (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Associated Types

type OpWithRanges (HostOp lore op) :: Type Source #

Methods

removeOpRanges :: OpWithRanges (HostOp lore op) -> HostOp lore op Source #

addOpRanges :: HostOp lore op -> OpWithRanges (HostOp lore op) Source #

(Attributes lore, RangedOp op) => RangedOp (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

opRanges :: HostOp lore op -> [Range] Source #

(CanBeWise (Op lore), CanBeWise op, Attributes lore) => CanBeWise (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Associated Types

type OpWithWisdom (HostOp lore op) :: Type Source #

Methods

removeOpWisdom :: OpWithWisdom (HostOp lore op) -> HostOp lore op Source #

(Attributes lore, IndexOp op) => IndexOp (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

indexOp :: (Attributes lore0, IndexOp (Op lore0)) => SymbolTable lore0 -> Int -> HostOp lore op -> [PrimExp VName] -> Maybe (PrimExp VName, Certificates) Source #

(Attributes lore, Aliased lore, CSEInOp (Op lore), CSEInOp op) => CSEInOp (HostOp lore op) Source # 
Instance details

Defined in Futhark.Optimise.CSE

Methods

cseInOp :: HostOp lore op -> CSEM lore0 (HostOp lore op)

type OpWithAliases (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

type OpWithAliases (HostOp lore op) = HostOp (Aliases lore) (OpWithAliases op)
type OpWithRanges (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

type OpWithRanges (HostOp lore op) = HostOp (Ranges lore) (OpWithRanges op)
type OpWithWisdom (HostOp lore op) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

type OpWithWisdom (HostOp lore op) = HostOp (Wise lore) (OpWithWisdom op)

typeCheckHostOp :: Checkable lore => (SegLevel -> OpWithAliases (Op lore) -> TypeM lore ()) -> Maybe SegLevel -> (op -> TypeM lore ()) -> HostOp (Aliases lore) op -> TypeM lore () Source #

Reexports