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

Safe Haskell | None
Language | GHC2021

Futhark.IR.GPU.Op

Contents

- Size operations
- Host operations
- SegOp refinements
- Reexports

Synopsis

- data SizeOp
  - = GetSize Name SizeClass
  - | GetSizeMax SizeClass
  - | CmpSizeLe Name SizeClass SubExp
  - | CalcNumBlocks SubExp Name SubExp
- data HostOp (op :: Type -> Type) rep
  - = SegOp (SegOp SegLevel rep)
  - | SizeOp SizeOp
  - | OtherOp (op rep)
  - | GPUBody [Type] (Body rep)
- traverseHostOpStms :: Monad m => OpStmsTraverser m (op rep) rep -> OpStmsTraverser m (HostOp op rep) rep
- typeCheckHostOp :: Checkable rep => (SegLevel -> Op (Aliases rep) -> TypeM rep ()) -> Maybe SegLevel -> (op (Aliases rep) -> TypeM rep ()) -> HostOp op (Aliases rep) -> TypeM rep ()
- data SegLevel
  - = SegThread SegVirt (Maybe KernelGrid)
  - | SegBlock SegVirt (Maybe KernelGrid)
  - | SegThreadInBlock SegVirt
- segVirt :: SegLevel -> SegVirt
- data SegVirt
  - = SegVirt
  - | SegNoVirt
  - | SegNoVirtFull SegSeqDims
- newtype SegSeqDims = SegSeqDims {
  - segSeqDims :: [Int]
  }
- data KernelGrid = KernelGrid {
  - gridNumBlocks :: Count NumBlocks SubExp
  - gridBlockSize :: Count BlockSize SubExp
  }
- module Futhark.IR.GPU.Sizes
- module Futhark.IR.SegOp

# Size operations

data SizeOp Source #

A simple size-level query or computation.

Constructors

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 integer value.
CalcNumBlocks SubExp Name SubExp | `CalcNumBlocks w max_num_tblocks tblock_size` calculates the number of GPU threadblocks to use for an input of the given size. The `Name` is a size name. Note that `w` is an i64 to avoid overflow issues.

#### Instances

Instances details

OpMetrics SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods opMetrics :: SizeOp -> MetricsM () Source #
FreeIn SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods freeIn' :: SizeOp -> FV Source #
Rename SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods rename :: SizeOp -> RenameM SizeOp Source #
Substitute SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods substituteNames :: Map VName VName -> SizeOp -> SizeOp Source #
Show SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods showsPrec :: Int -> SizeOp -> ShowS Source # show :: SizeOp -> String Source # showList :: [SizeOp] -> ShowS Source #
Eq SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods (==) :: SizeOp -> SizeOp -> Bool Source # (/=) :: SizeOp -> SizeOp -> Bool Source #
Ord SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods compare :: SizeOp -> SizeOp -> Ordering Source # (<) :: SizeOp -> SizeOp -> Bool Source # (<=) :: SizeOp -> SizeOp -> Bool Source # (>) :: SizeOp -> SizeOp -> Bool Source # (>=) :: SizeOp -> SizeOp -> Bool Source # max :: SizeOp -> SizeOp -> SizeOp Source # min :: SizeOp -> SizeOp -> SizeOp Source #
Pretty SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods pretty :: SizeOp -> Doc ann Source # prettyList :: [SizeOp] -> Doc ann Source #

# Host operations

data HostOp (op :: Type -> Type) rep Source #

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

Constructors

SegOp (SegOp SegLevel rep) | A segmented operation.
SizeOp SizeOp |
OtherOp (op rep) |
GPUBody [Type] (Body rep) | Code to run sequentially on the GPU, in a single thread.

#### Instances

Instances details

