Module Sarek_native_gen_kernel

Kernel Generation

Convert execution strategy to generation mode

val gen_arg_cast : ?current_module:Stdlib.String.t -> ?inline_types:Sarek_native_gen_base.StringSet.t -> ?inline_ids_var:string -> loc:Ppxlib.location -> Sarek_typed_ast.tparam -> int -> Ppxlib.expression

Generate a type cast expression for extracting a kernel argument.

For vectors: extract NA_Vec and create an accessor wrapper. For scalars: match on NA_Int32/NA_Float32/etc and extract the value.

Uses typed native_arg for type safety.

val gen_types_object : loc:Ppxlib__.Location.t -> Sarek_typed_ast.ttype_decl list -> Ppxlib.expression

Generate an object expression with accessor methods for FCM. Example for type point with fields x and y: object method get_point_x r = r.x method get_point_y r = r.y method make_point ~x ~y = record with fields x and y end

Using an object avoids needing to define a record type for the accessors.

val gen_cpu_kern_native : loc:Ppxlib__.Location.t -> Sarek_typed_ast.tkernel -> Ppxlib.expression

Generate V2 cpu_kern - uses Spoc_core.Vector.get/set instead of Spoc.Mem.

Generated signature: thread_state -> shared_mem -> args_tuple -> unit This matches the signature expected by run_parallel/run_sequential.

val gen_simple_cpu_kern_native : loc:Ppxlib__.Location.t -> exec_strategy:Sarek_convergence.exec_strategy -> Sarek_typed_ast.tkernel -> Ppxlib.expression

Generate simple kernel for optimized threadpool execution using the modern vector path (Spoc_core.Vector).

val gen_cpu_kern_native_wrapper : loc:Ppxlib__.Location.t -> Sarek_typed_ast.tkernel -> Ppxlib.expression

Generate the cpu_kern wrapper for use with native_fn_t.

Generated function type: parallel:bool -> block:int*int*int -> grid:int*int*int -> native_arg array -> unit

Uses typed native_arg accessors for type-safe vector access. Vectors are wrapped in accessor objects with get/set/length/underlying.