Sarek_ppx_lib.Sarek_convergenceAnalysis context
val init_ctx : ctxInitial context - start converged
val diverge : 'a -> ctxEnter diverged mode
val is_thread_varying_intrinsic : Sarek_env.intrinsic_ref -> boolCheck if an intrinsic ref is thread-varying using core primitives
val is_barrier_ref : Sarek_env.intrinsic_ref -> boolCheck if an intrinsic ref is a barrier/convergence point
val is_thread_varying : Sarek_typed_ast.texpr -> boolCheck if an expression's value varies per-thread.
Thread-varying (different per thread):
Uniform (same for all threads in workgroup):
val is_barrier_intrinsic : Sarek_env.intrinsic_ref -> boolCheck if an intrinsic reference is a barrier
val is_warp_convergence_ref : Sarek_env.intrinsic_ref -> boolCheck if an intrinsic ref requires warp convergence
val check_expr : ctx -> Sarek_typed_ast.texpr -> Sarek_error.error listCollect errors from convergence analysis
val contains_diverging_control_flow : Sarek_typed_ast.texpr -> boolCheck if an expression contains any control flow with thread-varying conditions. This is used for superstep analysis - the implicit barrier at the end of a superstep requires that no divergence occurs within the body.
val check_module_item :
ctx ->
Sarek_typed_ast.tmodule_item ->
Sarek_error.error listCheck a module item
val check_kernel :
Sarek_typed_ast.tkernel ->
(unit, Sarek_error.error list) Stdlib.resultCheck a kernel for convergence safety
val expr_uses_barriers : Sarek_typed_ast.texpr -> boolCheck if a kernel uses any barriers (explicit or implicit). Used for compile-time optimization of native kernel execution.
val kernel_uses_barriers : Sarek_typed_ast.tkernel -> boolCheck if a kernel uses barriers
Detect which thread/block dimensions a kernel uses to enable optimized native CPU execution. Simple kernels that only use global_idx_x can be run with a simple parallel for loop without the thread_state overhead.
type dim_usage = {uses_x : bool;uses_y : bool;uses_z : bool;uses_block_dim : bool;Uses block_dim_x/y/z
*)uses_grid_dim : bool;Uses grid_dim_x/y/z
*)uses_thread_idx : bool;Uses thread_idx_x/y/z directly
*)uses_block_idx : bool;Uses block_idx_x/y/z directly
*)}Dimension usage record
val empty_dim_usage : dim_usageval dim_usage_of_name : string -> dim_usageCheck if an intrinsic name affects dimension usage
val dim_usage_of_intrinsic_ref : Sarek_env.intrinsic_ref -> dim_usageGet dimension usage from an intrinsic reference
val expr_dim_usage : Sarek_typed_ast.texpr -> dim_usageAnalyze expression for dimension usage
val kernel_exec_strategy : Sarek_typed_ast.tkernel -> exec_strategyDetermine the optimal execution strategy for a kernel