Sarek_matrix_mappingWhich outputs a recognised GEMM nest writes (specs/matrix-pattern-rewrite.md, "Preconditions").
A rewritten kernel has its own launch geometry, so it must write exactly the outputs the original launch writes: no more (it would overwrite memory the original leaves alone), no fewer. analyse recognises how the row, column and batch indices derive from the launch, and the guards that bound them; region turns that into numbers for one launch.
type index_kind = | Axis of axisglobal_idx_a, or thread_idx_a + block_dim_a * block_idx_a
| Loop of {var : Sarek_ir_types.var;lo : Sarek_ir_types.expr;hi : Sarek_ir_types.expr;}an enclosing for
| Quotient of {linear : string;divisor : Sarek_ir_types.expr;}t / d, t the named linear thread id
| Remainder of {linear : string;divisor : Sarek_ir_types.expr;}t mod d
Upper u: index < u. Lower l: index >= l.
type mapping = {m : index_kind;n : index_kind;batch : index_kind option;bounds : (role * bound) list;}The outputs of one launch: rows 0, me), columns [0, ne), batches [0, ze); when [d > 0] (a quotient/remainder mapping) also [row * d + column < t].
val axis_char : axis -> charval analyse :
Sarek_ir_types.kernel ->
Sarek_matrix_pattern.gemm ->
(mapping, string) Stdlib.resultError reason when the indices or the guards are outside what the rewrite can bound.
val region :
mapping ->
Sarek_ir_eval_int.launch ->
(region, string) Stdlib.resultError reason when a bound cannot be evaluated, a guard excludes the origin, or the launch writes nothing.