02f2376Scale examples to 1-4 s of GPU work so tic/toc comparisons are meaningfulJeremy Magland 1% Tiled f32 matrix multiply (the GPU has no f64): 30 products of
2% 2048 x 2048, about half a teraflop of work.
e01ddf1MATLAB-syntax scripts on WebGPU: fused kernels, tic/toc timing, CPU comparisonJeremy Magland 3% For an apples-to-apples MATLAB run, also try single precision there:
4% A = rand(n, n, 'single'); B = rand(n, n, 'single');
02f2376Scale examples to 1-4 s of GPU work so tic/toc comparisons are meaningfulJeremy Magland 5n = 2048;
6reps = 30;
e01ddf1MATLAB-syntax scripts on WebGPU: fused kernels, tic/toc timing, CPU comparisonJeremy Magland 7A = rand(n, n);
8B = rand(n, n);
9C = A * B; % warm-up
10tic;
02f2376Scale examples to 1-4 s of GPU work so tic/toc comparisons are meaningfulJeremy Magland 11for k = 1:reps
e01ddf1MATLAB-syntax scripts on WebGPU: fused kernels, tic/toc timing, CPU comparisonJeremy Magland 12 C = A * B;
13end
14t = toc;
02f2376Scale examples to 1-4 s of GPU work so tic/toc comparisons are meaningfulJeremy Magland 15fprintf('%.1f GFLOP/s over %d multiplies of %dx%d\n', 2*n^3*reps/1e9/t, reps, n, n);
e01ddf1MATLAB-syntax scripts on WebGPU: fused kernels, tic/toc timing, CPU comparisonJeremy Magland 16fprintf('checksum %.2f\n', sum(C(:))/n^2);