LegNeato
rust-gpu-chimera
Rust

Demo project showing a single Rust codebase running on CPU and directly on GPUs

Last updated Jul 7, 2026
488
Stars
14
Forks
4
Issues
+1
Stars/day
Attention Score
59
Language breakdown
Rust 82.6%
Shell 17.4%
โ–ธ Files click to expand
README

Rust GPU Chimera Demo

A cross-platform demo of a single Rust codebase running on both the CPU and GPU via CUDA, Vulkan, Metal, and DirectX. There are no shader or kernel languages used, only Rust.

Supported Configurations

| Platform | Rust Features | Host | Backend | Driver | How it Works | Status | | ------------ | ------------- | ------ | ------- | ------------- | -------------------- | ------------------ | | Linux | - | CPU | - | - | Rust โ†’ Native | โœ… Working | | Linux | wgpu | [wgpu] | Vulkan | Native | Rust โ†’ SPIR-V | โœ… Working | | Linux | ash | [ash] | Vulkan | Native | Rust โ†’ SPIR-V | โœ… Working | | Linux | cuda | [cust] | CUDA | Native | Rust โ†’ NVVM โ†’ PTX | โœ… Working | | macOS | - | CPU | - | - | Rust โ†’ Native | โœ… Working | | macOS | wgpu | [wgpu] | Metal | Metal | Rust โ†’ SPIR-V โ†’ MSL | โœ… Working | | macOS | wgpu,vulkan | [wgpu] | Vulkan | [MoltenVK] | Rust โ†’ SPIR-V | โœ… Working | | macOS | wgpu,vulkan | [wgpu] | Vulkan | [SwiftShader] | Rust โ†’ SPIR-V | โœ… Working | | macOS | ash | [ash] | Vulkan | [MoltenVK] | Rust โ†’ SPIR-V | โœ… Working | | macOS | ash | [ash] | Vulkan | [SwiftShader] | Rust โ†’ SPIR-V | โœ… Working | | macOS | cuda | [cust] | CUDA | - | - | โŒ Unavailable[^1] | | Windows | - | CPU | - | - | Rust โ†’ Native | โœ… Working | | Windows | wgpu | [wgpu] | DX12 | Native | Rust โ†’ SPIR-V โ†’ HLSL | โœ… Working | | Windows | wgpu,vulkan | [wgpu] | Vulkan | Native | Rust โ†’ SPIR-V | โœ… Working | | Windows | wgpu,vulkan | [wgpu] | Vulkan | [SwiftShader] | Rust โ†’ SPIR-V | โœ… Working | | Windows | ash | [ash] | Vulkan | Native | Rust โ†’ SPIR-V | โœ… Working | | Windows | ash | [ash] | Vulkan | [SwiftShader] | Rust โ†’ SPIR-V | โœ… Working | | Windows | cuda | [cust] | CUDA | Native | Rust โ†’ NVVM โ†’ PTX | โœ… Working | | Android | - | CPU | - | - | Rust โ†’ Native | โœ… Working | | Android | wgpu | [wgpu] | Vulkan | Native | Rust โ†’ SPIR-V | โœ… Working | | Android | ash | [ash] | Vulkan | Native | Rust โ†’ SPIR-V | โœ… Working | | Android | cuda | [cust] | CUDA | - | - | โŒ Unavailable[^2] | | iOS | - | CPU | - | - | Rust โ†’ Native | โœ… Working | | iOS | wgpu | [wgpu] | Metal | Metal | Rust โ†’ SPIR-V โ†’ MSL | ๐Ÿ”ท Should work | | iOS | wgpu,vulkan | [wgpu] | Vulkan | [MoltenVK] | Rust โ†’ SPIR-V | ๐Ÿ”ท Should work | | iOS | ash | [ash] | Vulkan | [MoltenVK] | Rust โ†’ SPIR-V | ๐Ÿ”ท Should work | | iOS | cuda | [cust] | CUDA | - | - | โŒ Unavailable[^1] | | tvOS | - | CPU | - | - | Rust โ†’ Native | โœ… Working | | tvOS | wgpu | [wgpu] | Metal | Metal | Rust โ†’ SPIR-V โ†’ MSL | ๐Ÿ”ท Should work | | tvOS | wgpu,vulkan | [wgpu] | Vulkan | [MoltenVK] | Rust โ†’ SPIR-V | ๐Ÿ”ท Should work | | tvOS | ash | [ash] | Vulkan | [MoltenVK] | Rust โ†’ SPIR-V | ๐Ÿ”ท Should work | | tvOS | cuda | [cust] | CUDA | - | - | โŒ Unavailable[^1] | | visionOS | - | CPU | - | - | Rust โ†’ Native | โœ… Working | | visionOS | wgpu | [wgpu] | Metal | Metal | Rust โ†’ SPIR-V โ†’ MSL | ๐Ÿ”ท Should work | | visionOS | wgpu,vulkan | [wgpu] | Vulkan | [MoltenVK] | Rust โ†’ SPIR-V | ๐Ÿ”ท Should work | | visionOS | ash | [ash] | Vulkan | [MoltenVK] | Rust โ†’ SPIR-V | ๐Ÿ”ท Should work | | visionOS | cuda | [cust] | CUDA | - | - | โŒ Unavailable[^1] |

