Module Opencl_api.Program

type t = {
  1. mutable handle : Opencl_types.cl_program;
  2. context : Context.t;
  3. source : string;
  4. mutable _pinned : (char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t;
}
val pin : string -> (char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t
val create_from_source : Context.t -> string -> t
val create_from_binary : Context.t -> string -> t option

A program holding binary, or None if the driver refuses it (CL_INVALID_BINARY, a binary built for another device or driver). Not yet built: build_status does that.

val binary : t -> string option

The binary the driver produced for the (single) device of the program's context, or None if the driver returns none (size 0). Only meaningful after a successful build.

val effective_options : t -> caller:string -> string

The complete option string clBuildProgram receives for caller. caller is what the CALLER wants; it is not what the driver gets. Opencl_fp.build_options screens it - raising Opencl_fp.Fp_conformance_violation on anything that would relax float semantics below docs/fp-contraction-policy.md §1 - and appends the options this backend requires on its own behalf, gated on the device's CL_DEVICE_SINGLE_FP_CONFIG.

build_status is the ONLY place an option string reaches clBuildProgram, and every caller reaches it through this function: the guard sits here rather than at the caller on purpose, so it screens flags a FUTURE maintainer of this module adds itself, not merely a caller's. Same placement argument as Cuda_nvrtc.compile_with_string_opts (docs/fp-contraction-policy.md §5).

Until backlog #136 the options passed straight through, and every caller in the tree passed nothing - so the effective option string was empty and Sarek silently accepted each vendor's default, including a sqrt of up to 3 ulp.

val build_status : t -> options:string -> Opencl_types.cl_int

clBuildProgram with the already-screened options; the raw status.

val build_log : t -> string
val release : t -> unit
val cache_target : t -> options:string -> Opencl_disk_cache.target

The identity of what program is built for, as the disk cache keys it.

val adopt_cached_binary : t -> key:string -> options:string -> bool

Replace program's handle by a built-from-binary one if key names a usable cached binary. false leaves program untouched: a corrupt entry, a binary the driver refuses, or one that fails to build all mean "compile from source", never an error.

val build_from_source : t -> options:string -> unit
val build : t -> ?options:string -> unit -> unit

Build a program, through the persistent disk cache when the driver gives programs a binary. A hit skips the compiler; a miss (or an unusable entry) compiles source and (over)writes the entry.