MCPcopy Index your code
hub / github.com/LegNeato/rust-gpu-chimera

github.com/LegNeato/rust-gpu-chimera @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
96 symbols 181 edges 11 files 16 documented · 17%
What it actually does AI analysis from the code graph — generated when you open this
loading…
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

Extension points exported contracts — how you extend this code

SortRunner (Interface)
Common trait for all sorting backends [4 implementers]
src/lib.rs
SortableKey (Interface)
Trait for types that can be sorted using bitonic sort [3 implementers]
shared/src/lib.rs

Core symbols most depended-on inside this repo

sort
called by 25
src/lib.rs
print_test_header
called by 9
src/main.rs
run_test_on_backend
called by 9
src/main.rs
as_u32
called by 9
shared/src/lib.rs
run_sort_test
called by 4
src/main.rs
bitonic_sort_step
called by 3
kernel/src/lib.rs
as_usize
called by 2
shared/src/lib.rs
build_spirv_kernel
called by 1
build.rs

Shape

Method 42
Function 37
Class 12
Enum 3
Interface 2

Languages

Rust100%

Modules by API surface

shared/src/lib.rs21 symbols
src/runners/ash.rs14 symbols
src/runners/wgpu.rs12 symbols
kernel/src/lib.rs12 symbols
src/runners/cuda.rs10 symbols
src/runners/cpu.rs9 symbols
src/lib.rs7 symbols
src/main.rs6 symbols
build.rs3 symbols
src/error.rs2 symbols

For agents

$ claude mcp add rust-gpu-chimera \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page