[^1]: CUDA is not supported on macOS/iOS/tvOS/visionOS. ZLUDA could potentially enable CUDA on these platforms in the future.

[^2]: CUDA is not supported on Android. ZLUDA could potentially enable CUDA on Android in the future.

Running the Demo

The demo runs a bitonic sort on various data types (u32, i32, f32) with different sizes and configurations.

Linux

# CPU execution
cargo run --release

Vulkan via wgpu

cargo run --release --features wgpu

Vulkan via ash

cargo run --release --features ash

CUDA (NVIDIA GPU required)

cargo run --release --features cuda

macOS

# CPU execution
cargo run --release

Metal via wgpu (SPIR-V โ†’ MSL translation)

cargo run --release --features wgpu

Vulkan via wgpu (requires MoltenVK)

cargo run --release --features wgpu,vulkan

Vulkan via ash (requires MoltenVK)

cargo run --release --features ash

Windows

# CPU execution
cargo run --release

DirectX 12 via wgpu (SPIR-V โ†’ HLSL translation)

cargo run --release --features wgpu

Vulkan via wgpu

cargo run --release --features wgpu,vulkan

Vulkan via ash

cargo run --release --features ash

CUDA (NVIDIA GPU required)

cargo run --release --features cuda

Instead of cargo run you can replace it with cargo test to run unit tests for the same configuration.

Project Structure

rust-gpu-chimera-demo/
โ”œโ”€โ”€ kernel/           # Compute kernel logic and entrypoints
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ””โ”€โ”€ lib.rs
โ”œโ”€โ”€ shared/           # Code that runs on both the CPU and GPU
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ””โ”€โ”€ lib.rs
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ runners/      # Code that runs on the CPU/host and interfaces with the GPU
โ”‚   โ”‚   โ”œโ”€โ”€ cpu.rs
โ”‚   โ”‚   โ”œโ”€โ”€ cuda.rs
โ”‚   โ”‚   โ”œโ”€โ”€ wgpu.rs
โ”‚   โ”‚   โ””โ”€โ”€ ash.rs
โ”‚   โ”œโ”€โ”€ lib.rs
โ”‚   โ””โ”€โ”€ main.rs       # Demo application binary
โ””โ”€โ”€ build.rs          # Kernel compilation orchestration

[wgpu]: https://github.com/gfx-rs/wgpu [ash]: https://github.com/ash-rs/ash [cust]: https://github.com/Rust-GPU/Rust-CUDA/tree/main/crates/cust [MoltenVK]: https://github.com/KhronosGroup/MoltenVK [SwiftShader]: https://github.com/google/swiftshader

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท LegNeato/rust-gpu-chimera ยท Updated daily from GitHub