Module Vulkan_plugin.Backend

Vulkan Backend - implements BACKEND

val name : string
val version : int * int * int
val is_available : unit -> bool
module Device : sig ... end

Device management

module Stream : sig ... end

Async execution streams / command queues

module Memory : sig ... end

GPU memory allocation and transfer

module Event : sig ... end

Timing events

module Kernel : sig ... end

Kernel compilation and execution

val enable_profiling : unit -> unit
val disable_profiling : unit -> unit

The execution model this backend uses

val generate_source : ?block:Spoc_framework.Framework_sig.dims -> Sarek_ir_types.kernel -> string option

Generate source code from Sarek IR (for JIT backends). Returns None for Direct/Custom backends.

  • parameter block

    Optional block dimensions (required for Vulkan/GLSL which embeds workgroup size in shader)

Execute a kernel directly (for Direct/Custom backends). JIT backends should raise an error if this is called. The backend chooses which component to use:

  • Direct backends (Native): use native_fn
  • Custom backends (Interpreter): use ir
  • parameter native_fn

    Pre-compiled OCaml function (from PPX)

  • parameter ir

    Sarek IR kernel (for interpretation)

  • parameter block

    Block dimensions

  • parameter grid

    Grid dimensions

  • parameter args

    Kernel arguments - fully typed, no Obj.t

Backend-specific intrinsic registry

External Kernel Execution

val supported_source_langs : Spoc_framework.Framework_sig.source_lang list

List of source languages this backend supports

val run_source : source:string -> lang:Spoc_framework.Framework_sig.source_lang -> kernel_name:string -> block:Spoc_framework.Framework_sig.dims -> grid:Spoc_framework.Framework_sig.dims -> shared_mem:int -> Spoc_framework.Framework_sig.run_source_arg list -> unit

Execute an external kernel from source code.

  • parameter source

    The kernel source code (CUDA/OpenCL/PTX string)

  • parameter lang

    The source language

  • parameter kernel_name

    The name of the kernel function to execute

  • parameter block

    Block dimensions

  • parameter grid

    Grid dimensions

  • parameter shared_mem

    Shared memory size in bytes

  • parameter args

    Kernel arguments as run_source_arg list

  • raises Failure

    if source language is not supported

Kernel Args Wrapping

Type-safe wrapping/unwrapping of backend-specific kernel args into the extensible kargs type. Each backend extends kargs with its own variant.

Wrap this backend's kernel args into a kargs variant

val unwrap_kargs : Spoc_framework.Framework_sig.kargs -> Kernel.args option

Unwrap kargs to this backend's kernel args. Returns None if wrong backend.