CanBeAliased op => CanBeAliased (HostOp op) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods addOpAliases :: AliasableRep rep => AliasTable -> HostOp op rep -> HostOp op (Aliases rep) Source #
OpReturns (HostOp (NoOp :: Type -> Type)) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods opReturns :: forall rep (inner :: Type -> Type) m. (Mem rep inner, Monad m, HasScope rep m) => HostOp (NoOp :: Type -> Type) rep -> m [ExpReturns] Source #
IsOp op => IsOp (HostOp op) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods safeOp :: ASTRep rep => HostOp op rep -> Bool Source # cheapOp :: ASTRep rep => HostOp op rep -> Bool Source # opDependencies :: ASTRep rep => HostOp op rep -> [Names] Source #
AliasedOp op => AliasedOp (HostOp op) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods opAliases :: Aliased rep => HostOp op rep -> [Names] Source # consumedInOp :: Aliased rep => HostOp op rep -> Names Source #
TypedOp op => TypedOp (HostOp op) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods opType :: HasScope rep m => HostOp op rep -> m [ExtType] Source #
RephraseOp op => RephraseOp (HostOp op) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods rephraseInOp :: Monad m => Rephraser m from to -> HostOp op from -> m (HostOp op to) Source #
CanBeWise op => CanBeWise (HostOp op) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods addOpWisdom :: Informing rep => HostOp op rep -> HostOp op (Wise rep) Source #
(OpMetrics (Op rep), OpMetrics (op rep)) => OpMetrics (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods opMetrics :: HostOp op rep -> MetricsM () Source #
(ASTRep rep, IndexOp (op rep)) => IndexOp (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods indexOp :: (ASTRep rep0, IndexOp (Op rep0)) => SymbolTable rep0 -> Int -> HostOp op rep -> [TPrimExp Int64 VName] -> Maybe Indexed Source #
(ASTRep rep, FreeIn (op rep)) => FreeIn (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods freeIn' :: HostOp op rep -> FV Source #
TopDownHelper (HostOp (NoOp :: Type -> Type) (Aliases GPUMem)) Source # |
Instance details Defined in Futhark.Optimise.ArrayShortCircuiting.TopdownAnalysis Methods innerNonNegatives :: [VName] -> HostOp (NoOp :: Type -> Type) (Aliases GPUMem) -> Names innerKnownLessThan :: HostOp (NoOp :: Type -> Type) (Aliases GPUMem) -> [(VName, PrimExp VName)] scopeHelper :: HostOp (NoOp :: Type -> Type) (Aliases GPUMem) -> Scope rep
(Aliased rep, CSEInOp (Op rep), CSEInOp (op rep)) => CSEInOp (HostOp op rep) Source # |
Instance details Defined in Futhark.Optimise.CSE Methods cseInOp :: HostOp op rep -> CSEM rep0 (HostOp op rep)
SizeSubst (HostOp rep op) Source # |
Instance details Defined in Futhark.Pass.ExplicitAllocations.GPU Methods opIsConst :: HostOp rep op -> Bool Source #
(ASTRep rep, Rename (op rep)) => Rename (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods rename :: HostOp op rep -> RenameM (HostOp op rep) Source #
(ASTRep rep, Substitute (op rep)) => Substitute (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods substituteNames :: Map VName VName -> HostOp op rep -> HostOp op rep Source #
(RepTypes rep, Show (op rep)) => Show (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods showsPrec :: Int -> HostOp op rep -> ShowS Source # show :: HostOp op rep -> String Source # showList :: [HostOp op rep] -> ShowS Source #
(RepTypes rep, Eq (op rep)) => Eq (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods (==) :: HostOp op rep -> HostOp op rep -> Bool Source # (/=) :: HostOp op rep -> HostOp op rep -> Bool Source #
(RepTypes rep, Ord (op rep)) => Ord (HostOp op rep) Source # |

Instance details

Defined in Futhark.IR.GPU.Op

Methods

compare :: HostOp op rep -> HostOp op rep -> Ordering Source #

(<) :: HostOp op rep -> HostOp op rep -> Bool Source #

(<=) :: HostOp op rep -> HostOp op rep -> Bool Source #

(>) :: HostOp op rep -> HostOp op rep -> Bool Source #

(>=) :: HostOp op rep -> HostOp op rep -> Bool Source #

max :: HostOp op rep -> HostOp op rep -> HostOp op rep Source #

min :: HostOp op rep -> HostOp op rep -> HostOp op rep Source #

(PrettyRep rep, Pretty (op rep)) => Pretty (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods pretty :: HostOp op rep -> Doc ann Source # prettyList :: [HostOp op rep] -> Doc ann Source #

traverseHostOpStms :: Monad m => OpStmsTraverser m (op rep) rep -> OpStmsTraverser m (HostOp op rep) rep Source #

A helper for defining `TraverseOpStms`.

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

# SegOp refinements

data SegLevel Source #

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

Constructors

SegThread SegVirt (Maybe KernelGrid) |
SegBlock SegVirt (Maybe KernelGrid) |
SegThreadInBlock SegVirt |

#### Instances

Instances details

FreeIn SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods freeIn' :: SegLevel -> FV Source #
Simplifiable SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods simplify :: SimplifiableRep rep => SegLevel -> SimpleM rep SegLevel Source #
Rename SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods rename :: SegLevel -> RenameM SegLevel Source #
Substitute SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods substituteNames :: Map VName VName -> SegLevel -> SegLevel Source #
Show SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods showsPrec :: Int -> SegLevel -> ShowS Source # show :: SegLevel -> String Source # showList :: [SegLevel] -> ShowS Source #
Eq SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods (==) :: SegLevel -> SegLevel -> Bool Source # (/=) :: SegLevel -> SegLevel -> Bool Source #
Ord SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods compare :: SegLevel -> SegLevel -> Ordering Source # (<) :: SegLevel -> SegLevel -> Bool Source # (<=) :: SegLevel -> SegLevel -> Bool Source # (>) :: SegLevel -> SegLevel -> Bool Source # (>=) :: SegLevel -> SegLevel -> Bool Source # max :: SegLevel -> SegLevel -> SegLevel Source # min :: SegLevel -> SegLevel -> SegLevel Source #
Pretty SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods pretty :: SegLevel -> Doc ann Source # prettyList :: [SegLevel] -> Doc ann Source #

segVirt :: SegLevel -> SegVirt Source #

The `SegVirt` of the `SegLevel`.

data SegVirt Source #

Do we need block-virtualisation when generating code for the segmented operation? In most cases, we do, but for some simple kernels, we compute the full number of blocks 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 |
SegNoVirtFull SegSeqDims | Not only do we not need virtualisation, but we _guarantee_ that all physical threads participate in the work. This can save some checks in code generation.

#### Instances

Instances details

Show SegVirt Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods showsPrec :: Int -> SegVirt -> ShowS Source # show :: SegVirt -> String Source # showList :: [SegVirt] -> ShowS Source #
Eq SegVirt Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods (==) :: SegVirt -> SegVirt -> Bool Source # (/=) :: SegVirt -> SegVirt -> Bool Source #
Ord SegVirt Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods compare :: SegVirt -> SegVirt -> Ordering Source # (<) :: SegVirt -> SegVirt -> Bool Source # (<=) :: SegVirt -> SegVirt -> Bool Source # (>) :: SegVirt -> SegVirt -> Bool Source # (>=) :: SegVirt -> SegVirt -> Bool Source # max :: SegVirt -> SegVirt -> SegVirt Source # min :: SegVirt -> SegVirt -> SegVirt Source #
Pretty SegVirt Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods pretty :: SegVirt -> Doc ann Source # prettyList :: [SegVirt] -> Doc ann Source #

newtype SegSeqDims Source #

These dimensions (indexed from 0, outermost) of the corresponding `SegSpace` should not be parallelised, but instead iterated sequentially. For example, with a `SegSeqDims` of `[0]` and a `SegSpace` with dimensions `[n][m]`, there will be an outer loop with `n` iterations, while the `m` dimension will be parallelised.

Semantically, this has no effect, but it may allow reductions in memory usage or other low-level optimisations. Operationally, the guarantee is that for a SegSeqDims of e.g. `[i,j,k]`, threads running at any given moment will always have the same indexes along the dimensions specified by `[i,j,k]`.

At the moment, this is only supported for `SegNoVirtFull` intra-block parallelism in GPU code, as we have not yet found it useful anywhere else.

Constructors

SegSeqDims |

Fields

- segSeqDims :: [Int]

#### Instances

Instances details

Show SegSeqDims Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods showsPrec :: Int -> SegSeqDims -> ShowS Source # show :: SegSeqDims -> String Source # showList :: [SegSeqDims] -> ShowS Source #
Eq SegSeqDims Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods (==) :: SegSeqDims -> SegSeqDims -> Bool Source # (/=) :: SegSeqDims -> SegSeqDims -> Bool Source #
Ord SegSeqDims Source # |

Instance details

Defined in Futhark.IR.GPU.Op

Methods

compare :: SegSeqDims -> SegSeqDims -> Ordering Source #

(<) :: SegSeqDims -> SegSeqDims -> Bool Source #

(<=) :: SegSeqDims -> SegSeqDims -> Bool Source #

(>) :: SegSeqDims -> SegSeqDims -> Bool Source #

(>=) :: SegSeqDims -> SegSeqDims -> Bool Source #

max :: SegSeqDims -> SegSeqDims -> SegSeqDims Source #

min :: SegSeqDims -> SegSeqDims -> SegSeqDims Source #

data KernelGrid Source #

The actual, physical grid dimensions used for the GPU kernel running this `SegOp`.

Constructors

KernelGrid |

Fields

- gridNumBlocks :: Count NumBlocks SubExp
- gridBlockSize :: Count BlockSize SubExp

#### Instances

Instances details

FreeIn KernelGrid Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods freeIn' :: KernelGrid -> FV Source #
Simplifiable KernelGrid Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods simplify :: SimplifiableRep rep => KernelGrid -> SimpleM rep KernelGrid Source #
Substitute KernelGrid Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods substituteNames :: Map VName VName -> KernelGrid -> KernelGrid Source #
Show KernelGrid Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods showsPrec :: Int -> KernelGrid -> ShowS Source # show :: KernelGrid -> String Source # showList :: [KernelGrid] -> ShowS Source #
Eq KernelGrid Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods (==) :: KernelGrid -> KernelGrid -> Bool Source # (/=) :: KernelGrid -> KernelGrid -> Bool Source #
Ord KernelGrid Source # |

Instance details

Defined in Futhark.IR.GPU.Op

Methods

compare :: KernelGrid -> KernelGrid -> Ordering Source #

(<) :: KernelGrid -> KernelGrid -> Bool Source #

(<=) :: KernelGrid -> KernelGrid -> Bool Source #

(>) :: KernelGrid -> KernelGrid -> Bool Source #

(>=) :: KernelGrid -> KernelGrid -> Bool Source #

max :: KernelGrid -> KernelGrid -> KernelGrid Source #

min :: KernelGrid -> KernelGrid -> KernelGrid Source #

Pretty KernelGrid Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods pretty :: KernelGrid -> Doc ann Source # prettyList :: [KernelGrid] -> Doc ann Source #

# Reexports

module Futhark.IR.GPU.Sizes

module Futhark.IR.SegOp