e01ddf1MATLAB-syntax scripts on WebGPU: fused kernels, tic/toc timing, CPU comparisonJeremy Magland 1% Monte Carlo estimate of pi: comparisons and logicals fuse too, so the
2% mask never touches memory -- one fused pass plus the reduction.
3n = 10000000;
4tic;
5x = 2*rand(n, 1) - 1;
6y = 2*rand(n, 1) - 1;
7pi_est = 4*mean((x.^2 + y.^2) <= 1);
8toc
9fprintf('pi ~ %.6f (n = %d)\n', pi_est, n);