Single-source pure-Rust heterogeneous GPU compute platform
Rust
0
1 commits
updated Oct 2, 2026
Pure-Rust Heterogeneous GPU Compute Platform with Just-In-Time Compilation
Write standard, idiomatic Rust functions and execute them natively across CPU cores or compile them just-in-time directly onto GPU silicon.
No Nightly toolchains required. No foreign shading languages. No descriptor set juggling.
Enki unifies host and accelerator execution. The showcase below demonstrates a real-time procedural 3D raymarching with smooth lighting, ambient occlusion, and mouse-driven orbital camera controls—compiled just-in-time from a single Rust function running on a potato GPU:

Pressing SPACE dynamically switches execution between GPU silicon (Enki) and multi-threaded CPU cores (Rayon) in real time.
git clone https://github.com/enkiruntime/enki_sdf.git
cd enki_sdf
cargo run
Add Enki and glam to your project:
cargo add enki-gpu glam
Replace src/main.rs with the following:
use enki::*;
use glam::Vec2;
const COUNT: usize = 5;
// Declare the compute kernel with #[nam]
#[nam]
fn scale_vectors(_space: &Space, input: &Vec2, output: &mut Vec2, factor: f32) {
*output = *input * factor;
}
fn main() {
// Initialize the headless GPU runtime
let enki = Enki::init();
// Allocate physical data directly in GPU VRAM
let in_gpu = gpu_vec![
Vec2::new(1.0, 2.0),
Vec2::new(3.0, 4.0),
Vec2::new(5.0, 6.0),
Vec2::new(7.0, 8.0),
Vec2::new(9.0, 10.0),
];
let mut out_gpu = gpu_vec![Vec2::ZERO; COUNT];
let factor = 2.5f32;
// Record and dispatch directly to GPU silicon
enki.flow(|_| {
scale_vectors.run(
&Space::gpu_x(COUNT),
&in_gpu,
&mut out_gpu,
GpuParam::new(factor),
);
});
// Dual Execution: Run the exact same function on CPU native rust
let in_cpu = vec![
Vec2::new(1.0, 2.0),
Vec2::new(3.0, 4.0),
Vec2::new(5.0, 6.0),
Vec2::new(7.0, 8.0),
Vec2::new(9.0, 10.0),
];
let mut out_cpu = vec![Vec2::ZERO; COUNT];
for i in 0..COUNT {
scale_vectors(&Space::cpu_x(i, COUNT), &in_cpu[i], &mut out_cpu[i], factor);
}
// Verify bit-for-bit equivalence
assert_eq!(&out_cpu[..], &out_gpu.to_vec()[..]);
println!("GPU Results: {:?}", out_gpu.to_vec());
println!("Execution verified: CPU and GPU outputs match identically!");
}
Run the application:
cargo run
Note: On your first build, Enki will prompt to automatically configure --emit=llvm-bc and optimization profiles in .cargo/config.toml. Alternatively, you can run non-intrusively using the official CLI runner via cargo install cargo-enki && cargo enki run.
1.80+). No nightly compiler forks, custom toolchains, or experimental compiler plugins.rustc's compile-time borrow checker on the host with a runtime BorrowEngine that intercepts spatial slice collisions, domain bound deficits, and temporal presentation hazards.Synchronization2) automatically.#[nam] are standard Rust functions. They can be tested natively on host CPU threads using rayon and standard #[test] assertions without requiring physical GPU silicon in CI/CD pipelines.Enki is currently an alpha-stage project (v0.1). It represents an active systems research effort into unified language execution:
BorrowEngine operates as a compiler-grade pragmatic safety net at the dispatch boundary. It detects concrete spatial and temporal data race hazards before hardware queue submission. It does not claim to provide formal mathematical soundness proofs for arbitrary parallel access patterns.For in-depth architectural breakdowns, memory layout analysis, and advanced graphics pipelines, read the official documentation:
The book covers:
GpuVec, zero-cost sub-slicing (Slice), by-value uniform packing (GpuParam), and on-chip scratchpad memory (GpuTileMem).1.80 or newer.VK_KHR_buffer_device_address)VK_KHR_timeline_semaphore)VK_KHR_synchronization2)shaderInt64)Enki is structured with an open-core architecture:
enki-gpu, anu, apsu, utu, enki_macros):
Fully open-source under MIT License or Apache License 2.0.Rust
100.0%
Single-source pure-Rust heterogeneous GPU compute platform
Rust
0
1 commits
updated Oct 2, 2026
Pure-Rust Heterogeneous GPU Compute Platform with Just-In-Time Compilation
Write standard, idiomatic Rust functions and execute them natively across CPU cores or compile them just-in-time directly onto GPU silicon.
No Nightly toolchains required. No foreign shading languages. No descriptor set juggling.
Enki unifies host and accelerator execution. The showcase below demonstrates a real-time procedural 3D raymarching with smooth lighting, ambient occlusion, and mouse-driven orbital camera controls—compiled just-in-time from a single Rust function running on a potato GPU:

