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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.CodeGen.ImpCode.GPU

Description

Variation of Futhark.CodeGen.ImpCode that contains the notion of a kernel invocation.

Synopsis

- type Program = Definitions HostOp
- type HostCode = Code HostOp
- type KernelCode = Code KernelOp
- data KernelConst
  - = SizeConst Name SizeClass
  - | SizeMaxConst SizeClass
- type KernelConstExp = PrimExp KernelConst
- data HostOp
  - = CallKernel Kernel
  - | GetSize VName Name SizeClass
  - | CmpSizeLe VName Name SizeClass Exp
  - | GetSizeMax VName SizeClass
- data KernelOp
  - = GetBlockId VName Int
  - | GetLocalId VName Int
  - | GetLocalSize VName Int
  - | GetLockstepWidth VName
  - | Atomic Space AtomicOp
  - | Barrier Fence
  - | MemFence Fence
  - | SharedAlloc VName (Count Bytes (TExp Int64))
  - | ErrorSync Fence
- data Fence
  - = FenceLocal
  - | FenceGlobal
- data AtomicOp
  - = AtomicAdd IntType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicFAdd FloatType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicSMax IntType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicSMin IntType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicUMax IntType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicUMin IntType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicAnd IntType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicOr IntType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicXor IntType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicCmpXchg PrimType VName VName (Count Elements (TExp Int64)) Exp Exp
  - | AtomicXchg PrimType VName VName (Count Elements (TExp Int64)) Exp
  - | AtomicWrite PrimType VName (Count Elements (TExp Int64)) Exp
- type BlockDim = Either Exp KernelConstExp
- data Kernel = Kernel {
  - kernelBody :: Code KernelOp
  - kernelUses :: [KernelUse]
  - kernelNumBlocks :: [Exp]
  - kernelBlockSize :: [BlockDim]
  - kernelName :: Name
  - kernelFailureTolerant :: Bool
  - kernelCheckSharedMemory :: Bool
  }
- data KernelUse
  - = ScalarUse VName PrimType
  - | MemoryUse VName
  - | ConstUse VName KernelConstExp
- module Futhark.CodeGen.ImpCode
- module Futhark.IR.GPU.Sizes

# Documentation

type Program = Definitions HostOp Source #

A program that calls kernels.

type HostCode = Code HostOp Source #

Host-level code that can call kernels.

type KernelCode = Code KernelOp Source #

Code inside a kernel.

data KernelConst Source #

A run-time constant related to kernels.

Constructors

SizeConst Name SizeClass |
SizeMaxConst SizeClass |

#### Instances

Instances details

Show KernelConst Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods showsPrec :: Int -> KernelConst -> ShowS Source # show :: KernelConst -> String Source # showList :: [KernelConst] -> ShowS Source #
FreeIn KernelConst Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods freeIn' :: KernelConst -> FV Source #
Eq KernelConst Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods (==) :: KernelConst -> KernelConst -> Bool Source # (/=) :: KernelConst -> KernelConst -> Bool Source #
Ord KernelConst Source # |

Instance details

Defined in Futhark.CodeGen.ImpCode.GPU

Methods

compare :: KernelConst -> KernelConst -> Ordering Source #

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

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

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

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

max :: KernelConst -> KernelConst -> KernelConst Source #

min :: KernelConst -> KernelConst -> KernelConst Source #

Pretty KernelConst Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods pretty :: KernelConst -> Doc ann Source # prettyList :: [KernelConst] -> Doc ann Source #

type KernelConstExp = PrimExp KernelConst Source #

An expression whose variables are kernel constants.

data HostOp Source #

An operation that runs on the host (CPU).

Constructors

CallKernel Kernel |
GetSize VName Name SizeClass |
CmpSizeLe VName Name SizeClass Exp |
GetSizeMax VName SizeClass |

#### Instances

Instances details

Show HostOp Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods showsPrec :: Int -> HostOp -> ShowS Source # show :: HostOp -> String Source # showList :: [HostOp] -> ShowS Source #
FreeIn HostOp Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods freeIn' :: HostOp -> FV Source #
Pretty HostOp Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods pretty :: HostOp -> Doc ann Source # prettyList :: [HostOp] -> Doc ann Source #

data KernelOp Source #

An operation that occurs within a kernel body.

Constructors

GetBlockId VName Int |
GetLocalId VName Int |
GetLocalSize VName Int |
GetLockstepWidth VName |
Atomic Space AtomicOp |
Barrier Fence |
MemFence Fence |
SharedAlloc VName (Count Bytes (TExp Int64)) |
ErrorSync Fence | Perform a barrier and also check whether any threads have failed an assertion. Make sure all threads would reach all `ErrorSync`s if any of them do. A failing assertion will jump to the next following `ErrorSync`, so make sure it's not inside control flow or similar.

#### Instances

Instances details

