math-webgpu-sandbox

MATLAB-syntax scripts compiled to fused WebGPU compute kernels — time them with tic/toc, then paste the same script into MATLAB and compare. source

script.m — valid MATLAB
output

          

        

The GPU computes in f32 (WebGPU has no f64) while MATLAB defaults to double — timings compare fairly, values agree to single precision. For the closest MATLAB comparison use single arrays. rand here is a deterministic counter-based generator: statistics match MATLAB's, individual draws do not. Supported: elementwise math (fused per source line, including comparisons and logicals), A*B, transpose, sum/mean/prod/max/min/norm/dot, A(:)/reshape (free), for loops (replayed, not unrolled), tic/toc/disp/fprintf. Not (yet) supported: indexing/slicing beyond (:), if/while, complex numbers, user functions.