Sarek DSL

Write high-performance GPU kernels directly in OCaml syntax using a type-safe PPX. No need to learn CUDA C or OpenCL C for your logic.

Unified Runtime

The SPOC framework manages memory transfers, device detection, and kernel execution across multiple hardware backends seamlessly.

Modern Architecture

Optimized for OCaml 5 with support for CUDA, OpenCL, Vulkan, Metal, and parallel CPU execution via Domains.


Recent Developments (2024-2026)

Sarek has been recently modernized to leverage the latest OCaml features and modern GPU APIs:

Quick Start

Sarek is not yet in the official opam repository. Install from source:

git clone https://github.com/mathiasbourgoin/Sarek.git
cd Sarek
opam install . --deps-only -y
dune build

Check out the Getting Started guide to write your first GPU kernel in minutes, or browse the Examples to see common patterns.

How it works

Sarek allows you to express parallel logic as standard OCaml functions. These are compiled to native GPU code at runtime.

(* A simple vector addition kernel *)
let%kernel vector_add (a : float32 vector) (b : float32 vector) (c : float32 vector) =
  let idx = get_global_id 0 in
  c.(idx) <- a.(idx) + b.(idx)

Project Info

Sarek is the result of over a decade of academic research into high-level parallel programming abstractions. It is currently maintained by Mathias Bourgoin.