Module Cuda_api.Kernel

type t = {
  1. module_ : Cuda_types.cu_module Ctypes.structure Ctypes.ptr;
  2. function_ : Cuda_types.cu_function Ctypes.structure Ctypes.ptr;
  3. name : string;
}
type arg =
  1. | ArgBuffer : _ Memory.buffer -> arg
  2. | ArgInt32 : int32 -> arg
  3. | ArgInt64 : int64 -> arg
  4. | ArgFloat32 : float -> arg
  5. | ArgFloat64 : float -> arg
  6. | ArgPtr : nativeint -> arg
val cache : (string, t) Spoc_framework.Guarded_cache.t
val with_sm_target : major:int -> minor:int -> string -> string
val load_module_from_ptx : name:string -> string -> t
val compile : Device.t -> name:string -> source:string -> t
val load_from_ptx : Device.t -> name:string -> ptx:string -> t

Load a pre-assembled PTX string directly, bypassing NVRTC. The .target directive in the PTX is automatically rewritten to match the device's actual SM, so a PTX built for sm_86 loads cleanly on sm_61 as long as it uses no sm_86-specific instructions.

val load_from_ptx_current : name:string -> ptx:string -> t

Load a pre-assembled PTX string using the already-current CUDA context. The caller must have already set the device context via Device.set_current.

val with_cache : Device.t -> name:string -> source:string -> (unit -> t) -> t
val load_from_ptx_cached : Device.t -> name:string -> ptx:string -> t

Cached variant of load_from_ptx — same cache as compile_cached. Without it, every launch reloads (and re-JITs) the PTX module, which dominates kernel time on drivers that compile at module-load (NVIDIA JIT, ZLUDA).

val compile_cached : Device.t -> name:string -> source:string -> t
val clear_cache : unit -> unit
type ctype_ref =
  1. | CTypeRef : 'a Ctypes.typ * 'a Ctypes.ptr -> ctype_ref

Existential wrapper for keeping Ctypes-allocated values alive during FFI calls

val launch : t -> args:arg list -> grid:(int * int * int) -> block:(int * int * int) -> shared_mem:int -> stream:Stream.t option -> unit