Crate cubecl_opt

Crate cubecl_opt 

Source
Expand description

§CubeCL Optimizer

A library that parses CubeCL IR into a control flow graph, transforms it to static single-assignment form and runs various optimizations on it. The order of operations is as follows:

  1. Parse root scope recursively into a control flow graph
  2. Run optimizations that must be done before SSA transformation
  3. Analyze variable liveness
  4. Transform the graph to pruned SSA form
  5. Run post-SSA optimizations and analyses in a loop until no more improvements are found
  6. Speed

The output is represented as a petgraph graph of BasicBlocks terminated by ControlFlow. This can then be compiled into actual executable code by walking the graph and generating all phi nodes, instructions and branches.

§Representing PhiInstruction in non-SSA languages

Phi instructions can be simulated by generating a mutable variable for each phi, then assigning value to it in each relevant block.

Structs§

AtomicCounter
An atomic counter with a simplified interface.
BasicBlock
A basic block of instructions interrupted by control flow. Phi nodes are assumed to come before any instructions. See https://en.wikipedia.org/wiki/Basic_block
ConstArray
EdgeIndex
Edge identifier.
NodeIndex
Node identifier.
Optimizer
An optimizer that applies various analyses and optimization passes to the IR.
OptimizerBuilder
Build an optimizer with IR transformers
PhiInstruction
A phi node that picks its value based on the BasicBlock that came immediately before. For more information, see https://en.wikipedia.org/wiki/Static_single-assignment_form
Program
SharedLiveness
Shared liveness works the other way around from normal liveness, since shared memory lives forever by default. So any use (read or write) inserts it as live, while only free changes the state to dead.
Uniformity

Enums§

BlockUse
ControlFlow
Control flow that terminates a block
TransformAction
The action that should be performed on an instruction, returned by IrTransformer::maybe_transform

Traits§

IrTransformer
A transformer that can modify instructions before they get added to the control flow graph.

Functions§

visit_noop
A visitor that does nothing.