Summary
Add WGPU backend alongside cudarc to enable GPU-accelerated compression on all platforms.
Current State
trueno-zram GPU support:
├── cudarc (CUDA) → NVIDIA Linux only
└── No Mac, AMD, Intel, or browser support
Proposed State
trueno-zram GPU backends:
├── cudarc (CUDA) → NVIDIA Linux/Windows (existing)
├── wgpu (Metal) → macOS (Apple Silicon + Intel)
├── wgpu (Vulkan) → Linux AMD/Intel, Android
├── wgpu (DX12) → Windows AMD/Intel
└── wgpu (WebGPU) → Browsers (WASM)
Target Platforms
| Platform |
GPU API |
Status |
| Linux + NVIDIA |
CUDA |
✅ Implemented |
| Linux + AMD/Intel |
Vulkan via WGPU |
🔲 Planned |
| macOS Intel |
Metal via WGPU |
🔲 Planned |
| macOS Apple Silicon |
Metal via WGPU |
🔲 Planned |
| Windows |
DX12/Vulkan via WGPU |
🔲 Planned |
| Browser/WASM |
WebGPU via WGPU |
🔲 Planned |
Implementation
Dependencies
[dependencies]
wgpu = "23"
Backend Selection
pub enum GpuBackend {
Cuda(CudaContext), // Existing
Wgpu(wgpu::Device), // New
}
impl GpuBackend {
pub fn auto_detect() -> Option<Self> {
// 1. Try CUDA first (fastest on NVIDIA)
if let Some(cuda) = CudaContext::new().ok() {
return Some(GpuBackend::Cuda(cuda));
}
// 2. Fall back to WGPU (Metal, Vulkan, DX12)
if let Some(wgpu) = WgpuContext::new().ok() {
return Some(GpuBackend::Wgpu(wgpu));
}
None
}
}
Compute Shader (WGSL)
@group(0) @binding(0) var<storage, read> input_pages: array<u32>;
@group(0) @binding(1) var<storage, read_write> output: array<u32>;
@compute @workgroup_size(256)
fn lz4_compress(@builtin(global_invocation_id) id: vec3<u32>) {
let page_idx = id.x;
// LZ4 compression kernel
}
Use Cases
- Intel Mac via SSH - Metal GPU for coverage builds
- Apple Silicon Macs - Native Metal acceleration
- AMD GPU workstations - Vulkan backend
- Browser-based tools - WebGPU for web IDEs
- Edge devices - Portable WASM deployment
Acceptance Criteria
Performance Targets
| Platform |
Target Throughput |
| CUDA (RTX 4090) |
60 GB/s |
| Metal (M1 Max) |
30 GB/s |
| Vulkan (RX 7900) |
40 GB/s |
| WebGPU (browser) |
10 GB/s |
Related
Labels
enhancement, gpu, cross-platform, wgpu
Summary
Add WGPU backend alongside cudarc to enable GPU-accelerated compression on all platforms.
Current State
Proposed State
Target Platforms
Implementation
Dependencies
Backend Selection
Compute Shader (WGSL)
Use Cases
Acceptance Criteria
wgpufeature flagWgpuContextwith device auto-detectionssh mac)Performance Targets
Related
Labels
enhancement, gpu, cross-platform, wgpu