Supported Backends

Sarek is designed to be backend-agnostic. You write your kernel once in OCaml, and Sarek compiles it to the appropriate shading language (CUDA C, OpenCL C, GLSL, MSL) or executes it natively on the CPU.

Backend Target Status Requirements
CUDA NVIDIA GPUs Stable NVIDIA Driver + CUDA Toolkit
OpenCL Multi-vendor (AMD, Intel, NVIDIA) Stable OpenCL Runtime / ICD
Vulkan Cross-platform (Linux, Windows, Android) Stable Vulkan SDK + glslangValidator
Metal Apple Silicon & Intel Macs Stable macOS 10.13+
Native CPU (Multicore) Stable OCaml 5.4.0+
Interpreter CPU (Debug) Stable None

CUDA Backend (sarek-cuda)

Targets NVIDIA GPUs using the CUDA Driver API and NVRTC (Runtime Compilation).

Build it from the repository (dune build sarek-cuda), list sarek-cuda.plugin in your libraries, and call Sarek_cuda.Cuda_plugin.init () (CUDA/PTX, the default path) and, if you want the NVRTC path, Sarek_cuda.Cuda_c_plugin.init () (CUDA/C) before Device.init (see Getting Started).

OpenCL Backend (sarek-opencl)

Targets a wide range of devices including AMD GPUs, Intel integrated graphics, and FPGAs.

Build it from the repository (dune build sarek-opencl), list sarek-opencl.plugin in your libraries, and call Sarek_opencl.Opencl_plugin.init () before Device.init (see Getting Started).

Vulkan Backend (sarek-vulkan)

Uses GLSL compute shaders and SPIR-V for modern cross-platform GPU support.

Build it from the repository (dune build sarek-vulkan), list sarek-vulkan.plugin in your libraries, and call Sarek_vulkan.Vulkan_plugin.init () before Device.init (see Getting Started).

Metal Backend (sarek-metal)

Native support for Apple hardware (M1/M2/M3 chips) using Metal Shading Language (MSL).

Build it from the repository (dune build sarek-metal), list sarek-metal.plugin in your libraries, and call Sarek_metal.Metal_plugin.init () before Device.init (see Getting Started).

Native CPU Backend (sarek.native)

Executes kernels directly on the host CPU without GPU compilation.

Interpreter Backend (sarek.interpreter)

Walks through the Sarek IR (Intermediate Representation) step-by-step.

WebGPU / WGSL Codegen Target

Sarek includes a WGSL (WebGPU Shading Language) code-generation backend that emits compute shaders for browser-side execution via the WebGPU API.