Kernelin / Live demo

⚡ Kotlin on your GPU, live

This fractal is computed on your GPU by a shader that the Kernelin compiler plugin generated from a plain Kotlin function. No hand-written GPU code.

loading...
Click to zoom in · Shift-click or right-click to zoom out
GPU (compute + copy back)
–
–
CPU (Kotlin → Wasm, 1 core)
–
press "Race"
GPU is faster by
–
same frame, same Kotlin kernel
Pixels
–
zoom 1×

The code behind it

You write the Kotlin. At build time, Kernelin translates it into the WGSL (switch tabs to compare), which this page runs with WebGPU. The same Kotlin function also runs on the JVM in unit tests.

loading...

How it runs

The whole page logic that matters is Kotlin compiled to WebAssembly (100 KB):

JavaScript only handles the buttons and paints the pixels. GPU timings include copying the result back from the GPU, but not drawing it. Source: Demo.kt.