1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! 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
//!
//! ```rust,no_run
//! 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
//!
//! ```text
//! ┌──────────────────────────────────────────┐
//! │ 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.
// WASM target support — compiled on wasm32 or when the `wasm` feature is
// enabled (so that native tests can exercise the module).
pub use WebGpuBackend;
pub use ;
pub use ;
pub use ;
pub use ScanKind;