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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.CodeGen.ImpCode.Multicore

Description

Multicore imperative code.

Synopsis

- type Program = Functions Multicore
- data Multicore
  - = SegOp String [Param] ParallelTask (Maybe ParallelTask) [Param] SchedulerInfo
  - | ParLoop String MCCode [Param]
  - | ISPCKernel MCCode [Param]
  - | ForEach VName Exp Exp MCCode
  - | ForEachActive VName MCCode
  - | ExtractLane VName Exp Exp
  - | GetLoopBounds VName VName
  - | GetTaskId VName
  - | GetNumTasks VName
  - | Atomic AtomicOp
- type MCCode = Code Multicore
- data Scheduling
  - = Dynamic
  - | Static
- data SchedulerInfo = SchedulerInfo {
  - iterations :: Exp
  - scheduling :: Scheduling
  }
- data AtomicOp
  - = AtomicAdd IntType VName VName (Count Elements (TExp Int32)) Exp
  - | AtomicSub IntType VName VName (Count Elements (TExp Int32)) Exp
  - | AtomicAnd IntType VName VName (Count Elements (TExp Int32)) Exp
  - | AtomicOr IntType VName VName (Count Elements (TExp Int32)) Exp
  - | AtomicXor IntType VName VName (Count Elements (TExp Int32)) Exp
  - | AtomicXchg PrimType VName VName (Count Elements (TExp Int32)) Exp
  - | AtomicCmpXchg PrimType VName VName (Count Elements (TExp Int32)) VName Exp
- newtype ParallelTask = ParallelTask MCCode
- data KernelHandling
  - = TraverseKernels
  - | OpaqueKernels
- lexicalMemoryUsageMC :: KernelHandling -> Function Multicore -> Map VName Space
- module Futhark.CodeGen.ImpCode

# Documentation

type Program = Functions Multicore Source #

An imperative multicore program.

data Multicore Source #

A multicore operation.

Constructors

SegOp String [Param] ParallelTask (Maybe ParallelTask) [Param] SchedulerInfo |
ParLoop String MCCode [Param] |
ISPCKernel MCCode [Param] | A kernel of ISPC code, or a scoped block in regular C.
ForEach VName Exp Exp MCCode | A foreach loop in ISPC, or a regular for loop in C.
ForEachActive VName MCCode | A foreach_active loop in ISPC, or a single execution in C.
ExtractLane VName Exp Exp | Extract a value from a given lane and assign it to a variable. This is just a regular assignment in C.
GetLoopBounds VName VName | Retrieve inclusive start and exclusive end indexes of the chunk we are supposed to be executing. Only valid immediately inside a `ParLoop` construct!
GetTaskId VName | Retrieve the task ID that is currently executing. Only valid immediately inside a `ParLoop` construct!
GetNumTasks VName | Retrieve the number of subtasks to execute. Only valid immediately inside a `SegOp` or `ParLoop` construct!
Atomic AtomicOp |

#### Instances

Instances details

FreeIn Multicore Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.Multicore Methods freeIn' :: Multicore -> FV Source #
Pretty Multicore Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.Multicore Methods pretty :: Multicore -> Doc ann Source # prettyList :: [Multicore] -> Doc ann Source #

type MCCode = Code Multicore Source #

Multicore code.

data Scheduling Source #

Whether the Scheduler should schedule the tasks as Dynamic or it is restainted to Static

Constructors

Dynamic |
Static |

#### Instances

Instances details

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

data SchedulerInfo Source #

Information about parallel work that is do be done. This is passed to the scheduler to help it make scheduling decisions.

Constructors

SchedulerInfo |

Fields

- iterations :: Exp

  The number of total iterations for a task.

- scheduling :: Scheduling

  The type scheduling for the task.

#### Instances

Instances details

FreeIn SchedulerInfo Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.Multicore Methods freeIn' :: SchedulerInfo -> FV Source #
Pretty SchedulerInfo Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.Multicore Methods pretty :: SchedulerInfo -> Doc ann Source # prettyList :: [SchedulerInfo] -> Doc ann Source #

data AtomicOp Source #

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

Constructors

AtomicAdd IntType VName VName (Count Elements (TExp Int32)) Exp |
AtomicSub IntType VName VName (Count Elements (TExp Int32)) Exp |
AtomicAnd IntType VName VName (Count Elements (TExp Int32)) Exp |
AtomicOr IntType VName VName (Count Elements (TExp Int32)) Exp |
AtomicXor IntType VName VName (Count Elements (TExp Int32)) Exp |
AtomicXchg PrimType VName VName (Count Elements (TExp Int32)) Exp |
AtomicCmpXchg PrimType VName VName (Count Elements (TExp Int32)) VName Exp |

#### Instances

Instances details

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

newtype ParallelTask Source #

A task for a `SegOp`.

Constructors

ParallelTask MCCode |

#### Instances

Instances details

FreeIn ParallelTask Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.Multicore Methods freeIn' :: ParallelTask -> FV Source #
Pretty ParallelTask Source # |
Instance details Defined in Futhark.CodeGen.ImpCode.Multicore Methods pretty :: ParallelTask -> Doc ann Source # prettyList :: [ParallelTask] -> Doc ann Source #

data KernelHandling Source #

Whether `lexicalMemoryUsageMC` should look inside nested kernels or not.

Constructors

TraverseKernels |
OpaqueKernels |

lexicalMemoryUsageMC :: KernelHandling -> Function Multicore -> Map VName Space Source #

Like `lexicalMemoryUsage`, but traverses some inner multicore ops.

module Futhark.CodeGen.ImpCode