1% A long chain of elementwise math on 8 million elements, fused into ONE
2% GPU kernel per source line and replayed 600 times (about 5 billion updates).
3% Paste this whole script into MATLAB to compare (lower niter if slow).
4n = 8000000;
5niter = 600;
6x = rand(n, 1);
7y = zeros(n, 1);
8tic;
9for k = 1:niter
10 y = y + 0.1*sin(x + k) .* exp(-x) + x.^2;
11end
12t = toc;
13fprintf('%.0f million element-updates/sec\n', niter*n/1e6/t);
14fprintf('checksum %.4f (rand differs from MATLAB; expect ~equal, not equal)\n', mean(y));