Blog / Engineering

One kernel, every GPU Pick targets in the build

Ben KoskaSep 23, 20261 min read

The same kernel compiles to every backend. Switch targets in your build, not in your code.

Write the kernel once

A kernel is an ordinary Emma function marked with the kernel keyword.

vectorAdd.emma
1
2
3
kernel func vectorAdd(a: Float[], b: Float[], c: Float[]) {
    c[id.x] = a[id.x] + b[id.x]
}

Targets CUDA, ROCm, Vulkan

Pick targets in the build

The targets live in your build file. Adding one does not touch the kernel.

build.toml
1
2
[build]
targets = ["cuda", "rocm", "vulkan"]