Sarek_metal.Sarek_ir_metalRe-export the Metal code generator from the pure sarek_codegen library. Consumers of Sarek_metal.Sarek_ir_metal and in-package Sarek_ir_metal are unchanged.
include module type of struct include Sarek_codegen.Sarek_ir_metal endmodule Codegen_error = Sarek_codegen.Sarek_ir_metal.Codegen_errorLocal error module — same raised exception as the package-level Metal_error.
Current framework string for SNative code generation. Always None in normal use; SNative branches check this ref and error if None.
val current_variants :
(string * (string * Sarek_ir_types.elttype list) list) list Stdlib.refCurrent kernel's variant definitions (set during generate)
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 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)