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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.CodeGen.ImpCode

Contents

- Typed enumerations
- Re-exports from other modules.

Description

ImpCode is an imperative intermediate language used as a stepping stone in code generation. The functional core IR (Futhark.IR.Syntax) gets translated into ImpCode by Futhark.CodeGen.ImpGen. Later we then translate ImpCode to, for example, C.

## Basic design

ImpCode distinguishes between statements (`Code`), which may have side effects, and expressions (`Exp`) which do not. Expressions involve only scalars and have a type. The actual expression definition is in Futhark.Analysis.PrimExp, specifically `PrimExp` and its phantom-typed variant `TPrimExp`.

`Code` is a generic representation parametrised on an extensible arbitrary operation, represented by the `Op` constructor. Specific instantiations of ImpCode, such as Futhark.CodeGen.ImpCode.Multicore, will pass in a specific kind of operation to express backend-specific functionality (in the case of multicore, this is `Multicore`).

## Arrays and memory

ImpCode does not have arrays. `DeclareArray` is for declaring constant array literals, not arrays in general. Instead, ImpCode deals only with memory. Array operations present in core IR programs are turned into `Write`, `Read`, and `Copy` operations that use flat indexes and offsets based on the index function of the original array.

## Scoping

ImpCode is much simpler than the functional core IR; partly because we hope to do less work on it. We don't have real optimisation passes on ImpCode. One result of this simplicity is that ImpCode has a fairly naive view of scoping. The only things that can bring new names into scope are `DeclareMem`, `DeclareScalar`, `DeclareArray`, `For`, and function parameters. In particular, `Op`s cannot bind parameters. The standard workaround is to define `Op`s that retrieve the value of an implicit parameter and assign it to a variable declared with the normal mechanisms. `GetLoopBounds` is an example of this pattern.

## Inspiration

