Sarek_execute.Coopmat_variantLaunch-time variant of a cooperative-matrix kernel on the CUDA backends.
wmma needs a 32-byte aligned address and a stride that is a multiple of 16 bytes, which the IR does not promise. The generators emit the bare instruction for an access they can prove aligned, and for every other access a run-time test with a staging path through a per-warp shared buffer (Sarek_ir_coopmat_align). A kernel whose accesses depend on scalar arguments (a GEMM's k and n) would pay that buffer on every launch, so the host decides instead: Sarek_ir_coopmat_align.derive reduces "every access is aligned" to a predicate on the kernel's int32 parameters, and at launch the actual arguments either satisfy it (the kernel marked with Sarek_ir_coopmat_align.mark_aligned: bare wmma, no check, no buffer) or not (the kernel as given: the staged variant). The marked kernel is a distinct IR value, built once per kernel, so Execute's source memo, which keys on the IR's physical identity, holds one source per variant (and per block) and each is compiled once.
Only the CUDA frameworks are concerned; every other backend, and a kernel with no cooperative-matrix statement, gets the kernel it was given. The base pointers are assumed 32-byte aligned (device allocations).
module A = Sarek_ir_coopmat_aligntype outcome = | Alignedthe marked variant: no check, no staging buffer
*)| Stagedthe kernel as given: static proofs where they hold, run-time check and staging for the rest
*)| Checkedevery access tested at run time: a launch argument's base pointer is not 32-byte aligned, which the static proofs assume
*)| Not_applicablenot a CUDA framework, or no cooperative matrix
*)What a launch runs.
val outcome_name : outcome -> stringtype entry = {applicable : bool;predicate : A.predicate option;aligned : Sarek_ir_types.kernel option;None: the kernel itself
checked : Sarek_ir_types.kernel option;arrays : string list;the array parameters its accesses touch
*)}val entry_key : entry Ir_memo.keyval entry_of : Sarek_ir_types.kernel -> entryThe largest power of two (at most 4096) dividing a device pointer; 0 is taken as maximally aligned.
val is_param : Sarek_ir_types.kernel -> Stdlib.String.t -> boolval bases_aligned :
Sarek_ir_types.kernel ->
(Stdlib.String.t * int) list option ->
Stdlib.String.t list ->
boolval relevant : framework:string -> Sarek_ir_types.kernel -> boolWhether choose has anything to decide for k on framework: a CUDA framework and a kernel with cooperative-matrix statements. The launch path asks this first: for every other launch it is a string comparison against two names (a kernel on a CUDA framework: one physical comparison with the last kernel seen), and nothing is allocated.
val choose_lazy :
?count:bool ->
framework:string ->
Sarek_ir_types.kernel ->
scalars:(unit -> (string * int) list) ->
bases:(unit -> (string * int) list option) ->
Sarek_ir_types.kernel * outcomechoose ~framework k scalars is the kernel to generate and run for the scalar int32 arguments scalars (parameter name, value); ~count:false leaves the launch counters alone (introspection).
val choose :
?count:bool ->
?bases:(string * int) list ->
framework:string ->
Sarek_ir_types.kernel ->
(string * int) list ->
Sarek_ir_types.kernel * outcomechoose_lazy with the arguments in hand.