Show KernelOp Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods showsPrec :: Int -> KernelOp -> ShowS Source # show :: KernelOp -> String Source # showList :: [KernelOp] -> ShowS Source #
FreeIn KernelOp Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods freeIn' :: KernelOp -> FV Source #
Pretty KernelOp Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods pretty :: KernelOp -> Doc ann Source # prettyList :: [KernelOp] -> Doc ann Source #

data Fence Source #

When we do a barrier or fence, is it at the local or global level? By the `Ord` instance, global is greater than local.

Constructors

FenceLocal |
FenceGlobal |

#### Instances

Instances details

Show Fence Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods showsPrec :: Int -> Fence -> ShowS Source # show :: Fence -> String Source # showList :: [Fence] -> ShowS Source #
Eq Fence Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods (==) :: Fence -> Fence -> Bool Source # (/=) :: Fence -> Fence -> Bool Source #
Ord Fence Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods compare :: Fence -> Fence -> Ordering Source # (<) :: Fence -> Fence -> Bool Source # (<=) :: Fence -> Fence -> Bool Source # (>) :: Fence -> Fence -> Bool Source # (>=) :: Fence -> Fence -> Bool Source # max :: Fence -> Fence -> Fence Source # min :: Fence -> Fence -> Fence Source #

data AtomicOp Source #

Atomic operations return the value stored before the update. This old value is stored in the first `VName` (except for `AtomicWrite`). The second `VName` is the memory block to update. The `Exp` is the new value.

Constructors

AtomicAdd IntType VName VName (Count Elements (TExp Int64)) Exp |
AtomicFAdd FloatType VName VName (Count Elements (TExp Int64)) Exp |
AtomicSMax IntType VName VName (Count Elements (TExp Int64)) Exp |
AtomicSMin IntType VName VName (Count Elements (TExp Int64)) Exp |
AtomicUMax IntType VName VName (Count Elements (TExp Int64)) Exp |
AtomicUMin IntType VName VName (Count Elements (TExp Int64)) Exp |
AtomicAnd IntType VName VName (Count Elements (TExp Int64)) Exp |
AtomicOr IntType VName VName (Count Elements (TExp Int64)) Exp |
AtomicXor IntType VName VName (Count Elements (TExp Int64)) Exp |
AtomicCmpXchg PrimType VName VName (Count Elements (TExp Int64)) Exp Exp |
AtomicXchg PrimType VName VName (Count Elements (TExp Int64)) Exp |
AtomicWrite PrimType VName (Count Elements (TExp Int64)) Exp | Corresponds to a write followed by a memory fence. The old value is not read.

#### Instances

Instances details

Show AtomicOp Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods showsPrec :: Int -> AtomicOp -> ShowS Source # show :: AtomicOp -> String Source # showList :: [AtomicOp] -> ShowS Source #
FreeIn AtomicOp Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods freeIn' :: AtomicOp -> FV Source #

type BlockDim = Either Exp KernelConstExp Source #

The size of one dimension of a block.

data Kernel Source #

A generic kernel containing arbitrary kernel code.

Constructors

Kernel |

Fields

- kernelBody :: Code KernelOp
- kernelUses :: [KernelUse]

  The host variables referenced by the kernel.

- kernelNumBlocks :: [Exp]
- kernelBlockSize :: [BlockDim]
- kernelName :: Name

  A short descriptive and _unique_ name - should be alphanumeric and without spaces.

- kernelFailureTolerant :: Bool

  If true, this kernel does not need to check whether we are in a failing state, as it can cope. Intuitively, it means that the kernel does not depend on any non-scalar parameters to make control flow decisions. Replication, transpose, and copy kernels are examples of this.

- kernelCheckSharedMemory :: Bool

  If true, multi-versioning branches will consider this kernel when considering the shared memory requirements. Set this to false for kernels that do their own checking.

#### Instances

Instances details

Show Kernel Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods showsPrec :: Int -> Kernel -> ShowS Source # show :: Kernel -> String Source # showList :: [Kernel] -> ShowS Source #
FreeIn Kernel Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods freeIn' :: Kernel -> FV Source #
Pretty Kernel Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods pretty :: Kernel -> Doc ann Source # prettyList :: [Kernel] -> Doc ann Source #

data KernelUse Source #

Information about a host-level variable that is used inside this kernel. When generating the actual kernel code, this is used to deduce which parameters are needed.

Constructors

ScalarUse VName PrimType |
MemoryUse VName |
ConstUse VName KernelConstExp |

#### Instances

Instances details

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

Instance details

Defined in Futhark.CodeGen.ImpCode.GPU

Methods

compare :: KernelUse -> KernelUse -> Ordering Source #

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

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

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

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

max :: KernelUse -> KernelUse -> KernelUse Source #

min :: KernelUse -> KernelUse -> KernelUse Source #

Pretty KernelUse Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.GPU Methods pretty :: KernelUse -> Doc ann Source # prettyList :: [KernelUse] -> Doc ann Source #

module Futhark.CodeGen.ImpCode

module Futhark.IR.GPU.Sizes