Sarek_quoteHelper to create an identifier expression
Quote an int as OCaml expression
Quote an int32 as OCaml expression
Quote a float as OCaml expression
Quote a string as OCaml expression
Quote a bool as OCaml expression
val quote_list :
loc:Ppxlib.location ->
(loc:Ppxlib.location -> 'a -> Ppxlib_ast.Ast.expression) ->
'a list ->
Ppxlib_ast.Ast.expressionQuote a list
val quote_option :
loc:Ppxlib.location ->
(loc:Ppxlib.location -> 'a -> Ppxlib_ast.Ast.expression) ->
'a option ->
Ppxlib_ast.Ast.expressionQuote an option
val core_type_of_typ :
loc:Ppxlib.location ->
Sarek_types.typ ->
Ppxlib.core_type optionOptional OCaml type constraint for a kernel parameter.
NOT ON THE LIVE PATH. The parameter constraints the PPX actually emits come from Sarek_native_intrinsics.core_type_of_typ, which Sarek_native_gen.ml:305 uses and which returns [%type: _] for EVERY TVec; this option-returning variant is referenced only by sarek/tests/unit/test_quote.ml. It is kept (and kept correct) because it encodes the intended mapping, but changing it changes no generated code.
In particular: an OCaml constraint cannot police vector element types at all on the real launch path, because Execute.vector_arg's Vec constructor is existential and erases them. That check lives at Execute.check_launch_args.
val kernel_ctor_name : Sarek_types.typ -> stringval build_kernel_args :
loc:Ppxlib__.Location.t ->
Sarek_typed_ast.tparam list ->
Ppxlib_ast.Ast.pattern
* Ppxlib__.Import.expression
* Ppxlib__.Import.pattern
* Ppxlib_ast.Ast.expressionmodule IntrinsicRefSet : sig ... endval expr_of_intrinsic_ref_opt :
loc:Ppxlib__.Location.t ->
Sarek_env.intrinsic_ref ->
Ppxlib.expression optionGenerate an OCaml expression for an intrinsic reference.
Intrinsics are now defined in stdlib modules (Float32, Float64, Int32, etc.) via %sarek_intrinsic. We reference the function to ensure it exists at compile time. The module path enables extensibility: user libraries can define their own intrinsics and the PPX will reference them correctly.
Examples:
"Sarek_stdlib"; "Float32", "sin") -> Sarek_stdlib.Float32.sin"Sarek_stdlib"; "Gpu", "block_barrier") -> Sarek_stdlib.Gpu.block_barrierCORE primitives get NO witness (None). They are not stdlib symbols: they live in Sarek_core_primitives.all, a table compiled into the PPX itself, so their existence is already established before any OCaml code is emitted — there is nothing for a witness to check. The previous behaviour emitted an UNQUALIFIED Gpu.<name>, naming a module that is not in scope at a user's expansion site, and that broke the f16 feature's documented usage: the mandated shape
let x = float32_of_float16 a.(tid) in ...failed with Unbound module "Gpu" (#57 slice 1 review, MF4c). It only appeared to work when the conversion sat directly inside a vector store, because collect_intrinsic_refs did not descend into TEVecSet's value — the accident that hid this.
BLAST RADIUS of returning None for every CorePrimitiveRef, not just the f16 pair: none, because no such witness could ever resolve. When a name is registered BOTH as a core primitive and as a %sarek_intrinsic the stdlib registration wins and the ref is an IntrinsicRef with a fully-qualified path — verified on the emitted AST, where global_thread_id (present in both Sarek_core_primitives.all and Gpu.ml) comes out as Sarek_stdlib.Gpu.global_thread_id. A CorePrimitiveRef therefore only ever names a primitive with NO stdlib counterpart, for which the emitted Gpu.<name> was unresolvable in every context. Their existence is checked by the typer against Sarek_core_primitives.all regardless. float16_of_float32 / float32_of_float16 have no Gpu counterpart at all and could never have resolved: they are deliberately core primitives rather than %sarek_intrinsics because a stdlib type registration needs a ctype and Ctypes has no half type.
val collect_intrinsic_refs : Sarek_typed_ast.texpr -> IntrinsicRefSet.tCollect all intrinsic function refs from a typed expression
val collect_from_module_items :
Sarek_typed_ast.tmodule_item list ->
IntrinsicRefSet.tCollect intrinsic refs from module items
val generate_intrinsic_check :
loc:Ppxlib__.Location.t ->
Sarek_typed_ast.tkernel ->
Ppxlib.expressionGenerate a dummy expression that references all intrinsic functions. This ensures compile-time checking that all intrinsics exist in their stdlib modules.
val quote_kernel :
loc:Ppxlib__.Location.t ->
?native_kernel:Sarek_typed_ast.tkernel ->
ir_opt:Sarek_ir_ppx.kernel ->
Sarek_typed_ast.tkernel ->
Ppxlib.expressionQuote a kernel to create a sarek_kernel expression
val quote_sarek_loc : loc:Ppxlib.location -> Sarek_ast.loc -> Ppxlib.expressionQuote a Sarek_ast.loc
val quote_sarek_memspace :
loc:Ppxlib.location ->
Sarek_ast.memspace ->
Ppxlib.expressionQuote a Sarek_ast.memspace
val quote_sarek_type_expr :
loc:Ppxlib.location ->
Sarek_ast.type_expr ->
Ppxlib_ast.Ast.expressionQuote a Sarek_ast.type_expr
val quote_sarek_binop :
loc:Ppxlib.location ->
Sarek_ast.binop ->
Ppxlib.expressionQuote a Sarek_ast.binop
val quote_sarek_unop :
loc:Ppxlib.location ->
Sarek_ast.unop ->
Ppxlib.expressionQuote a Sarek_ast.unop
val quote_sarek_for_dir :
loc:Ppxlib.location ->
Sarek_ast.for_dir ->
Ppxlib.expressionQuote a Sarek_ast.for_dir
val quote_sarek_pattern :
loc:Ppxlib.location ->
Sarek_ast.pattern ->
Ppxlib_ast.Ast.expressionQuote a Sarek_ast.pattern
val quote_sarek_param :
loc:Ppxlib.location ->
Sarek_ast.param ->
Ppxlib.expressionQuote a Sarek_ast.param
val quote_sarek_expr :
loc:Ppxlib.location ->
Sarek_ast.expr ->
Ppxlib_ast.Ast.expressionQuote a Sarek_ast.expr - main recursive function
val quote_sarek_module_item :
loc:Ppxlib.location ->
Sarek_ast.module_item ->
Ppxlib.expressionQuote a Sarek_ast.module_item
val quote_sarek_type_decl :
loc:Ppxlib.location ->
Sarek_ast.type_decl ->
Ppxlib.expressionQuote a Sarek_ast.type_decl