Pressing SPACE dynamically switches execution between GPU silicon (Enki) and multi-threaded CPU cores (Rayon) in real time.
git clone https://github.com/enkiruntime/enki_sdf.git
cd enki_sdf
cargo run
Add Enki and glam to your project:
cargo add enki-gpu glam
Replace src/main.rs with the following:
use enki::*;
use glam::Vec2;
const COUNT: usize = 5;
// Declare the compute kernel with #[nam]
#[nam]
fn scale_vectors(_space: &Space, input: &Vec2, output: &mut Vec2, factor: f32) {
*output = *input * factor;
}
fn main() {
// Initialize the headless GPU runtime
let enki = Enki::init();
// Allocate physical data directly in GPU VRAM
let in_gpu = gpu_vec![
Vec2::new(1.0, 2.0),
Vec2::new(3.0, 4.0),
Vec2::new(5.0, 6.0),
Vec2::new(7.0, 8.0),
Vec2::new(9.0, 10.0),
];
let mut out_gpu = gpu_vec![Vec2::ZERO; COUNT];
let factor = 2.5f32;
// Record and dispatch directly to GPU silicon
enki.flow(|_| {
scale_vectors.run(
&Space::gpu_x(COUNT),
&in_gpu,
&mut out_gpu,
GpuParam::new(factor),
);
});
// Dual Execution: Run the exact same function on CPU native rust
let in_cpu = vec![
Vec2::new(1.0, 2.0),
Vec2::new(3.0, 4.0),
Vec2::new(5.0, 6.0),
Vec2::new(7.0, 8.0),
Vec2::new(9.0, 10.0),
];
let mut out_cpu = vec![Vec2::ZERO; COUNT];
for i in 0..COUNT {
scale_vectors(&Space::cpu_x(i, COUNT), &in_cpu[i], &mut out_cpu[i], factor);
}
// Verify bit-for-bit equivalence
assert_eq!(&out_cpu[..], &out_gpu.to_vec()[..]);
println!("GPU Results: {:?}", out_gpu.to_vec());
println!("Execution verified: CPU and GPU outputs match identically!");
}
Run the application:
cargo run
Note: On your first build, Enki will prompt to automatically configure --emit=llvm-bc and optimization profiles in .cargo/config.toml. Alternatively, you can run non-intrusively using the official CLI runner via cargo install cargo-enki && cargo enki run.
1.80+). No nightly compiler forks, custom toolchains, or experimental compiler plugins.rustc's compile-time borrow checker on the host with a runtime BorrowEngine that intercepts spatial slice collisions, domain bound deficits, and temporal presentation hazards.Synchronization2) automatically.#[nam] are standard Rust functions. They can be tested natively on host CPU threads using rayon and standard #[test] assertions without requiring physical GPU silicon in CI/CD pipelines.Enki is currently an alpha-stage project (v0.1). It represents an active systems research effort into unified language execution:
BorrowEngine operates as a compiler-grade pragmatic safety net at the dispatch boundary. It detects concrete spatial and temporal data race hazards before hardware queue submission. It does not claim to provide formal mathematical soundness proofs for arbitrary parallel access patterns.For in-depth architectural breakdowns, memory layout analysis, and advanced graphics pipelines, read the official documentation:
The book covers:
GpuVec, zero-cost sub-slicing (Slice), by-value uniform packing (GpuParam), and on-chip scratchpad memory (GpuTileMem).1.80 or newer.VK_KHR_buffer_device_address)VK_KHR_timeline_semaphore)VK_KHR_synchronization2)shaderInt64)Enki is structured with an open-core architecture:
enki-gpu, anu, apsu, utu, enki_macros):
Fully open-source under MIT License or Apache License 2.0.Rust
100.0%