Sarek_registryInformation about a primitive/intrinsic type (float32, int64, etc.)
Information about a record field
Information about a record type (user-defined via @@sarek.type)
Information about a variant constructor
Information about a variant type
type fun_info = {fi_name : string;fi_arity : int;fi_device : string -> string;fi_arg_types : string list;fi_ret_type : string;}Information about an intrinsic function
val type_registry : (string, type_info) Stdlib.Hashtbl.tType registry - maps type names to their info (primitives)
val record_registry : (string, record_info) Stdlib.Hashtbl.tRecord registry - maps type names to their info (user-defined records)
val variant_registry : (string, variant_info) Stdlib.Hashtbl.tVariant registry - maps type names to their info (user-defined variants)
val fun_registry : (string list * string, fun_info) Stdlib.Hashtbl.tFunction registry - maps (module_path, name) to their info
Register a primitive type
val register_record : string -> fields:field_info list -> size:int -> unitRegister a record type (called by PPX-generated code for @@sarek.type)
val register_variant : string -> constructors:constructor_info list -> unitRegister a variant type (called by PPX-generated code for @@sarek.type)
val register_fun :
?module_path:string list ->
string ->
arity:int ->
device:(string -> string) ->
arg_types:string list ->
ret_type:string ->
unitRegister an intrinsic function
A scalar crossing between an evaluator and an intrinsic's host (OCaml) implementation. One constructor per scalar type an intrinsic signature can name: int32, int64, float32 (an OCaml float holding a binary32 value), float/float64, bool and unit.
val host_registry :
(string list * string, host_value list -> host_value) Stdlib.Hashtbl.tHost implementations of intrinsic functions, keyed like fun_registry. let%sarek_intrinsic registers one for every function whose signature is all scalars; it is what lets an evaluator that has no built-in table entry for an intrinsic (the interpreter, for an intrinsic declared outside sarek's stdlib) run it. The implementation receives its arguments in the declared order, each with the constructor of its declared type, and raises Invalid_argument on any other shape.
val register_host_impl :
?module_path:string list ->
string ->
(host_value list -> host_value) ->
unitval find_host_impl :
?module_path:string list ->
string ->
(host_value list -> host_value) optionval find_type : string -> type_info optionFind a primitive type by name
val find_record : string -> record_info optionFind a record type by name
val find_variant : string -> variant_info optionFind a variant type by name
val find_fun : ?module_path:string list -> string -> fun_info optionFind a function by name, optionally in a module
Get device code for a function
Get the device-code template for a function on a given backend. This is for V2 IR codegens that don't have SPOC device objects.
framework is the caller's backend tag ("CUDA", "OpenCL", "Metal", …). It used to be hardcoded to "generic", which cuda_or_opencl resolves to the CUDA branch — so every backend reaching this fallback got the CUDA spelling, and an OpenCL or Metal kernel calling e.g. Float32.abs_float was emitted as fabsf(...). Neither OpenCL C nor MSL declares fabsf; both spell it fabs. The stdlib already declares both spellings (dev "fabsf" "fabs"); only this lookup was discarding the caller's framework.
?framework defaults to "generic" so existing non-backend callers keep the previous behaviour.
val find_record_by_short_name : string -> record_info optionFind a record by short name (last component after '.'). This handles cases where the registry uses qualified names like "Module.typename" but the custom_type uses just "typename".
val record_fields : string -> field_info listGet record field info - tries exact match first, then short name
val variant_constructors : string -> constructor_info listGet variant constructors
Raised when a shading-language framework asks this two-way dispatch for a spelling it cannot supply. See cuda_or_opencl.