GPU compiler infrastructure.
Shokado does for GPU languages what LLVM does for CPU ones: an IR, a verifier, a linker, an optimizer, code generators, and a VM. It's one C library without dependencies, small enough to vendor, and safe to run on untrusted input.
Why Shokado and Bento
The GPU language
Bento
Bento is the GPU language built on Shokado. Barriers, subgroups, uniformity, and uber shaders are concepts it understands rather than thinly typed intrinsics and macros bolted onto C.
Meet Bento Language tour Getting started
import std;
struct Pixel {
[[location(0)]] uv: f32x2,
}
struct Color {
[[color(0)]] rgba: f32x4,
}
[[stage(.Fragment)]]
fn main(px: Pixel) -> Color {
let corner = px.uv.x * px.uv.y;
let glow = std::smoothstep(0.0, 1.0, corner);
return { f32x4 { px.uv, glow, 1.0 } };
}
Write once, run anywhere
Shokado generates code for SPIR-V, DXIL, AIR, and GLSL with no other compiler in between. Targets
Infrastructure
An IR, a verifier, a linker, an optimizer, and code generators, all language agnostic. Bento is a small client on top of all that, much like clang is the C and C++ frontend for LLVM. Tools, IR and bytecode, Library
Structured SSA
Blocks belong to if and loop instructions rather than to a control flow graph. IR can be built, edited, printed, and verified from other programs.
Bytecode
Modules can be linked at build time or at run time, left incomplete, and mixed with IR from any source.
Tools
Linker, optimizer, code generator, disassembler, validator, and stripper, for modules from any frontend.
Optimizer
Inlining, mem2reg, scalar replacement of aggregates, CSE, and rule-driven algebraic simplification. Competitive with spirv-opt and with the highest optimization level of DXC.
Library
One C header. Memory, files, and diagnostics are provided by the host through callbacks.
Untrusted input
No source or bytecode can crash the library, hang it, or run it out of memory. An input that proves otherwise is worth up to $500 USD under the bug bounty.
Rationale
“The shader situation in Vulkan and Direct3D 12 is somewhat dire and this is an attempt at trying to address it.”
The rationale is about the lessons from past mistakes, why Shokado is not a transpiler, and why the library comes first. Status is on the roadmap.