This library is in flux. APIs may change without notice. Generated from source on 6/15/2026.

Kernel

High-performance computation primitives inspired by shader languages.

kernel.kz

Koru Standard Library: Computation Kernels ============================================ High-performance computation primitives inspired by shader languages. Describe RELATIONSHIPS between data elements, not iteration patterns. The compiler decides optimal data layout and iteration strategy. USAGE: ~import std/kernel // 1. Declare the shape (structure with explicit types) ~std/kernel:shape(Body) { x: f64, y: f64, z: f64, vx: f64, vy: f64, vz: f64, mass: f64 } // 2. Initialize kernel data (creates instance of shape) // Uses Koru syntax (x: value) which transforms to Zig (.x = value) ~std/kernel:init(Body) { x: 0, y: 0, z: 0, vx: 1.0, vy: 0, vz: 0, mass: 1.0 } | kernel bodies |> ... // 3. Perform kernel operations std/kernel:pairwise { bodies.vel -= d * mag * bodies.other.mass bodies.other.vel += d * mag * bodies.mass } DESIGN: - kernel.shape is [norun] - just a declaration, sits in AST as metadata - kernel.init is [transform] - looks up shape, emits struct + instance - kernel.pairwise is [transform] - emits iteration code KERNEL OPERATIONS: - kernel.pairwise: All unique pairs (i,j where i < j) - kernel.self: Per-element operations (future) - kernel.reduce: Reduction to single value (future) - kernel.cross: Cross-product of two kernels (future) MAGIC BINDINGS: Inside kernel.pairwise: - `bodies` refers to the current element (self, bodies[i]) - `bodies.other` refers to the paired element (bodies[j])