02f2376Scale examples to 1-4 s of GPU work so tic/toc comparisons are meaningfulJeremy Magland 1% Reductions with fused loaders, 300 times over 10 million elements:
2% dot, norm and max each read their operands exactly once per pass --
3% sum(a.*b) is one sweep of memory, not two.
e01ddf1MATLAB-syntax scripts on WebGPU: fused kernels, tic/toc timing, CPU comparisonJeremy Magland 4n = 10000000;
02f2376Scale examples to 1-4 s of GPU work so tic/toc comparisons are meaningfulJeremy Magland 5reps = 300;
e01ddf1MATLAB-syntax scripts on WebGPU: fused kernels, tic/toc timing, CPU comparisonJeremy Magland 6a = rand(n, 1);
7b = rand(n, 1);
8tic;
02f2376Scale examples to 1-4 s of GPU work so tic/toc comparisons are meaningfulJeremy Magland 9for k = 1:reps
10 d = dot(a, b);
11 nrm = norm(a - b);
12 mx = max(abs(a - b));
13end
14t = toc;
e01ddf1MATLAB-syntax scripts on WebGPU: fused kernels, tic/toc timing, CPU comparisonJeremy Magland 15fprintf('dot %.0f norm %.2f max %.6f\n', d, nrm, mx);
02f2376Scale examples to 1-4 s of GPU work so tic/toc comparisons are meaningfulJeremy Magland 16fprintf('%.1f GB/s effective\n', reps*6*n*4/1e9/t);