Safe Haskell | None |
---|---|
Language | Haskell2010 |
Imperative code with an OpenCL component.
Apart from ordinary imperative code, this also carries around an OpenCL program as a string, as well as a list of kernels defined by the OpenCL program.
The imperative code has been augmented with a LaunchKernel
operation that allows one to execute an OpenCL kernel.
Synopsis
- data Program = Program {}
- type Function = Function OpenCL
- data FunctionT a = Function Bool [Param] [Param] (Code a) [ExternalValue] [ExternalValue]
- type Code = Code OpenCL
- type KernelName = String
- data KernelArg
- data OpenCL
- data KernelTarget
- data Int8
- data Int16
- data Int32
- data Int64
- data Word8
- data Word16
- data Word32
- data Word64
- pretty :: Pretty a => a -> String
- data ConvOp
- data CmpOp
- data BinOp
- = Add IntType
- | FAdd FloatType
- | Sub IntType
- | FSub FloatType
- | Mul IntType
- | FMul FloatType
- | UDiv IntType
- | SDiv IntType
- | FDiv FloatType
- | UMod IntType
- | SMod IntType
- | SQuot IntType
- | SRem IntType
- | SMin IntType
- | UMin IntType
- | FMin FloatType
- | SMax IntType
- | UMax IntType
- | FMax FloatType
- | Shl IntType
- | LShr IntType
- | AShr IntType
- | And IntType
- | Or IntType
- | Xor IntType
- | Pow IntType
- | FPow FloatType
- | LogAnd
- | LogOr
- data UnOp
- data PrimValue
- = IntValue !IntValue
- | FloatValue !FloatValue
- | BoolValue !Bool
- | Checked
- data FloatValue
- data IntValue
- = Int8Value !Int8
- | Int16Value !Int16
- | Int32Value !Int32
- | Int64Value !Int64
- data PrimType
- data FloatType
- data IntType
- allIntTypes :: [IntType]
- allFloatTypes :: [FloatType]
- allPrimTypes :: [PrimType]
- intValue :: Integral int => IntType -> int -> IntValue
- intValueType :: IntValue -> IntType
- valueIntegral :: Integral int => IntValue -> int
- floatValue :: Real num => FloatType -> num -> FloatValue
- floatValueType :: FloatValue -> FloatType
- primValueType :: PrimValue -> PrimType
- blankPrimValue :: PrimType -> PrimValue
- allUnOps :: [UnOp]
- allBinOps :: [BinOp]
- allCmpOps :: [CmpOp]
- allConvOps :: [ConvOp]
- doUnOp :: UnOp -> PrimValue -> Maybe PrimValue
- doComplement :: IntValue -> IntValue
- doAbs :: IntValue -> IntValue
- doFAbs :: FloatValue -> FloatValue
- doSSignum :: IntValue -> IntValue
- doUSignum :: IntValue -> IntValue
- doBinOp :: BinOp -> PrimValue -> PrimValue -> Maybe PrimValue
- doAdd :: IntValue -> IntValue -> IntValue
- doMul :: IntValue -> IntValue -> IntValue
- doSDiv :: IntValue -> IntValue -> Maybe IntValue
- doSMod :: IntValue -> IntValue -> Maybe IntValue
- doPow :: IntValue -> IntValue -> Maybe IntValue
- doConvOp :: ConvOp -> PrimValue -> Maybe PrimValue
- doZExt :: IntValue -> IntType -> IntValue
- doSExt :: IntValue -> IntType -> IntValue
- doFPConv :: FloatValue -> FloatType -> FloatValue
- doFPToUI :: FloatValue -> IntType -> IntValue
- doFPToSI :: FloatValue -> IntType -> IntValue
- doUIToFP :: IntValue -> FloatType -> FloatValue
- doSIToFP :: IntValue -> FloatType -> FloatValue
- doCmpOp :: CmpOp -> PrimValue -> PrimValue -> Maybe Bool
- doCmpEq :: PrimValue -> PrimValue -> Bool
- doCmpUlt :: IntValue -> IntValue -> Bool
- doCmpUle :: IntValue -> IntValue -> Bool
- doCmpSlt :: IntValue -> IntValue -> Bool
- doCmpSle :: IntValue -> IntValue -> Bool
- doFCmpLt :: FloatValue -> FloatValue -> Bool
- doFCmpLe :: FloatValue -> FloatValue -> Bool
- intToWord64 :: IntValue -> Word64
- intToInt64 :: IntValue -> Int64
- binOpType :: BinOp -> PrimType
- cmpOpType :: CmpOp -> PrimType
- unOpType :: UnOp -> PrimType
- convOpType :: ConvOp -> (PrimType, PrimType)
- primFuns :: Map String ([PrimType], PrimType, [PrimValue] -> Maybe PrimValue)
- zeroIsh :: PrimValue -> Bool
- oneIsh :: PrimValue -> Bool
- negativeIsh :: PrimValue -> Bool
- primBitSize :: PrimType -> Int
- primByteSize :: Num a => PrimType -> a
- intByteSize :: Num a => IntType -> a
- floatByteSize :: Num a => FloatType -> a
- commutativeBinOp :: BinOp -> Bool
- convOpFun :: ConvOp -> String
- prettySigned :: Bool -> PrimType -> String
- data VName = VName !Name !Int
- data Name
- data Commutativity
- data StreamOrd
- data Uniqueness
- defaultEntryPoint :: Name
- nameToString :: Name -> String
- nameFromString :: String -> Name
- nameToText :: Name -> Text
- nameFromText :: Text -> Name
- locStr :: SrcLoc -> String
- baseTag :: VName -> Int
- baseName :: VName -> Name
- baseString :: VName -> String
- data ErrorMsgPart a
- = ErrorString String
- | ErrorInt32 a
- newtype ErrorMsg a = ErrorMsg [ErrorMsgPart a]
- type SpaceId = String
- data Space
- data PrimExp v
- constFoldPrimExp :: PrimExp v -> PrimExp v
- (.&&.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.||.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.<.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.<=.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.==.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.>.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.>=.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.&.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.|.) :: PrimExp v -> PrimExp v -> PrimExp v
- (.^.) :: PrimExp v -> PrimExp v -> PrimExp v
- evalPrimExp :: (Pretty v, Monad m) => (v -> m PrimValue) -> PrimExp v -> m PrimValue
- primExpType :: PrimExp v -> PrimType
- coerceIntPrimExp :: IntType -> PrimExp v -> PrimExp v
- true :: PrimExp v
- false :: PrimExp v
- data Bytes
- data Elements
- newtype Count u = Count {}
- data Arg
- type Exp = PrimExp ExpLeaf
- data ExpLeaf
- data Volatility
- pattern If :: Exp -> Code a -> Code a -> Code a
- pattern Op :: a -> Code a
- pattern Write :: VName -> Count Bytes -> PrimType -> Space -> Volatility -> Exp -> Code a
- pattern Comment :: String -> Code a -> Code a
- pattern Skip :: Code a
- pattern Free :: VName -> Space -> Code a
- pattern While :: Exp -> Code a -> Code a
- pattern For :: VName -> IntType -> Exp -> Code a -> Code a
- pattern Allocate :: VName -> Count Bytes -> Space -> Code a
- pattern Copy :: VName -> Count Bytes -> Space -> VName -> Count Bytes -> Space -> Count Bytes -> Code a
- pattern Assert :: Exp -> ErrorMsg Exp -> (SrcLoc, [SrcLoc]) -> Code a
- pattern (:>>:) :: Code a -> Code a -> Code a
- pattern DeclareMem :: VName -> Space -> Code a
- pattern DeclareScalar :: VName -> PrimType -> Code a
- pattern DeclareArray :: VName -> Space -> PrimType -> ArrayContents -> Code a
- pattern SetScalar :: VName -> Exp -> Code a
- pattern SetMem :: VName -> VName -> Space -> Code a
- pattern Call :: [VName] -> Name -> [Arg] -> Code a
- pattern DebugPrint :: String -> PrimType -> Exp -> Code a
- data ArrayContents
- data FunctionT a
- data ExternalValue
- data ValueDesc
- data Signedness
- newtype Functions a = Functions [(Name, Function a)]
- data Param
- data Type
- type DimSize = Size
- type MemSize = Size
- data Size
- paramName :: Param -> VName
- elements :: Exp -> Count Elements
- bytes :: Exp -> Count Bytes
- withElemType :: Count Elements -> PrimType -> Count Bytes
- dimSizeToExp :: DimSize -> Count Elements
- memSizeToExp :: MemSize -> Count Bytes
- sizeToExp :: Size -> Exp
- var :: VName -> PrimType -> Exp
- index :: VName -> Count Bytes -> PrimType -> Space -> Volatility -> Exp
- module Futhark.Representation.Kernels.Sizes
Documentation
An program calling OpenCL kernels.
Program | |
|
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 used if the function is an entry point.
Function Bool [Param] [Param] (Code a) [ExternalValue] [ExternalValue] |
Instances
Functor FunctionT Source # | |
Foldable FunctionT Source # | |
Defined in Futhark.CodeGen.ImpCode fold :: Monoid m => FunctionT m -> m # foldMap :: Monoid m => (a -> m) -> FunctionT a -> m # foldr :: (a -> b -> b) -> b -> FunctionT a -> b # foldr' :: (a -> b -> b) -> b -> FunctionT a -> b # foldl :: (b -> a -> b) -> b -> FunctionT a -> b # foldl' :: (b -> a -> b) -> b -> FunctionT a -> b # foldr1 :: (a -> a -> a) -> FunctionT a -> a # foldl1 :: (a -> a -> a) -> FunctionT a -> a # toList :: FunctionT a -> [a] # length :: FunctionT a -> Int # elem :: Eq a => a -> FunctionT a -> Bool # maximum :: Ord a => FunctionT a -> a # minimum :: Ord a => FunctionT a -> a # | |
Traversable FunctionT Source # | |
Defined in Futhark.CodeGen.ImpCode | |
Show a => Show (FunctionT a) Source # | |
Pretty op => Pretty (FunctionT op) Source # | |
type KernelName = String Source #
The name of a kernel.
An argument to be passed to a kernel.
Host-level OpenCL operation.
LaunchKernel KernelName [KernelArg] [Exp] [Exp] | |
HostCode Code | |
GetSize VName Name | |
CmpSizeLe VName Name Exp | |
GetSizeMax VName SizeClass |
data KernelTarget Source #
The target platform when compiling imperative code to a Program
Instances
Eq KernelTarget Source # | |
Defined in Futhark.CodeGen.ImpCode.OpenCL (==) :: KernelTarget -> KernelTarget -> Bool # (/=) :: KernelTarget -> KernelTarget -> Bool # |
8-bit signed integer type
Instances
16-bit signed integer type
Instances
32-bit signed integer type
Instances
64-bit signed integer type
Instances
8-bit unsigned integer type
Instances
16-bit unsigned integer type
Instances
32-bit unsigned integer type
Instances
64-bit unsigned integer type
Instances
Conversion operators try to generalise the from t0 x to t1
instructions from LLVM.
ZExt IntType IntType | Zero-extend the former integer type to the latter. If the new type is smaller, the result is a truncation. |
SExt IntType IntType | Sign-extend the former integer type to the latter. If the new type is smaller, the result is a truncation. |
FPConv FloatType FloatType | Convert value of the former floating-point type to the latter. If the new type is smaller, the result is a truncation. |
FPToUI FloatType IntType | Convert a floating-point value to the nearest unsigned integer (rounding towards zero). |
FPToSI FloatType IntType | Convert a floating-point value to the nearest signed integer (rounding towards zero). |
UIToFP IntType FloatType | Convert an unsigned integer to a floating-point value. |
SIToFP IntType FloatType | Convert a signed integer to a floating-point value. |
IToB IntType | Convert an integer to a boolean value. Zero becomes false; anything else is true. |
BToI IntType | Convert a boolean to an integer. True is converted to 1 and False to 0. |
Comparison operators are like BinOp
s, but they return PrimType
s.
The somewhat ugly constructor names are straight out of LLVM.
CmpEq PrimType | All types equality. |
CmpUlt IntType | Unsigned less than. |
CmpUle IntType | Unsigned less than or equal. |
CmpSlt IntType | Signed less than. |
CmpSle IntType | Signed less than or equal. |
FCmpLt FloatType | Floating-point less than. |
FCmpLe FloatType | Floating-point less than or equal. |
CmpLlt | Boolean less than. |
CmpLle | Boolean less than or equal. |
Binary operators. These correspond closely to the binary operators in LLVM. Most are parametrised by their expected input and output types.
Add IntType | Integer addition. |
FAdd FloatType | Floating-point addition. |
Sub IntType | Integer subtraction. |
FSub FloatType | Floating-point subtraction. |
Mul IntType | Integer multiplication. |
FMul FloatType | Floating-point multiplication. |
UDiv IntType | Unsigned integer division. Rounds towards negativity infinity. Note: this is different from LLVM. |
SDiv IntType | Signed integer division. Rounds towards negativity infinity. Note: this is different from LLVM. |
FDiv FloatType | Floating-point division. |
UMod IntType | Unsigned integer modulus; the countepart to |
SMod IntType | Signed integer modulus; the countepart to |
SQuot IntType | Signed integer division. Rounds towards zero.
This corresponds to the |
SRem IntType | Signed integer division. Rounds towards zero.
This corresponds to the |
SMin IntType | Returns the smallest of two signed integers. |
UMin IntType | Returns the smallest of two unsigned integers. |
FMin FloatType | Returns the smallest of two floating-point numbers. |
SMax IntType | Returns the greatest of two signed integers. |
UMax IntType | Returns the greatest of two unsigned integers. |
FMax FloatType | Returns the greatest of two floating-point numbers. |
Shl IntType | Left-shift. |
LShr IntType | Logical right-shift, zero-extended. |
AShr IntType | Arithmetic right-shift, sign-extended. |
And IntType | Bitwise and. |
Or IntType | Bitwise or. |
Xor IntType | Bitwise exclusive-or. |
Pow IntType | Integer exponentiation. |
FPow FloatType | Floating-point exponentiation. |
LogAnd | Boolean and - not short-circuiting. |
LogOr | Boolean or - not short-circuiting. |
Various unary operators. It is a bit ad-hoc what is a unary operator and what is a built-in function. Perhaps these should all go away eventually.
Not | E.g., |
Complement IntType | E.g., |
Abs IntType |
|
FAbs FloatType |
|
SSignum IntType | Signed sign function: |
USignum IntType | Unsigned sign function: |
Non-array values.
IntValue !IntValue | |
FloatValue !FloatValue | |
BoolValue !Bool | |
Checked | The only value of type |
data FloatValue Source #
A floating-point value.
Instances
An integer value.
Low-level primitive types.
Instances
Bounded PrimType Source # | |
Enum PrimType Source # | |
Defined in Futhark.Representation.Primitive | |
Eq PrimType Source # | |
Ord PrimType Source # | |
Defined in Futhark.Representation.Primitive | |
Show PrimType Source # | |
Pretty PrimType Source # | |
A floating point type.
Instances
Bounded FloatType Source # | |
Enum FloatType Source # | |
Defined in Futhark.Representation.Primitive succ :: FloatType -> FloatType # pred :: FloatType -> FloatType # fromEnum :: FloatType -> Int # enumFrom :: FloatType -> [FloatType] # enumFromThen :: FloatType -> FloatType -> [FloatType] # enumFromTo :: FloatType -> FloatType -> [FloatType] # enumFromThenTo :: FloatType -> FloatType -> FloatType -> [FloatType] # | |
Eq FloatType Source # | |
Ord FloatType Source # | |
Defined in Futhark.Representation.Primitive | |
Show FloatType Source # | |
Pretty FloatType Source # | |
An integer type, ordered by size. Note that signedness is not a property of the type, but a property of the operations performed on values of these types.
Instances
Bounded IntType Source # | |
Enum IntType Source # | |
Eq IntType Source # | |
Ord IntType Source # | |
Defined in Futhark.Representation.Primitive | |
Show IntType Source # | |
Pretty IntType Source # | |
allIntTypes :: [IntType] Source #
A list of all integer types.
allFloatTypes :: [FloatType] Source #
A list of all floating-point types.
allPrimTypes :: [PrimType] Source #
A list of all primitive types.
intValueType :: IntValue -> IntType Source #
floatValue :: Real num => FloatType -> num -> FloatValue Source #
Create a FloatValue
from a type and a Rational
.
floatValueType :: FloatValue -> FloatType Source #
primValueType :: PrimValue -> PrimType Source #
The type of a basic value.
blankPrimValue :: PrimType -> PrimValue Source #
A "blank" value of the given primitive type - this is zero, or whatever is close to it. Don't depend on this value, but use it for e.g. creating arrays to be populated by do-loops.
allConvOps :: [ConvOp] Source #
A list of all conversion operators for all types.
doComplement :: IntValue -> IntValue Source #
E.g., ~(~1) = 1
.
doFAbs :: FloatValue -> FloatValue Source #
abs(-2.0) = 2.0
.
doSDiv :: IntValue -> IntValue -> Maybe IntValue Source #
Signed integer division. Rounds towards negativity infinity. Note: this is different from LLVM.
doSMod :: IntValue -> IntValue -> Maybe IntValue Source #
Signed integer modulus; the countepart to SDiv
.
doZExt :: IntValue -> IntType -> IntValue Source #
Zero-extend the given integer value to the size of the given type. If the type is smaller than the given value, the result is a truncation.
doSExt :: IntValue -> IntType -> IntValue Source #
Sign-extend the given integer value to the size of the given type. If the type is smaller than the given value, the result is a truncation.
doFPConv :: FloatValue -> FloatType -> FloatValue Source #
Convert the former floating-point type to the latter.
doFPToUI :: FloatValue -> IntType -> IntValue Source #
Convert a floating-point value to the nearest unsigned integer (rounding towards zero).
doFPToSI :: FloatValue -> IntType -> IntValue Source #
Convert a floating-point value to the nearest signed integer (rounding towards zero).
doUIToFP :: IntValue -> FloatType -> FloatValue Source #
Convert an unsigned integer to a floating-point value.
doSIToFP :: IntValue -> FloatType -> FloatValue Source #
Convert a signed integer to a floating-point value.
doCmpEq :: PrimValue -> PrimValue -> Bool Source #
Compare any two primtive values for exact equality.
doFCmpLt :: FloatValue -> FloatValue -> Bool Source #
Floating-point less than.
doFCmpLe :: FloatValue -> FloatValue -> Bool Source #
Floating-point less than or equal.
intToWord64 :: IntValue -> Word64 Source #
intToInt64 :: IntValue -> Int64 Source #
convOpType :: ConvOp -> (PrimType, PrimType) Source #
The input and output types of a conversion operator.
primFuns :: Map String ([PrimType], PrimType, [PrimValue] -> Maybe PrimValue) Source #
A mapping from names of primitive functions to their parameter types, their result type, and a function for evaluating them.
negativeIsh :: PrimValue -> Bool Source #
Is the given value kind of negative?
primBitSize :: PrimType -> Int Source #
The size of a value of a given primitive type in bites.
primByteSize :: Num a => PrimType -> a Source #
The size of a value of a given primitive type in eight-bit bytes.
intByteSize :: Num a => IntType -> a Source #
The size of a value of a given integer type in eight-bit bytes.
floatByteSize :: Num a => FloatType -> a Source #
The size of a value of a given floating-point type in eight-bit bytes.
commutativeBinOp :: BinOp -> Bool Source #
True if the given binary operator is commutative.
prettySigned :: Bool -> PrimType -> String Source #
True if signed. Only makes a difference for integer types.
A name tagged with some integer. Only the integer is used in
comparisons, no matter the type of vn
.
Instances
The abstract (not really) type representing names in the Futhark
compiler. String
s, being lists of characters, are very slow,
while Text
s are based on byte-arrays.
Instances
Eq Name Source # | |
Ord Name Source # | |
Show Name Source # | |
IsString Name Source # | |
Defined in Language.Futhark.Core fromString :: String -> Name # | |
Semigroup Name Source # | |
ToIdent Name Source # | |
Pretty Name Source # | |
IsName Name Source # | |
Eq (QualName Name) Source # | |
Eq (TypeArgExp Name) Source # | |
Defined in Language.Futhark.Syntax (==) :: TypeArgExp Name -> TypeArgExp Name -> Bool # (/=) :: TypeArgExp Name -> TypeArgExp Name -> Bool # | |
Eq (TypeExp Name) Source # | |
Eq (DimDecl Name) Source # | |
Ord (QualName Name) Source # | |
Defined in Language.Futhark.Syntax compare :: QualName Name -> QualName Name -> Ordering # (<) :: QualName Name -> QualName Name -> Bool # (<=) :: QualName Name -> QualName Name -> Bool # (>) :: QualName Name -> QualName Name -> Bool # (>=) :: QualName Name -> QualName Name -> Bool # |
data Commutativity Source #
Whether some operator is commutative or not. The Monoid
instance returns the least commutative of its arguments.
Instances
data Uniqueness Source #
The uniqueness attribute of a type. This essentially indicates
whether or not in-place modifications are acceptable. With respect
to ordering, Unique
is greater than Nonunique
.
Instances
defaultEntryPoint :: Name Source #
The name of the default program entry point (main).
nameToString :: Name -> String Source #
Convert a name to the corresponding list of characters.
nameFromString :: String -> Name Source #
Convert a list of characters to the corresponding name.
locStr :: SrcLoc -> String Source #
A human-readable location string, of the form
filename:lineno:columnno
. This follows the GNU coding standards
for error messages:
https://www.gnu.org/prep/standards/html_node/Errors.html
This function assumes that both start and end position is in the same file (it is not clear what the alternative would even mean).
data ErrorMsgPart a Source #
A part of an error message.
ErrorString String | A literal string. |
ErrorInt32 a | A run-time integer value. |
Instances
An error message is a list of error parts, which are concatenated to form the final message.
ErrorMsg [ErrorMsgPart a] |
Instances
Functor ErrorMsg Source # | |
Foldable ErrorMsg Source # | |
Defined in Futhark.Representation.AST.Syntax.Core fold :: Monoid m => ErrorMsg m -> m # foldMap :: Monoid m => (a -> m) -> ErrorMsg a -> m # foldr :: (a -> b -> b) -> b -> ErrorMsg a -> b # foldr' :: (a -> b -> b) -> b -> ErrorMsg a -> b # foldl :: (b -> a -> b) -> b -> ErrorMsg a -> b # foldl' :: (b -> a -> b) -> b -> ErrorMsg a -> b # foldr1 :: (a -> a -> a) -> ErrorMsg a -> a # foldl1 :: (a -> a -> a) -> ErrorMsg a -> a # elem :: Eq a => a -> ErrorMsg a -> Bool # maximum :: Ord a => ErrorMsg a -> a # minimum :: Ord a => ErrorMsg a -> a # | |
Traversable ErrorMsg Source # | |
Defined in Futhark.Representation.AST.Syntax.Core | |
Eq a => Eq (ErrorMsg a) Source # | |
Ord a => Ord (ErrorMsg a) Source # | |
Defined in Futhark.Representation.AST.Syntax.Core | |
Show a => Show (ErrorMsg a) Source # | |
IsString (ErrorMsg a) Source # | |
Defined in Futhark.Representation.AST.Syntax.Core fromString :: String -> ErrorMsg a # | |
Pretty a => Pretty (ErrorMsg a) 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.
A primitive expression parametrised over the representation of
free variables. Note that the Functor
, Traversable
, and Num
instances perform automatic (but simple) constant folding.
LeafExp v PrimType | |
ValueExp PrimValue | |
BinOpExp BinOp (PrimExp v) (PrimExp v) | |
CmpOpExp CmpOp (PrimExp v) (PrimExp v) | |
UnOpExp UnOp (PrimExp v) | |
ConvOpExp ConvOp (PrimExp v) | |
FunExp String [PrimExp v] PrimType |
Instances
constFoldPrimExp :: PrimExp v -> PrimExp v Source #
Perform quick and dirty constant folding on the top level of a PrimExp. This is necessary because we want to consider e.g. equality modulo constant folding.
(.<.) :: PrimExp v -> PrimExp v -> PrimExp v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.<=.) :: PrimExp v -> PrimExp v -> PrimExp v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.==.) :: PrimExp v -> PrimExp v -> PrimExp v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.>.) :: PrimExp v -> PrimExp v -> PrimExp v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.>=.) :: PrimExp v -> PrimExp v -> PrimExp v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
primExpType :: PrimExp v -> PrimType Source #
A wrapper around Exp
that maintains a unit as a phantom
type.
Instances
Eq (Count u) Source # | |
Num (Count u) Source # | |
Show (Count u) Source # | |
Pretty (Count u) Source # | |
IntegralExp (Count u) Source # | |
Defined in Futhark.CodeGen.ImpCode quot :: Count u -> Count u -> Count u Source # rem :: Count u -> Count u -> Count u Source # div :: Count u -> Count u -> Count u Source # mod :: Count u -> Count u -> Count u Source # sgn :: Count u -> Maybe Int Source # fromInt8 :: Int8 -> Count u Source # fromInt16 :: Int16 -> Count u Source # | |
FreeIn (Count u) Source # | |
data Volatility Source #
The volatility of a memory access.
Instances
Eq Volatility Source # | |
Defined in Futhark.CodeGen.ImpCode (==) :: Volatility -> Volatility -> Bool # (/=) :: Volatility -> Volatility -> Bool # | |
Ord Volatility Source # | |
Defined in Futhark.CodeGen.ImpCode compare :: Volatility -> Volatility -> Ordering # (<) :: Volatility -> Volatility -> Bool # (<=) :: Volatility -> Volatility -> Bool # (>) :: Volatility -> Volatility -> Bool # (>=) :: Volatility -> Volatility -> Bool # max :: Volatility -> Volatility -> Volatility # min :: Volatility -> Volatility -> Volatility # | |
Show Volatility Source # | |
Defined in Futhark.CodeGen.ImpCode showsPrec :: Int -> Volatility -> ShowS # show :: Volatility -> String # showList :: [Volatility] -> ShowS # |
pattern Comment :: String -> Code a -> Code a Source #
Has the same semantics as the contained code, but the comment should show up in generated code for ease of inspection.
pattern Free :: VName -> Space -> Code a Source #
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.
pattern Allocate :: VName -> Count Bytes -> Space -> Code a Source #
Memory space must match the corresponding
DeclareMem
.
pattern Copy :: VName -> Count Bytes -> Space -> VName -> Count Bytes -> Space -> Count Bytes -> Code a Source #
Destination, offset in destination, destination space, source, offset in source, offset space, number of bytes.
pattern DeclareArray :: VName -> Space -> PrimType -> ArrayContents -> Code a Source #
Create an array containing the given values. The lifetime of the array will be the entire application. This is mostly used for constant arrays, but also for some bookkeeping data, like the synchronisation counts used to implement reduction.
pattern DebugPrint :: String -> PrimType -> Exp -> Code a Source #
Print the given value (of the given type) to the screen, somehow annotated with the given string as a description. This has no semantic meaning, but is used entirely for debugging. Code generators are free to ignore this statement.
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.
ArrayValues [PrimValue] | Precisely these values. |
ArrayZeros Int | This many zeroes. |
Instances
Show ArrayContents Source # | |
Defined in Futhark.CodeGen.ImpCode showsPrec :: Int -> ArrayContents -> ShowS # show :: ArrayContents -> String # showList :: [ArrayContents] -> ShowS # | |
Pretty ArrayContents Source # | |
Defined in Futhark.CodeGen.ImpCode ppr :: ArrayContents -> Doc # pprPrec :: Int -> ArrayContents -> Doc # pprList :: [ArrayContents] -> Doc # |
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 used if the function is an entry point.
Instances
Functor FunctionT Source # | |
Foldable FunctionT Source # | |
Defined in Futhark.CodeGen.ImpCode fold :: Monoid m => FunctionT m -> m # foldMap :: Monoid m => (a -> m) -> FunctionT a -> m # foldr :: (a -> b -> b) -> b -> FunctionT a -> b # foldr' :: (a -> b -> b) -> b -> FunctionT a -> b # foldl :: (b -> a -> b) -> b -> FunctionT a -> b # foldl' :: (b -> a -> b) -> b -> FunctionT a -> b # foldr1 :: (a -> a -> a) -> FunctionT a -> a # foldl1 :: (a -> a -> a) -> FunctionT a -> a # toList :: FunctionT a -> [a] # length :: FunctionT a -> Int # elem :: Eq a => a -> FunctionT a -> Bool # maximum :: Ord a => FunctionT a -> a # minimum :: Ord a => FunctionT a -> a # | |
Traversable FunctionT Source # | |
Defined in Futhark.CodeGen.ImpCode | |
Show a => Show (FunctionT a) Source # | |
Pretty op => Pretty (FunctionT op) 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.
OpaqueValue String [ValueDesc] | The string is a human-readable description with no other semantics. |
TransparentValue ValueDesc |
Instances
Show ExternalValue Source # | |
Defined in Futhark.CodeGen.ImpCode showsPrec :: Int -> ExternalValue -> ShowS # show :: ExternalValue -> String # showList :: [ExternalValue] -> ShowS # | |
Pretty ExternalValue Source # | |
Defined in Futhark.CodeGen.ImpCode ppr :: ExternalValue -> Doc # pprPrec :: Int -> ExternalValue -> Doc # pprList :: [ExternalValue] -> Doc # |
A description of an externally meaningful value.
ArrayValue VName MemSize Space PrimType Signedness [DimSize] | An array with memory block, memory block size, memory space, element type, signedness of element type (if applicable), and shape. |
ScalarValue PrimType Signedness VName | A scalar value with signedness if applicable. |
data Signedness Source #
Instances
Eq Signedness Source # | |
Defined in Futhark.CodeGen.ImpCode (==) :: Signedness -> Signedness -> Bool # (/=) :: Signedness -> Signedness -> Bool # | |
Show Signedness Source # | |
Defined in Futhark.CodeGen.ImpCode showsPrec :: Int -> Signedness -> ShowS # show :: Signedness -> String # showList :: [Signedness] -> ShowS # |
A collection of imperative functions.
Instances
Functor Functions Source # | |
Foldable Functions Source # | |
Defined in Futhark.CodeGen.ImpCode fold :: Monoid m => Functions m -> m # foldMap :: Monoid m => (a -> m) -> Functions a -> m # foldr :: (a -> b -> b) -> b -> Functions a -> b # foldr' :: (a -> b -> b) -> b -> Functions a -> b # foldl :: (b -> a -> b) -> b -> Functions a -> b # foldl' :: (b -> a -> b) -> b -> Functions a -> b # foldr1 :: (a -> a -> a) -> Functions a -> a # foldl1 :: (a -> a -> a) -> Functions a -> a # toList :: Functions a -> [a] # length :: Functions a -> Int # elem :: Eq a => a -> Functions a -> Bool # maximum :: Ord a => Functions a -> a # minimum :: Ord a => Functions a -> a # | |
Traversable Functions Source # | |
Defined in Futhark.CodeGen.ImpCode | |
Semigroup (Functions a) Source # | |
Monoid (Functions a) Source # | |
Pretty op => Pretty (Functions op) Source # | |