Expand description
OxiCUDA WebGPU backend — cross-platform GPU compute via wgpu and WGSL.
Provides a WebGpuBackend that implements the oxicuda_backend::ComputeBackend trait
from oxicuda-backend, using wgpu to target Vulkan, Metal, Direct3D 12,
and the browser WebGPU API from a single Rust crate.
§Quick Start
use oxicuda_webgpu::WebGpuBackend;
use oxicuda_backend::ComputeBackend;
let mut backend = WebGpuBackend::new();
backend.init().expect("WebGPU init failed");
// Allocate 1 KiB on the GPU.
let ptr = backend.alloc(1024).expect("alloc failed");
backend.free(ptr).expect("free failed");§Architecture
┌──────────────────────────────────────────┐
│ WebGpuBackend │
│ (implements ComputeBackend) │
└──────────────┬───────────────────────────┘
│
┌────────▼────────┐
│ WebGpuDevice │ ← wgpu Instance + Adapter + Device + Queue
└────────┬────────┘
│
┌───────────▼────────────┐
│ WebGpuMemoryManager │ ← buffer pool (u64 handle → wgpu::Buffer)
└────────────────────────┘§WGSL Shader Generation
The shader module provides helpers that produce WGSL source strings for
common kernels (GEMM, element-wise ops, reductions). The shader_ext
module adds transpose, row-wise softmax, Blelloch prefix scan, layer
normalisation, warp-style subgroup reductions, and emulated-f64 arithmetic,
while the fft module provides a radix-2 Cooley-Tukey FFT plan
(WgslFftPlan) plus its butterfly shaders.
§Dispatch Planning
The planner module resolves workgroup sizes and dispatch grids from
adapter Limits (auto-tuning, 2-D dispatch folding, 256-byte texture row
alignment) — pure host-side arithmetic requiring no GPU.
Re-exports§
pub use backend::WebGpuBackend;pub use error::WebGpuError;pub use error::WebGpuResult;pub use fft::FftDirection;pub use fft::WgslFftPlan;pub use planner::DispatchGrid;pub use planner::Limits;pub use planner::Workgroup1D;pub use planner::Workgroup2D;pub use shader_ext::ScanKind;
Modules§
- backend
WebGpuBackend— the main entry point for the oxicuda-webgpu crate.- device
- WebGPU device wrapper — owns the wgpu instance, adapter, device, and queue.
- error
- Error types for the oxicuda-webgpu backend.
- fft
- WGSL radix-2 Cooley-Tukey FFT (Cooley & Tukey 1965) — host plan + shader.
- memory
- WebGPU buffer manager — allocates, copies, and frees
wgpu::Bufferobjects through an opaqueu64handle interface that mirrors the CUDA device-pointer model used by the rest of OxiCUDA. - planner
- Host-side dispatch and workgroup planning for WebGPU compute.
- shader
- WGSL shader source generation for common compute kernels.
- shader_
ext - Additional WGSL shader-source generators that extend
crate::shader. - wasm
- WASM target support for browser-based GPU compute via WebGPU.