ImpCode was originally inspired by the paper "Defunctionalizing Push Arrays" (FHPC '14).

Synopsis

- data Definitions a = Definitions {
  - defTypes :: OpaqueTypes
  - defConsts :: Constants a
  - defFuns :: Functions a
  }
- newtype Functions a = Functions {
  - unFunctions :: [(Name, Function a)]
  }
- type Function = FunctionT
- data FunctionT a = Function {
  - functionEntry :: Maybe EntryPoint
  - functionOutput :: [Param]
  - functionInput :: [Param]
  - functionBody :: Code a
  }
- data EntryPoint = EntryPoint {
  - entryPointName :: Name
  - entryPointResults :: [(Uniqueness, ExternalValue)]
  - entryPointArgs :: [((Name, Uniqueness), ExternalValue)]
  }
- data Constants a = Constants {
  - constsDecl :: [Param]
  - constsInit :: Code a
  }
- data ValueDesc
  - = ArrayValue VName Space PrimType Signedness [DimSize]
  - | ScalarValue PrimType Signedness VName
- data ExternalValue
  - = OpaqueValue Name [ValueDesc]
  - | TransparentValue ValueDesc
- data Param
  - = MemParam VName Space
  - | ScalarParam VName PrimType
- paramName :: Param -> VName
- type MemSize = SubExp
- type DimSize = SubExp
- data Code a
  - = Skip
  - | (Code a) :>>: (Code a)
  - | For VName Exp (Code a)
  - | While (TExp Bool) (Code a)
  - | DeclareMem VName Space
  - | DeclareScalar VName Volatility PrimType
  - | DeclareArray VName PrimType ArrayContents
  - | Allocate VName (Count Bytes (TExp Int64)) Space
  - | Free VName Space
  - | Copy PrimType [Count Elements (TExp Int64)] (VName, Space) (Count Elements (TExp Int64), [Count Elements (TExp Int64)]) (VName, Space) (Count Elements (TExp Int64), [Count Elements (TExp Int64)])
  - | Write VName (Count Elements (TExp Int64)) PrimType Space Volatility Exp
  - | SetScalar VName Exp
  - | Read VName VName (Count Elements (TExp Int64)) PrimType Space Volatility
  - | SetMem VName VName Space
  - | Call [VName] Name [Arg]
  - | If (TExp Bool) (Code a) (Code a)
  - | Assert Exp (ErrorMsg Exp) (SrcLoc, [SrcLoc])
  - | Comment Text (Code a)
  - | DebugPrint String (Maybe Exp)
  - | TracePrint (ErrorMsg Exp)
  - | Op a
- data PrimValue
  - = IntValue !IntValue
  - | FloatValue !FloatValue
  - | BoolValue !Bool
  - | UnitValue
- type Exp = PrimExp VName
- type TExp t = TPrimExp t VName
- data Volatility
  - = Volatile
  - | Nonvolatile
- data Arg
  - = ExpArg Exp
  - | MemArg VName
- var :: VName -> PrimType -> Exp
- data ArrayContents
  - = ArrayValues [PrimValue]
  - | ArrayZeros Int
- declaredIn :: Code a -> Names
- lexicalMemoryUsage :: Function a -> Map VName Space
- declsFirst :: Code a -> Code a
- calledFuncs :: (a -> Set Name) -> Code a -> Set Name
- callGraph :: (a -> Set Name) -> Functions a -> Map Name (Set Name)
- type ParamMap = Map Name (SizeClass, Set Name)
- data Bytes
- data Elements
- elements :: a -> Count Elements a
- bytes :: a -> Count Bytes a
- withElemType :: Count Elements (TExp Int64) -> PrimType -> Count Bytes (TExp Int64)
- prettyText :: Pretty a => a -> Text
- prettyString :: Pretty a => a -> String
- data Space
  - = DefaultSpace
  - | Space SpaceId
  - | ScalarSpace [SubExp] PrimType
- data ValueType = ValueType Signedness Rank PrimType
- data SubExp
  - = Constant PrimValue
  - | Var VName
- data EntryPointType
  - = TypeOpaque Name
  - | TypeTransparent ValueType
- newtype ErrorMsg a = ErrorMsg [ErrorMsgPart a]
- data ErrorMsgPart a
  - = ErrorString Text
  - | ErrorVal PrimType a
- data OpaqueType
  - = OpaqueType [ValueType]
  - | OpaqueRecord [(Name, EntryPointType)]
  - | OpaqueSum [ValueType] [(Name, [(EntryPointType, [Int])])]
  - | OpaqueArray Int Name [ValueType]
  - | OpaqueRecordArray Int Name [(Name, EntryPointType)]
- newtype OpaqueTypes = OpaqueTypes [(Name, OpaqueType)]
- newtype Rank = Rank Int
- data Signedness
  - = Unsigned
  - | Signed
- type SpaceId = String
- errorMsgArgTypes :: ErrorMsg a -> [PrimType]
- module Language.Futhark.Core
- module Language.Futhark.Primitive
- module Futhark.Analysis.PrimExp
- module Futhark.Analysis.PrimExp.Convert
- newtype Count u e = Count {
  - unCount :: e
  }
- data SizeClass
  - = SizeThreshold KernelPath (Maybe Int64)
  - | SizeThreadBlock
  - | SizeGrid
  - | SizeTile
  - | SizeRegTile
  - | SizeSharedMemory
  - | SizeBespoke Name Int64
  - | SizeRegisters
  - | SizeCache
- module Futhark.IR.Prop.Names

# Documentation

data Definitions a Source #

A collection of imperative functions and constants.

Constructors

Definitions |

Fields

- defTypes :: OpaqueTypes
- defConsts :: Constants a
- defFuns :: Functions a

#### Instances

Instances details

Functor Definitions Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods fmap :: (a -> b) -> Definitions a -> Definitions b Source # (<$) :: a -> Definitions b -> Definitions a Source #
Show a => Show (Definitions a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods showsPrec :: Int -> Definitions a -> ShowS Source # show :: Definitions a -> String Source # showList :: [Definitions a] -> ShowS Source #
Pretty op => Pretty (Definitions op) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods pretty :: Definitions op -> Doc ann Source # prettyList :: [Definitions op] -> Doc ann Source #

newtype Functions a Source #

A collection of imperative functions.

Constructors

Functions |

Fields

- unFunctions :: [(Name, Function a)]

#### Instances

Instances details

Foldable Functions Source # |

Instance details

Defined in Futhark.CodeGen.ImpCode

Methods

fold :: Monoid m => Functions m -> m Source #

foldMap :: Monoid m => (a -> m) -> Functions a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Functions a -> m Source #

foldr :: (a -> b -> b) -> b -> Functions a -> b Source #

foldr' :: (a -> b -> b) -> b -> Functions a -> b Source #

foldl :: (b -> a -> b) -> b -> Functions a -> b Source #

foldl' :: (b -> a -> b) -> b -> Functions a -> b Source #

foldr1 :: (a -> a -> a) -> Functions a -> a Source #

foldl1 :: (a -> a -> a) -> Functions a -> a Source #

toList :: Functions a -> [a] Source #

null :: Functions a -> Bool Source #

length :: Functions a -> Int Source #

elem :: Eq a => a -> Functions a -> Bool Source #

maximum :: Ord a => Functions a -> a Source #

minimum :: Ord a => Functions a -> a Source #

sum :: Num a => Functions a -> a Source #

product :: Num a => Functions a -> a Source #

Traversable Functions Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods traverse :: Applicative f => (a -> f b) -> Functions a -> f (Functions b) Source # sequenceA :: Applicative f => Functions (f a) -> f (Functions a) Source # mapM :: Monad m => (a -> m b) -> Functions a -> m (Functions b) Source # sequence :: Monad m => Functions (m a) -> m (Functions a) Source #
Functor Functions Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods fmap :: (a -> b) -> Functions a -> Functions b Source # (<$) :: a -> Functions b -> Functions a Source #
Monoid (Functions a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods mempty :: Functions a Source # mappend :: Functions a -> Functions a -> Functions a Source # mconcat :: [Functions a] -> Functions a Source #
Semigroup (Functions a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods (<>) :: Functions a -> Functions a -> Functions a Source # sconcat :: NonEmpty (Functions a) -> Functions a Source # stimes :: Integral b => b -> Functions a -> Functions a Source #
Show a => Show (Functions a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods showsPrec :: Int -> Functions a -> ShowS Source # show :: Functions a -> String Source # showList :: [Functions a] -> ShowS Source #
FreeIn a => FreeIn (Functions a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods freeIn' :: Functions a -> FV Source #
Pretty op => Pretty (Functions op) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods pretty :: Functions op -> Doc ann Source # prettyList :: [Functions op] -> Doc ann Source #

type Function = FunctionT Source #

Type alias for namespace control.

data FunctionT a Source #

A imperative function, containing the body as well as its low-level inputs and outputs, as well as its high-level arguments and results. The latter are only present if the function is an entry point.

Constructors

Function |

Fields

- functionEntry :: Maybe EntryPoint
- functionOutput :: [Param]
- functionInput :: [Param]
- functionBody :: Code a

#### Instances

Instances details

Foldable FunctionT Source # |

Instance details

Defined in Futhark.CodeGen.ImpCode

Methods

fold :: Monoid m => FunctionT m -> m Source #

foldMap :: Monoid m => (a -> m) -> FunctionT a -> m Source #

foldMap' :: Monoid m => (a -> m) -> FunctionT a -> m Source #

foldr :: (a -> b -> b) -> b -> FunctionT a -> b Source #

foldr' :: (a -> b -> b) -> b -> FunctionT a -> b Source #

foldl :: (b -> a -> b) -> b -> FunctionT a -> b Source #

foldl' :: (b -> a -> b) -> b -> FunctionT a -> b Source #

foldr1 :: (a -> a -> a) -> FunctionT a -> a Source #

foldl1 :: (a -> a -> a) -> FunctionT a -> a Source #

toList :: FunctionT a -> [a] Source #

null :: FunctionT a -> Bool Source #

length :: FunctionT a -> Int Source #

elem :: Eq a => a -> FunctionT a -> Bool Source #

maximum :: Ord a => FunctionT a -> a Source #

minimum :: Ord a => FunctionT a -> a Source #

sum :: Num a => FunctionT a -> a Source #

product :: Num a => FunctionT a -> a Source #

Traversable FunctionT Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods traverse :: Applicative f => (a -> f b) -> FunctionT a -> f (FunctionT b) Source # sequenceA :: Applicative f => FunctionT (f a) -> f (FunctionT a) Source # mapM :: Monad m => (a -> m b) -> FunctionT a -> m (FunctionT b) Source # sequence :: Monad m => FunctionT (m a) -> m (FunctionT a) Source #
Functor FunctionT Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods fmap :: (a -> b) -> FunctionT a -> FunctionT b Source # (<$) :: a -> FunctionT b -> FunctionT a Source #
Show a => Show (FunctionT a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods showsPrec :: Int -> FunctionT a -> ShowS Source # show :: FunctionT a -> String Source # showList :: [FunctionT a] -> ShowS Source #
Pretty op => Pretty (FunctionT op) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods pretty :: FunctionT op -> Doc ann Source # prettyList :: [FunctionT op] -> Doc ann Source #

data EntryPoint Source #

Information about how this function can be called from the outside world.

Constructors

EntryPoint |

Fields

- entryPointName :: Name
- entryPointResults :: [(Uniqueness, ExternalValue)]
- entryPointArgs :: [((Name, Uniqueness), ExternalValue)]

#### Instances

Instances details

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

data Constants a Source #

A collection of imperative constants.

Constructors

Constants |

Fields

- constsDecl :: [Param]

  The constants that are made available to the functions.

- constsInit :: Code a

  Setting the value of the constants. Note that this must not contain declarations of the names defined in `constsDecl`.

#### Instances

Instances details

Functor Constants Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods fmap :: (a -> b) -> Constants a -> Constants b Source # (<$) :: a -> Constants b -> Constants a Source #
Monoid (Constants a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods mempty :: Constants a Source # mappend :: Constants a -> Constants a -> Constants a Source # mconcat :: [Constants a] -> Constants a Source #
Semigroup (Constants a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods (<>) :: Constants a -> Constants a -> Constants a Source # sconcat :: NonEmpty (Constants a) -> Constants a Source # stimes :: Integral b => b -> Constants a -> Constants a Source #
Show a => Show (Constants a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods showsPrec :: Int -> Constants a -> ShowS Source # show :: Constants a -> String Source # showList :: [Constants a] -> ShowS Source #
Pretty op => Pretty (Constants op) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods pretty :: Constants op -> Doc ann Source # prettyList :: [Constants op] -> Doc ann Source #

data ValueDesc Source #

A description of an externally meaningful value.

Constructors

ArrayValue VName Space PrimType Signedness [DimSize] | An array with memory block memory space, element type, signedness of element type (if applicable), and shape.
ScalarValue PrimType Signedness VName | A scalar value with signedness if applicable.

#### Instances

Instances details

Show ValueDesc Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods showsPrec :: Int -> ValueDesc -> ShowS Source # show :: ValueDesc -> String Source # showList :: [ValueDesc] -> ShowS Source #
FreeIn ValueDesc Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods freeIn' :: ValueDesc -> FV Source #
Eq ValueDesc Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods (==) :: ValueDesc -> ValueDesc -> Bool Source # (/=) :: ValueDesc -> ValueDesc -> Bool Source #
Pretty ValueDesc Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods pretty :: ValueDesc -> Doc ann Source # prettyList :: [ValueDesc] -> Doc ann Source #

data ExternalValue Source #

^ An externally visible value. This can be an opaque value (covering several physical internal values), or a single value that can be used externally. We record the uniqueness because it is important to the external interface as well.

Constructors

OpaqueValue Name [ValueDesc] | The string is a human-readable description with no other semantics.
TransparentValue ValueDesc |

#### Instances

Instances details

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

data Param Source #

An ImpCode function parameter.

Constructors

MemParam VName Space |
ScalarParam VName PrimType |

#### Instances

Instances details

Show Param Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods showsPrec :: Int -> Param -> ShowS Source # show :: Param -> String Source # showList :: [Param] -> ShowS Source #
Eq Param Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods (==) :: Param -> Param -> Bool Source # (/=) :: Param -> Param -> Bool Source #
Pretty Param Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods pretty :: Param -> Doc ann Source # prettyList :: [Param] -> Doc ann Source #

paramName :: Param -> VName Source #

The name of a parameter.

type MemSize = SubExp Source #

The size of a memory block.

type DimSize = SubExp Source #

The size of an array.

data Code a Source #

A block of imperative code. Parameterised by an `Op`, which allows extensibility. Concrete uses of this type will instantiate the type parameter with e.g. a construct for launching GPU kernels.

Constructors

Skip | No-op. Crucial for the `Monoid` instance.
(:>>:) |

Fields

- (Code a)

  Statement composition. Crucial for the `Semigroup` instance.

- (Code a)

For VName Exp (Code a) | A for-loop iterating the given number of times. The loop parameter starts counting from zero and will have the same (integer) type as the bound. The bound is evaluated just once, before the loop is entered.
While (TExp Bool) (Code a) | While loop. The conditional is (of course) re-evaluated before every iteration of the loop.
DeclareMem VName Space | Declare a memory block variable that will point to memory in the given memory space. Note that this is distinct from allocation. The memory block must be the target of either an `Allocate` or a `SetMem` before it can be used for reading or writing.
DeclareScalar VName Volatility PrimType | Declare a scalar variable with an initially undefined value.
DeclareArray VName PrimType ArrayContents | Create a DefaultSpace array containing the given values. The lifetime of the array will be the entire application. This is mostly used for constant arrays.
Allocate VName (Count Bytes (TExp Int64)) Space | Memory space must match the corresponding `DeclareMem`.
Free VName Space | Indicate that some memory block will never again be referenced via the indicated variable. However, it may still be accessed through aliases. It is only safe to actually deallocate the memory block if this is the last reference. There is no guarantee that all memory blocks will be freed with this statement. Backends are free to ignore it entirely.
Copy PrimType [Count Elements (TExp Int64)] (VName, Space) (Count Elements (TExp Int64), [Count Elements (TExp Int64)]) (VName, Space) (Count Elements (TExp Int64), [Count Elements (TExp Int64)]) | `Copy pt shape dest dest_lmad src src_lmad`.
Write VName (Count Elements (TExp Int64)) PrimType Space Volatility Exp | `Write mem i t space vol v` writes the value `v` to `mem` offset by `i` elements of type `t`. The `Space` argument is the memory space of `mem` (technically redundant, but convenient).
SetScalar VName Exp | Set a scalar variable.
Read VName VName (Count Elements (TExp Int64)) PrimType Space Volatility | Read a scalar from memory from memory. The first `VName` is the target scalar variable, and the remaining arguments have the same meaning as with `Write`.
SetMem VName VName Space | Must be in same space.
Call [VName] Name [Arg] | Function call. The results are written to the provided `VName` variables.
If (TExp Bool) (Code a) (Code a) | Conditional execution.
Assert Exp (ErrorMsg Exp) (SrcLoc, [SrcLoc]) | Assert that something must be true. Should it turn out not to be true, then report a failure along with the given error message.
Comment Text (Code a) | Has the same semantics as the contained code, but the comment should show up in generated code for ease of inspection.
DebugPrint String (Maybe Exp) | Print the given value to the screen, somehow annotated with the given string as a description. If no type/value pair, just print the string. This has no semantic meaning, but is used entirely for debugging. Code generators are free to ignore this statement.
TracePrint (ErrorMsg Exp) | Log the given message, *without* a trailing linebreak (unless part of the message).
Op a | Perform an extensible operation.

#### Instances

Instances details

Foldable Code Source # |

Instance details

Defined in Futhark.CodeGen.ImpCode

Methods

fold :: Monoid m => Code m -> m Source #

foldMap :: Monoid m => (a -> m) -> Code a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Code a -> m Source #

foldr :: (a -> b -> b) -> b -> Code a -> b Source #

foldr' :: (a -> b -> b) -> b -> Code a -> b Source #

foldl :: (b -> a -> b) -> b -> Code a -> b Source #

foldl' :: (b -> a -> b) -> b -> Code a -> b Source #

foldr1 :: (a -> a -> a) -> Code a -> a Source #

foldl1 :: (a -> a -> a) -> Code a -> a Source #

toList :: Code a -> [a] Source #

null :: Code a -> Bool Source #

length :: Code a -> Int Source #

elem :: Eq a => a -> Code a -> Bool Source #

maximum :: Ord a => Code a -> a Source #

minimum :: Ord a => Code a -> a Source #

sum :: Num a => Code a -> a Source #

product :: Num a => Code a -> a Source #

Traversable Code Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods traverse :: Applicative f => (a -> f b) -> Code a -> f (Code b) Source # sequenceA :: Applicative f => Code (f a) -> f (Code a) Source # mapM :: Monad m => (a -> m b) -> Code a -> m (Code b) Source # sequence :: Monad m => Code (m a) -> m (Code a) Source #
Functor Code Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods fmap :: (a -> b) -> Code a -> Code b Source # (<$) :: a -> Code b -> Code a Source #
Monoid (Code a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods mempty :: Code a Source # mappend :: Code a -> Code a -> Code a Source # mconcat :: [Code a] -> Code a Source #
Semigroup (Code a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods (<>) :: Code a -> Code a -> Code a Source # sconcat :: NonEmpty (Code a) -> Code a Source # stimes :: Integral b => b -> Code a -> Code a Source #
Show a => Show (Code a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods showsPrec :: Int -> Code a -> ShowS Source # show :: Code a -> String Source # showList :: [Code a] -> ShowS Source #
FreeIn a => FreeIn (Code a) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods freeIn' :: Code a -> FV Source #
Pretty op => Pretty (Code op) Source # |
Instance details Defined in Futhark.CodeGen.ImpCode Methods pretty :: Code op -> Doc ann Source # prettyList :: [Code op] -> Doc ann Source #

data PrimValue Source #

Non-array values.

Constructors

IntValue !IntValue |
FloatValue !FloatValue |
BoolValue !Bool |
UnitValue | The only value of type `Unit`.

#### Instances

Instances details

Show PrimValue Source # |
Instance details Defined in Language.Futhark.Primitive Methods showsPrec :: Int -> PrimValue -> ShowS Source # show :: PrimValue -> String Source # showList :: [PrimValue] -> ShowS Source #
IsValue PrimValue Source # |
Instance details Defined in Futhark.IR.Prop.Constants Methods value :: PrimValue -> PrimValue Source #
Eq PrimValue Source # |
Instance details Defined in Language.Futhark.Primitive Methods (==) :: PrimValue -> PrimValue -> Bool Source # (/=) :: PrimValue -> PrimValue -> Bool Source #
Ord PrimValue Source # |

Instance details

Defined in Language.Futhark.Primitive

Methods

compare :: PrimValue -> PrimValue -> Ordering Source #

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

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

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

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

max :: PrimValue -> PrimValue -> PrimValue Source #

min :: PrimValue -> PrimValue -> PrimValue Source #

ToExp PrimValue Source # |
Instance details Defined in Futhark.CodeGen.Backends.SimpleRep Methods toExp :: PrimValue -> SrcLoc -> Exp Source #
Pretty PrimValue Source # |
Instance details Defined in Language.Futhark.Primitive Methods pretty :: PrimValue -> Doc ann Source # prettyList :: [PrimValue] -> Doc ann Source #

type Exp = PrimExp VName Source #

A side-effect free expression whose execution will produce a single primitive value.

type TExp t = TPrimExp t VName Source #

Like `Exp`, but with a required/known type.

data Volatility Source #

The volatility of a memory access or variable. Feel free to ignore this for backends where it makes no sense (anything but C and similar low-level things)

Constructors

Volatile |
Nonvolatile |

#### Instances

Instances details

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

Instance details

Defined in Futhark.CodeGen.ImpCode

Methods

compare :: Volatility -> Volatility -> Ordering Source #

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

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

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

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

max :: Volatility -> Volatility -> Volatility Source #

min :: Volatility -> Volatility -> Volatility Source #

data Arg Source #

A function call argument.

Constructors

ExpArg Exp |
MemArg VName |

#### Instances

Instances details

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

var :: VName -> PrimType -> Exp Source #

Turn a `VName` into a `Exp`.

data ArrayContents Source #

The contents of a statically declared constant array. Such arrays are always unidimensional, and reshaped if necessary in the code that uses them.

Constructors

ArrayValues [PrimValue] | Precisely these values.
ArrayZeros Int | This many zeroes.

#### Instances

Instances details

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

declaredIn :: Code a -> Names Source #

The names declared with `DeclareMem`, `DeclareScalar`, and `DeclareArray` in the given code.

lexicalMemoryUsage :: Function a -> Map VName Space Source #

Find those memory blocks that are used only lexically. That is, are not used as the source or target of a `SetMem`, or are the result of the function, nor passed as arguments to other functions. This is interesting because such memory blocks do not need reference counting, but can be managed in a purely stack-like fashion.

We do not look inside any `Op`s. We assume that no `Op` is going to `SetMem` a memory block declared outside it.

declsFirst :: Code a -> Code a Source #

Reorder the code such that all declarations appear first. This is always possible, because `DeclareScalar` and `DeclareMem` do not depend on any local bindings.

calledFuncs :: (a -> Set Name) -> Code a -> Set Name Source #

The set of functions that are called by this code. Accepts a function for determing function calls in `Op`s.

callGraph :: (a -> Set Name) -> Functions a -> Map Name (Set Name) Source #

Compute call graph, as per `calledFuncs`, but also include transitive calls.

type ParamMap = Map Name (SizeClass, Set Name) Source #

A mapping from names of tuning parameters to their class, as well as which functions make use of them (including transitively).

# Typed enumerations

data Bytes Source #

Phantom type for a count of bytes.

data Elements Source #

Phantom type for a count of elements.

elements :: a -> Count Elements a Source #

This expression counts elements.

bytes :: a -> Count Bytes a Source #

This expression counts bytes.

withElemType :: Count Elements (TExp Int64) -> PrimType -> Count Bytes (TExp Int64) Source #

Convert a count of elements into a count of bytes, given the per-element size.

# Re-exports from other modules.

prettyText :: Pretty a => a -> Text Source #

Prettyprint a value to a `Text`, appropriately wrapped.

prettyString :: Pretty a => a -> String Source #

Prettyprint a value to a `String`, appropriately wrapped.

data Space Source #

The memory space of a block. If `DefaultSpace`, this is the "default" space, whatever that is. The exact meaning of the `SpaceId` depends on the backend used. In GPU kernels, for example, this is used to distinguish between constant, global and shared memory spaces. In GPU-enabled host code, it is used to distinguish between host memory (`DefaultSpace`) and GPU space.

Constructors

DefaultSpace |
Space SpaceId |
ScalarSpace [SubExp] PrimType | A special kind of memory that is a statically sized array of some primitive type. Used for private memory on GPUs.

#### Instances

Instances details

Show Space Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods showsPrec :: Int -> Space -> ShowS Source # show :: Space -> String Source # showList :: [Space] -> ShowS Source #
FreeIn Space Source # |
Instance details Defined in Futhark.IR.Prop.Names Methods freeIn' :: Space -> FV Source #
Simplifiable Space Source # |
Instance details Defined in Futhark.Optimise.Simplify.Engine Methods simplify :: SimplifiableRep rep => Space -> SimpleM rep Space Source #
Eq Space Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (==) :: Space -> Space -> Bool Source # (/=) :: Space -> Space -> Bool Source #
Ord Space Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods compare :: Space -> Space -> Ordering Source # (<) :: Space -> Space -> Bool Source # (<=) :: Space -> Space -> Bool Source # (>) :: Space -> Space -> Bool Source # (>=) :: Space -> Space -> Bool Source # max :: Space -> Space -> Space Source # min :: Space -> Space -> Space Source #
Pretty Space Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: Space -> Doc ann Source # prettyList :: [Space] -> Doc ann Source #

data ValueType Source #

An actual non-opaque type that can be passed to and from Futhark programs, or serve as the contents of opaque types. Scalars are represented with zero rank.

Constructors

ValueType Signedness Rank PrimType |

#### Instances

Instances details

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

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

compare :: ValueType -> ValueType -> Ordering Source #

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

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

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

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

max :: ValueType -> ValueType -> ValueType Source #

min :: ValueType -> ValueType -> ValueType Source #

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

data SubExp Source #

A subexpression is either a scalar constant or a variable. One important property is that evaluation of a subexpression is guaranteed to complete in constant time.

Constructors

Constant PrimValue |
Var VName |

#### Instances

Instances details

Show SubExp Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods showsPrec :: Int -> SubExp -> ShowS Source # show :: SubExp -> String Source # showList :: [SubExp] -> ShowS Source #
ToExp SubExp Source # |
Instance details Defined in Futhark.CodeGen.ImpGen Methods toExp :: SubExp -> ImpM rep r op Exp Source # toExp' :: PrimType -> SubExp -> Exp Source #
ToExp SubExp Source # |
Instance details Defined in Futhark.Construct Methods toExp :: MonadBuilder m => SubExp -> m (Exp (Rep m)) Source #
HasLetDecMem LetDecMem Source # |
Instance details Defined in Futhark.IR.Mem Methods letDecMem :: LetDecMem -> LetDecMem Source #
FreeIn SubExp Source # |
Instance details Defined in Futhark.IR.Prop.Names Methods freeIn' :: SubExp -> FV Source #
DeclExtTyped DeclExtType Source # |
Instance details Defined in Futhark.IR.Prop.Types Methods declExtTypeOf :: DeclExtType -> DeclExtType Source #
DeclTyped DeclType Source # |
Instance details Defined in Futhark.IR.Prop.Types Methods declTypeOf :: DeclType -> DeclType Source #
ExtTyped DeclExtType Source # |
Instance details Defined in Futhark.IR.Prop.Types Methods extTypeOf :: DeclExtType -> ExtType Source #
ExtTyped ExtType Source # |
Instance details Defined in Futhark.IR.Prop.Types Methods extTypeOf :: ExtType -> ExtType Source #
FixExt ExtSize Source # |
Instance details Defined in Futhark.IR.Prop.Types Methods fixExt :: Int -> SubExp -> ExtSize -> ExtSize Source # mapExt :: (Int -> Int) -> ExtSize -> ExtSize Source #
Typed DeclType Source # |
Instance details Defined in Futhark.IR.Prop.Types Methods typeOf :: DeclType -> Type Source #
Typed Type Source # |
Instance details Defined in Futhark.IR.Prop.Types Methods typeOf :: Type -> Type Source #
IsBodyType BodyReturns Source # |
Instance details Defined in Futhark.IR.Mem Methods primBodyType :: PrimType -> BodyReturns Source #
IsBodyType ExtType Source # |
Instance details Defined in Futhark.IR.RetType Methods primBodyType :: PrimType -> ExtType Source #
IsRetType FunReturns Source # |
Instance details Defined in Futhark.IR.Mem Methods primRetType :: PrimType -> FunReturns Source # applyRetType :: Typed dec => [FunReturns] -> [Param dec] -> [(SubExp, Type)] -> Maybe [FunReturns] Source #
IsRetType DeclExtType Source # |
Instance details Defined in Futhark.IR.RetType Methods primRetType :: PrimType -> DeclExtType Source # applyRetType :: Typed dec => [DeclExtType] -> [Param dec] -> [(SubExp, Type)] -> Maybe [DeclExtType] Source #
Simplifiable ExtSize Source # |
Instance details Defined in Futhark.Optimise.Simplify.Engine Methods simplify :: SimplifiableRep rep => ExtSize -> SimpleM rep ExtSize Source #
Simplifiable SubExp Source # |
Instance details Defined in Futhark.Optimise.Simplify.Engine Methods simplify :: SimplifiableRep rep => SubExp -> SimpleM rep SubExp Source #
Rename ExtSize Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: ExtSize -> RenameM ExtSize Source #
Rename SubExp Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: SubExp -> RenameM SubExp Source #
Substitute SubExp Source # |
Instance details Defined in Futhark.Transform.Substitute Methods substituteNames :: Map VName VName -> SubExp -> SubExp Source #
Eq SubExp Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (==) :: SubExp -> SubExp -> Bool Source # (/=) :: SubExp -> SubExp -> Bool Source #
Ord SubExp Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods compare :: SubExp -> SubExp -> Ordering Source # (<) :: SubExp -> SubExp -> Bool Source # (<=) :: SubExp -> SubExp -> Bool Source # (>) :: SubExp -> SubExp -> Bool Source # (>=) :: SubExp -> SubExp -> Bool Source # max :: SubExp -> SubExp -> SubExp Source # min :: SubExp -> SubExp -> SubExp Source #
ToExp SubExp Source # |
Instance details Defined in Futhark.CodeGen.Backends.SimpleRep Methods toExp :: SubExp -> SrcLoc -> Exp Source #
Pretty ExtShape Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: ExtShape -> Doc ann Source # prettyList :: [ExtShape] -> Doc ann Source #
Pretty Shape Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: Shape -> Doc ann Source # prettyList :: [Shape] -> Doc ann Source #
Pretty SubExp Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: SubExp -> Doc ann Source # prettyList :: [SubExp] -> Doc ann Source #
ArrayShape (ShapeBase ExtSize) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods shapeRank :: ShapeBase ExtSize -> Int Source # subShapeOf :: ShapeBase ExtSize -> ShapeBase ExtSize -> Bool Source #
ArrayShape (ShapeBase SubExp) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods shapeRank :: ShapeBase SubExp -> Int Source # subShapeOf :: ShapeBase SubExp -> ShapeBase SubExp -> Bool Source #
Simplifiable [FunReturns] Source # |
Instance details Defined in Futhark.IR.Mem Methods simplify :: SimplifiableRep rep => [FunReturns] -> SimpleM rep [FunReturns] Source #
Pretty u => Pretty (TypeBase ExtShape u) Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: TypeBase ExtShape u -> Doc ann Source # prettyList :: [TypeBase ExtShape u] -> Doc ann Source #
Pretty u => Pretty (TypeBase Shape u) Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: TypeBase Shape u -> Doc ann Source # prettyList :: [TypeBase Shape u] -> Doc ann Source #
FixExt ret => DeclExtTyped (MemInfo ExtSize Uniqueness ret) Source # |
Instance details Defined in Futhark.IR.Mem Methods declExtTypeOf :: MemInfo ExtSize Uniqueness ret -> DeclExtType Source #
DeclTyped (MemInfo SubExp Uniqueness ret) Source # |
Instance details Defined in Futhark.IR.Mem Methods declTypeOf :: MemInfo SubExp Uniqueness ret -> DeclType Source #
FixExt ret => ExtTyped (MemInfo ExtSize NoUniqueness ret) Source # |
Instance details Defined in Futhark.IR.Mem Methods extTypeOf :: MemInfo ExtSize NoUniqueness ret -> ExtType Source #
FixExt ret => ExtTyped (MemInfo ExtSize Uniqueness ret) Source # |
Instance details Defined in Futhark.IR.Mem Methods extTypeOf :: MemInfo ExtSize Uniqueness ret -> ExtType Source #
FixExt ret => FixExt (MemInfo ExtSize u ret) Source # |
Instance details Defined in Futhark.IR.Mem Methods fixExt :: Int -> SubExp -> MemInfo ExtSize u ret -> MemInfo ExtSize u ret Source # mapExt :: (Int -> Int) -> MemInfo ExtSize u ret -> MemInfo ExtSize u ret Source #
Typed (MemInfo SubExp NoUniqueness ret) Source # |
Instance details Defined in Futhark.IR.Mem Methods typeOf :: MemInfo SubExp NoUniqueness ret -> Type Source #
Typed (MemInfo SubExp Uniqueness ret) Source # |
Instance details Defined in Futhark.IR.Mem Methods typeOf :: MemInfo SubExp Uniqueness ret -> Type Source #

data EntryPointType Source #

Every entry point argument and return value has an annotation indicating how it maps to the original source program type.

Constructors

TypeOpaque Name | An opaque type of this name.
TypeTransparent ValueType | A transparent type, which is scalar if the rank is zero.

#### Instances

Instances details

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

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

compare :: EntryPointType -> EntryPointType -> Ordering Source #

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

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

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

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

max :: EntryPointType -> EntryPointType -> EntryPointType Source #

min :: EntryPointType -> EntryPointType -> EntryPointType Source #

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

newtype ErrorMsg a Source #

An error message is a list of error parts, which are concatenated to form the final message.

Constructors

ErrorMsg [ErrorMsgPart a] |

#### Instances

Instances details

Foldable ErrorMsg Source # |

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

fold :: Monoid m => ErrorMsg m -> m Source #

foldMap :: Monoid m => (a -> m) -> ErrorMsg a -> m Source #

foldMap' :: Monoid m => (a -> m) -> ErrorMsg a -> m Source #

foldr :: (a -> b -> b) -> b -> ErrorMsg a -> b Source #

foldr' :: (a -> b -> b) -> b -> ErrorMsg a -> b Source #

foldl :: (b -> a -> b) -> b -> ErrorMsg a -> b Source #

foldl' :: (b -> a -> b) -> b -> ErrorMsg a -> b Source #

foldr1 :: (a -> a -> a) -> ErrorMsg a -> a Source #

foldl1 :: (a -> a -> a) -> ErrorMsg a -> a Source #

toList :: ErrorMsg a -> [a] Source #

null :: ErrorMsg a -> Bool Source #

length :: ErrorMsg a -> Int Source #

elem :: Eq a => a -> ErrorMsg a -> Bool Source #

maximum :: Ord a => ErrorMsg a -> a Source #

minimum :: Ord a => ErrorMsg a -> a Source #

sum :: Num a => ErrorMsg a -> a Source #

product :: Num a => ErrorMsg a -> a Source #

Traversable ErrorMsg Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods traverse :: Applicative f => (a -> f b) -> ErrorMsg a -> f (ErrorMsg b) Source # sequenceA :: Applicative f => ErrorMsg (f a) -> f (ErrorMsg a) Source # mapM :: Monad m => (a -> m b) -> ErrorMsg a -> m (ErrorMsg b) Source # sequence :: Monad m => ErrorMsg (m a) -> m (ErrorMsg a) Source #
Functor ErrorMsg Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods fmap :: (a -> b) -> ErrorMsg a -> ErrorMsg b Source # (<$) :: a -> ErrorMsg b -> ErrorMsg a Source #
IsString (ErrorMsg a) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods fromString :: String -> ErrorMsg a Source #
Monoid (ErrorMsg a) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods mempty :: ErrorMsg a Source # mappend :: ErrorMsg a -> ErrorMsg a -> ErrorMsg a Source # mconcat :: [ErrorMsg a] -> ErrorMsg a Source #
Semigroup (ErrorMsg a) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (<>) :: ErrorMsg a -> ErrorMsg a -> ErrorMsg a Source # sconcat :: NonEmpty (ErrorMsg a) -> ErrorMsg a Source # stimes :: Integral b => b -> ErrorMsg a -> ErrorMsg a Source #
Show a => Show (ErrorMsg a) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods showsPrec :: Int -> ErrorMsg a -> ShowS Source # show :: ErrorMsg a -> String Source # showList :: [ErrorMsg a] -> ShowS Source #
Eq a => Eq (ErrorMsg a) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (==) :: ErrorMsg a -> ErrorMsg a -> Bool Source # (/=) :: ErrorMsg a -> ErrorMsg a -> Bool Source #
Ord a => Ord (ErrorMsg a) Source # |

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

compare :: ErrorMsg a -> ErrorMsg a -> Ordering Source #

(<) :: ErrorMsg a -> ErrorMsg a -> Bool Source #

(<=) :: ErrorMsg a -> ErrorMsg a -> Bool Source #

(>) :: ErrorMsg a -> ErrorMsg a -> Bool Source #

(>=) :: ErrorMsg a -> ErrorMsg a -> Bool Source #

max :: ErrorMsg a -> ErrorMsg a -> ErrorMsg a Source #

min :: ErrorMsg a -> ErrorMsg a -> ErrorMsg a Source #

Pretty a => Pretty (ErrorMsg a) Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: ErrorMsg a -> Doc ann Source # prettyList :: [ErrorMsg a] -> Doc ann Source #

data ErrorMsgPart a Source #

A part of an error message.

Constructors

ErrorString Text | A literal string.
ErrorVal PrimType a | A run-time value.

#### Instances

Instances details

Foldable ErrorMsgPart Source # |

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

fold :: Monoid m => ErrorMsgPart m -> m Source #

foldMap :: Monoid m => (a -> m) -> ErrorMsgPart a -> m Source #

foldMap' :: Monoid m => (a -> m) -> ErrorMsgPart a -> m Source #

foldr :: (a -> b -> b) -> b -> ErrorMsgPart a -> b Source #

foldr' :: (a -> b -> b) -> b -> ErrorMsgPart a -> b Source #

foldl :: (b -> a -> b) -> b -> ErrorMsgPart a -> b Source #

foldl' :: (b -> a -> b) -> b -> ErrorMsgPart a -> b Source #

foldr1 :: (a -> a -> a) -> ErrorMsgPart a -> a Source #

foldl1 :: (a -> a -> a) -> ErrorMsgPart a -> a Source #

toList :: ErrorMsgPart a -> [a] Source #

null :: ErrorMsgPart a -> Bool Source #

length :: ErrorMsgPart a -> Int Source #

elem :: Eq a => a -> ErrorMsgPart a -> Bool Source #

maximum :: Ord a => ErrorMsgPart a -> a Source #

minimum :: Ord a => ErrorMsgPart a -> a Source #

sum :: Num a => ErrorMsgPart a -> a Source #

product :: Num a => ErrorMsgPart a -> a Source #

Traversable ErrorMsgPart Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods traverse :: Applicative f => (a -> f b) -> ErrorMsgPart a -> f (ErrorMsgPart b) Source # sequenceA :: Applicative f => ErrorMsgPart (f a) -> f (ErrorMsgPart a) Source # mapM :: Monad m => (a -> m b) -> ErrorMsgPart a -> m (ErrorMsgPart b) Source # sequence :: Monad m => ErrorMsgPart (m a) -> m (ErrorMsgPart a) Source #
Functor ErrorMsgPart Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods fmap :: (a -> b) -> ErrorMsgPart a -> ErrorMsgPart b Source # (<$) :: a -> ErrorMsgPart b -> ErrorMsgPart a Source #
IsString (ErrorMsgPart a) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods fromString :: String -> ErrorMsgPart a Source #
Show a => Show (ErrorMsgPart a) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods showsPrec :: Int -> ErrorMsgPart a -> ShowS Source # show :: ErrorMsgPart a -> String Source # showList :: [ErrorMsgPart a] -> ShowS Source #
Eq a => Eq (ErrorMsgPart a) Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (==) :: ErrorMsgPart a -> ErrorMsgPart a -> Bool Source # (/=) :: ErrorMsgPart a -> ErrorMsgPart a -> Bool Source #
Ord a => Ord (ErrorMsgPart a) Source # |

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

compare :: ErrorMsgPart a -> ErrorMsgPart a -> Ordering Source #

(<) :: ErrorMsgPart a -> ErrorMsgPart a -> Bool Source #

(<=) :: ErrorMsgPart a -> ErrorMsgPart a -> Bool Source #

(>) :: ErrorMsgPart a -> ErrorMsgPart a -> Bool Source #

(>=) :: ErrorMsgPart a -> ErrorMsgPart a -> Bool Source #

max :: ErrorMsgPart a -> ErrorMsgPart a -> ErrorMsgPart a Source #

min :: ErrorMsgPart a -> ErrorMsgPart a -> ErrorMsgPart a Source #

data OpaqueType Source #

The representation of an opaque type.

Constructors

OpaqueType [ValueType] |
OpaqueRecord [(Name, EntryPointType)] | Note that the field ordering here denote the actual representation - make sure it is preserved.

OpaqueSum [ValueType] [(Name, [(EntryPointType, [Int])])]

Constructor ordering also denotes representation, in that the index of the constructor is the identifying number.

The total values used to represent a sum values is the `ValueType` list. The `Int`s associated with each `EntryPointType` are the indexes of the values used to represent that constructor payload. This is necessary because we deduplicate payloads across constructors.

OpaqueArray Int Name [ValueType] | An array with this rank and named opaque element type.
OpaqueRecordArray Int Name [(Name, EntryPointType)] | An array with known rank and where the elements are this record type.

#### Instances

Instances details

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

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

compare :: OpaqueType -> OpaqueType -> Ordering Source #

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

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

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

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

max :: OpaqueType -> OpaqueType -> OpaqueType Source #

min :: OpaqueType -> OpaqueType -> OpaqueType Source #

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

newtype OpaqueTypes Source #

Names of opaque types and their representation.

Constructors

OpaqueTypes [(Name, OpaqueType)] |

#### Instances

Instances details

Monoid OpaqueTypes Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods mempty :: OpaqueTypes Source # mappend :: OpaqueTypes -> OpaqueTypes -> OpaqueTypes Source # mconcat :: [OpaqueTypes] -> OpaqueTypes Source #
Semigroup OpaqueTypes Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (<>) :: OpaqueTypes -> OpaqueTypes -> OpaqueTypes Source # sconcat :: NonEmpty OpaqueTypes -> OpaqueTypes Source # stimes :: Integral b => b -> OpaqueTypes -> OpaqueTypes Source #
Show OpaqueTypes Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods showsPrec :: Int -> OpaqueTypes -> ShowS Source # show :: OpaqueTypes -> String Source # showList :: [OpaqueTypes] -> ShowS Source #
Eq OpaqueTypes Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (==) :: OpaqueTypes -> OpaqueTypes -> Bool Source # (/=) :: OpaqueTypes -> OpaqueTypes -> Bool Source #
Ord OpaqueTypes Source # |

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

compare :: OpaqueTypes -> OpaqueTypes -> Ordering Source #

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

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

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

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

max :: OpaqueTypes -> OpaqueTypes -> OpaqueTypes Source #

min :: OpaqueTypes -> OpaqueTypes -> OpaqueTypes Source #

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

newtype Rank Source #

The size of an array type as merely the number of dimensions, with no further information.

Constructors

Rank Int |

#### Instances

Instances details

Monoid Rank Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods mempty :: Rank Source # mappend :: Rank -> Rank -> Rank Source # mconcat :: [Rank] -> Rank Source #
Semigroup Rank Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (<>) :: Rank -> Rank -> Rank Source # sconcat :: NonEmpty Rank -> Rank Source # stimes :: Integral b => b -> Rank -> Rank Source #
Show Rank Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods showsPrec :: Int -> Rank -> ShowS Source # show :: Rank -> String Source # showList :: [Rank] -> ShowS Source #
ArrayShape Rank Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods shapeRank :: Rank -> Int Source # subShapeOf :: Rank -> Rank -> Bool Source #
Rename Rank Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Rank -> RenameM Rank Source #
Substitute Rank Source # |
Instance details Defined in Futhark.Transform.Substitute Methods substituteNames :: Map VName VName -> Rank -> Rank Source #
Eq Rank Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods (==) :: Rank -> Rank -> Bool Source # (/=) :: Rank -> Rank -> Bool Source #
Ord Rank Source # |
Instance details Defined in Futhark.IR.Syntax.Core Methods compare :: Rank -> Rank -> Ordering Source # (<) :: Rank -> Rank -> Bool Source # (<=) :: Rank -> Rank -> Bool Source # (>) :: Rank -> Rank -> Bool Source # (>=) :: Rank -> Rank -> Bool Source # max :: Rank -> Rank -> Rank Source # min :: Rank -> Rank -> Rank Source #
Pretty Rank Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: Rank -> Doc ann Source # prettyList :: [Rank] -> Doc ann Source #
Pretty u => Pretty (TypeBase Rank u) Source # |
Instance details Defined in Futhark.IR.Pretty Methods pretty :: TypeBase Rank u -> Doc ann Source # prettyList :: [TypeBase Rank u] -> Doc ann Source #

data Signedness Source #

Since the core language does not care for signedness, but the source language does, entry point input/output information has metadata for integer types (and arrays containing these) that indicate whether they are really unsigned integers. This doesn't matter for non-integer types.

Constructors

Unsigned |
Signed |

#### Instances

Instances details

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

Instance details

Defined in Futhark.IR.Syntax.Core

Methods

compare :: Signedness -> Signedness -> Ordering Source #

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

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

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

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

max :: Signedness -> Signedness -> Signedness Source #

min :: Signedness -> Signedness -> Signedness Source #

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

type SpaceId = String Source #

A string representing a specific non-default memory space.

errorMsgArgTypes :: ErrorMsg a -> [PrimType] Source #

How many non-constant parts does the error message have, and what is their type?

module Language.Futhark.Core

module Language.Futhark.Primitive

module Futhark.Analysis.PrimExp

module Futhark.Analysis.PrimExp.Convert

newtype Count u e Source #

A wrapper supporting a phantom type for indicating what we are counting.

Constructors

Count |

Fields

- unCount :: e

#### Instances

Instances details

Foldable (Count u) Source # |

Instance details

Defined in Futhark.IR.GPU.Sizes

Methods

fold :: Monoid m => Count u m -> m Source #

foldMap :: Monoid m => (a -> m) -> Count u a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Count u a -> m Source #

foldr :: (a -> b -> b) -> b -> Count u a -> b Source #

foldr' :: (a -> b -> b) -> b -> Count u a -> b Source #

foldl :: (b -> a -> b) -> b -> Count u a -> b Source #

foldl' :: (b -> a -> b) -> b -> Count u a -> b Source #

foldr1 :: (a -> a -> a) -> Count u a -> a Source #

foldl1 :: (a -> a -> a) -> Count u a -> a Source #

toList :: Count u a -> [a] Source #

null :: Count u a -> Bool Source #

length :: Count u a -> Int Source #

elem :: Eq a => a -> Count u a -> Bool Source #

maximum :: Ord a => Count u a -> a Source #

minimum :: Ord a => Count u a -> a Source #

sum :: Num a => Count u a -> a Source #

product :: Num a => Count u a -> a Source #

Traversable (Count u) Source # |
Instance details Defined in Futhark.IR.GPU.Sizes Methods traverse :: Applicative f => (a -> f b) -> Count u a -> f (Count u b) Source # sequenceA :: Applicative f => Count u (f a) -> f (Count u a) Source # mapM :: Monad m => (a -> m b) -> Count u a -> m (Count u b) Source # sequence :: Monad m => Count u (m a) -> m (Count u a) Source #
Functor (Count u) Source # |
Instance details Defined in Futhark.IR.GPU.Sizes Methods fmap :: (a -> b) -> Count u a -> Count u b Source # (<$) :: a -> Count u b -> Count u a Source #
Num e => Num (Count u e) Source # |
Instance details Defined in Futhark.IR.GPU.Sizes Methods (+) :: Count u e -> Count u e -> Count u e Source # (-) :: Count u e -> Count u e -> Count u e Source # (*) :: Count u e -> Count u e -> Count u e Source # negate :: Count u e -> Count u e Source # abs :: Count u e -> Count u e Source # signum :: Count u e -> Count u e Source # fromInteger :: Integer -> Count u e Source #
Show e => Show (Count u e) Source # |
Instance details Defined in Futhark.IR.GPU.Sizes Methods showsPrec :: Int -> Count u e -> ShowS Source # show :: Count u e -> String Source # showList :: [Count u e] -> ShowS Source #
FreeIn e => FreeIn (Count u e) Source # |
Instance details Defined in Futhark.IR.GPU.Sizes Methods freeIn' :: Count u e -> FV Source #
Substitute e => Substitute (Count u e) Source # |
Instance details Defined in Futhark.IR.GPU.Sizes Methods substituteNames :: Map VName VName -> Count u e -> Count u e Source #
IntegralExp e => IntegralExp (Count u e) Source # |

Instance details

Defined in Futhark.IR.GPU.Sizes

Methods

quot :: Count u e -> Count u e -> Count u e Source #

rem :: Count u e -> Count u e -> Count u e Source #

div :: Count u e -> Count u e -> Count u e Source #

mod :: Count u e -> Count u e -> Count u e Source #

sgn :: Count u e -> Maybe Int Source #

pow :: Count u e -> Count u e -> Count u e Source #

divUp :: Count u e -> Count u e -> Count u e Source #

nextMul :: Count u e -> Count u e -> Count u e Source #

Eq e => Eq (Count u e) Source # |
Instance details Defined in Futhark.IR.GPU.Sizes Methods (==) :: Count u e -> Count u e -> Bool Source # (/=) :: Count u e -> Count u e -> Bool Source #
Ord e => Ord (Count u e) Source # |

Instance details

Defined in Futhark.IR.GPU.Sizes

Methods

compare :: Count u e -> Count u e -> Ordering Source #

(<) :: Count u e -> Count u e -> Bool Source #

(<=) :: Count u e -> Count u e -> Bool Source #

(>) :: Count u e -> Count u e -> Bool Source #

(>=) :: Count u e -> Count u e -> Bool Source #

max :: Count u e -> Count u e -> Count u e Source #

min :: Count u e -> Count u e -> Count u e Source #

Pretty e => Pretty (Count u e) Source # |
Instance details Defined in Futhark.IR.GPU.Sizes Methods pretty :: Count u e -> Doc ann Source # prettyList :: [Count u e] -> Doc ann Source #

data SizeClass Source #

The class of some kind of configurable size. Each class may impose constraints on the valid values.

Constructors

SizeThreshold KernelPath (Maybe Int64) | A threshold with an optional default.
SizeThreadBlock |
SizeGrid | The number of thread blocks.
SizeTile |
SizeRegTile |
SizeSharedMemory | Likely not useful on its own, but querying the maximum can be handy.
SizeBespoke Name Int64 | A bespoke size with a default.
SizeRegisters | Amount of registers available per threadblock. Mostly meaningful for querying the maximum.
SizeCache | Amount of L2 cache memory, in bytes. Mostly meaningful for querying the maximum.

#### Instances

Instances details

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

Instance details

Defined in Futhark.IR.GPU.Sizes

Methods

compare :: SizeClass -> SizeClass -> Ordering Source #

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

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

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

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

max :: SizeClass -> SizeClass -> SizeClass Source #

min :: SizeClass -> SizeClass -> SizeClass Source #

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

module Futhark.IR.Prop.Names