This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.

Kernel

~import std/kernel

Koru Standard Library: Computation Kernels

kernel.kz · 6 tors

Koru Standard Library: Computation Kernels · 38 more lines
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])

init

comptimetransformclaims_descendants koru_std/kernel.kz:108

pairwise

comptimetransform koru_std/kernel.kz:2084

self

comptimetransform koru_std/kernel.kz:2409

step

comptimetransform koru_std/kernel.kz:2652