/ concept-collection / math-webgpu-sandbox
Sign in
concept-collection / math-webgpu-sandbox
math-webgpu-sandbox / examples / matmul.m
14 lines · 406 BBlameHistoryRaw
1% Tiled f32 matrix multiply (the GPU has no f64).
2% For an apples-to-apples MATLAB run, also try single precision there:
3% A = rand(n, n, 'single'); B = rand(n, n, 'single');
4n = 1024;
5A = rand(n, n);
6B = rand(n, n);
7C = A * B; % warm-up
8tic;
9for k = 1:20
10 C = A * B;
11end
12t = toc;
13fprintf('%.1f GFLOP/s over 20 multiplies of %dx%d\n', 2*n^3*20/1e9/t, n, n);
14fprintf('checksum %.2f\n', sum(C(:))/n^2);
moveopenescclose