Sarek_execute.Index_sliceHost evaluation of a kernel's store indices for one launch (specs/epilogue-fusion.md).
stores answers "which elements of array a does this launch write, and how often", by running, for every thread of the launch, only the integer computations that the stores to a depend on: the index expressions, the conditions and loop bounds around the stores, and, transitively, the variables those read. These may use thread and work-group indices, launch dimensions, int32 scalar parameters and int32 constants. Anything else (an element read, a float, a match, an int64) makes the evaluation fail, which callers must treat as "unknown": never as "no store".
The slice. A variable is relevant when a store index, a condition or loop bound enclosing a store or a return, or an assignment to a relevant variable reads it (fixpoint). Statements that neither contain a store to a, a return, nor assign a relevant variable are skipped: they cannot change which stores execute. A return stops the thread, so the conditions around it are relevant too.
Values follow int32 two's-complement arithmetic, as the device does. Division or remainder by zero fails the evaluation.
module Ids : sig ... endval expr_vars : Ids.t -> Sarek_ir_types.expr -> Ids.tval has_target : is_target:(string -> bool) -> Sarek_ir_types.stmt -> boolval assigned : Ids.t -> Sarek_ir_types.stmt -> Ids.tval matters :
is_target:(string -> bool) ->
Ids.t ->
Sarek_ir_types.stmt ->
boolval grow : is_target:(string -> bool) -> Ids.t -> Sarek_ir_types.stmt -> Ids.tval relevant : is_target:(string -> bool) -> Sarek_ir_types.stmt -> Ids.ttype state = {slots : int32 array;mutable tx : int;mutable ty : int;mutable tz : int;mutable bx : int;mutable by : int;mutable bz : int;dims : int array;block x y z, grid x y z
*)mutable stop : bool;the thread executed return
mutable steps : int;loop iterations and threads so far, this run
*)budget : int;bound on steps
}val position : string -> state -> int32val binop :
Sarek_ir_types.binop ->
(state -> int32) ->
(state -> int32) ->
state ->
int32val cexpr : cenv -> Sarek_ir_types.expr -> state -> int32type cstmt = state -> unitval tick : state -> unitval cstmt :
is_target:(string -> bool) ->
record:(int32 -> unit) ->
cenv ->
Ids.t ->
Sarek_ir_types.stmt ->
cstmtval run :
?bind:(Sarek_ir_types.var * int32) list ->
?budget:int ->
is_target:(string -> bool) ->
record:(int32 -> unit) ->
scalars:(string * int32) list ->
dims:dims ->
Sarek_ir_types.stmt ->
string listRun body for every thread of a launch of dims. is_target selects the arrays whose stores are recorded; record receives each stored index (and, for stores in a thread, in program order). scalars gives the int32 scalar parameters by name; bind pre-binds variables (var, value) before each thread. Returns the scalar parameters the evaluation read. Raises Unknown when a relevant computation is not an integer function of the launch, or when more than budget threads plus loop iterations (default max_steps) would run.