Blame src/Matlab/FlopsMatrixMatrix.m

Packit 577717
function FlopsMatrixMatrix
Packit 577717
Packit 577717
% Compute a Matrix Matrix multiply 
Packit 577717
% on square arrays sized from 50 to 500,
Packit 577717
% in steps of 50. 
Packit 577717
%
Packit 577717
% Use the PAPI flops call to measure the floating point operations performed.
Packit 577717
% For each size, display:
Packit 577717
% - number of floating point operations
Packit 577717
% - theoretical number of operations
Packit 577717
% - difference
Packit 577717
% - per cent error
Packit 577717
% - mflops/s
Packit 577717
Packit 577717
fprintf(1,'\nPAPI Matrix Matrix Multiply Test');
Packit 577717
fprintf(1,'\n%12s %12s %12s %12s %12s %12s\n', 'n', 'ops', '2n^3', 'difference', '% error', 'mflops')
Packit 577717
for n=50:50:500,
Packit 577717
    a=rand(n);b=rand(n);c=rand(n);
Packit 577717
    flops(0);
Packit 577717
    c=c+a*b;
Packit 577717
    [count,mflops]=flops;
Packit 577717
    fprintf(1,'%12d %12d %12d %12d %12.2f %12.2f\n',n,count,2*n^3,count - 2*n^3, (1.0 - ((2*n^3) / count)) * 100,mflops)
Packit 577717
end