Module Sarek_opencl.Opencl_disk_cache

type target = {
  1. platform_name : string;
  2. platform_version : string;
  3. device_name : string;
  4. device_version : string;
  5. driver_version : string;
  6. build_options : string;
}

Everything that changes the binary a driver produces from a source.

A driver update changes driver_version (and usually device_version); a different compiler front end changes platform_*; the screened and capability-gated option string is build_options. Any difference must miss, so each is a key component.

val key : target -> source:string -> string

The cache key of source built for target.

The program binary holds every kernel of the source, so the key is per source, not per kernel name: keying by name would store one identical binary per kernel of a multi-kernel source. The fixed name below only fills the shared key shape.

val seal : string -> string

An entry is the binary prefixed by its own MD5, so a truncated or bit-rotted file is rejected here instead of being handed to the driver. A driver is free to accept garbage; MD5 is for corruption, not for an adversary.

val digest_length : int
val unseal : string -> string option
val load : key:string -> string option

The stored binary for key, or None on a miss, a disabled cache, an unusable cache directory, or a corrupt entry. Never raises: the cache is an optimisation.

val store : key:string -> string -> unit

Store binary under key. A driver that returned no binary is skipped. Never raises.