Sarek_metal.Sarek_ir_metalval current_device : Spoc_core.Device.t option Stdlib.refCurrent device for SNative code generation (set during generate_for_device)
val current_variants :
(string * (string * Sarek_ir_types.elttype list) list) list Stdlib.refCurrent kernel's variant definitions (set during generate)
Mangle OCaml type name to valid C identifier (e.g., "Module.point" -> "Module_point")
val metal_type_of_elttype : Sarek_ir_types.elttype -> stringMap Sarek IR element type to Metal C type string
val metal_memspace : Sarek_ir_types.memspace -> stringMap memory space to Metal qualifier
val metal_param_type : Sarek_ir_types.elttype -> stringMap Sarek IR element type to Metal C type for kernel parameters
val metal_helper_param_type : Sarek_ir_types.elttype -> stringMap Sarek IR element type to Metal C type for helper function parameters
val metal_atomic_type_of_elttype : Sarek_ir_types.elttype -> stringConvert type to atomic type for Metal
val gen_expr : Stdlib.Buffer.t -> Sarek_ir_types.expr -> unitval gen_binop : Sarek_ir_types.binop -> stringval gen_unop : Sarek_ir_types.unop -> stringval gen_intrinsic :
Stdlib.Buffer.t ->
string list ->
string ->
Sarek_ir_types.expr list ->
unitval gen_lvalue : Stdlib.Buffer.t -> Sarek_ir_types.lvalue -> unitval gen_match_pattern :
Stdlib.Buffer.t ->
string ->
string ->
string ->
string list ->
(string -> Sarek_ir_types.elttype list option) ->
unitGenerate match case pattern with variable bindings
val gen_var_decl :
Stdlib.Buffer.t ->
string ->
string ->
Sarek_ir_types.elttype ->
Sarek_ir_types.expr ->
unitGenerate variable declaration with initialization
val gen_array_decl :
Stdlib.Buffer.t ->
string ->
string ->
Sarek_ir_types.elttype ->
Sarek_ir_types.expr ->
string ->
unitGenerate array declaration
val gen_stmt : Stdlib.Buffer.t -> string -> Sarek_ir_types.stmt -> unitval is_vec_type : Sarek_ir_types.elttype -> boolCheck if a type is a vector (requires length parameter)
val gen_param_metal :
Stdlib.Buffer.t ->
string list ->
int ->
Sarek_ir_types.decl ->
intGenerate parameter with Metal buffer attributes, returns next buffer index
val gen_param : Stdlib.Buffer.t -> Sarek_ir_types.decl -> unitval collect_atomic_vars_expr : Sarek_ir_types.expr -> string listCollect variable names used in atomic operations
val collect_atomic_vars_lvalue : Sarek_ir_types.lvalue -> string listval collect_atomic_vars_stmt : Sarek_ir_types.stmt -> string listval gen_local :
Stdlib.Buffer.t ->
string ->
string list ->
Sarek_ir_types.decl ->
unitval gen_helper_func : Stdlib.Buffer.t -> Sarek_ir_types.helper_func -> unitGenerate a helper function (Metal device function)
val generate : Sarek_ir_types.kernel -> stringGenerate complete Metal source for a kernel
val generate_for_device :
device:Spoc_core.Device.t ->
Sarek_ir_types.kernel ->
stringGenerate complete Metal source with device context for SNative
val gen_variant_def :
Stdlib.Buffer.t ->
(string * (string * Sarek_ir_types.elttype list) list) ->
unitGenerate variant type definition for Metal
val generate_with_types :
types:(string * (string * Sarek_ir_types.elttype) list) list ->
Sarek_ir_types.kernel ->
stringGenerate Metal source with custom type definitions
val generate_with_fp64 : Sarek_ir_types.kernel -> stringGenerate Metal source with double precision (Metal supports FP64 natively)