Measuring Performance with
oneMKL Support Functions
oneMKL
oneMKL
oneMKL
Measure Performance of dgemm
Use the
routine to return the elapsed CPU time in seconds.
dsecnd
The quick execution of the
routine makes it difficult to measure its speed, even for an operation on a large matrix. For this reason, the exercises perform the multiplication multiple times. You should set the value of the
dgemm
LOOP_COUNT
constant so that the total execution time is about one second.
* Fortran source code is found in dgemm_with_timing.f PRINT *, "Making the first run of matrix product using " PRINT *, "Intel(R) MKL DGEMM subroutine to get stable " PRINT *, "run time measurements" PRINT *, "" CALL DGEMM('N','N',M,N,K,ALPHA,A,M,B,K,BETA,C,M) PRINT *, "Measuring performance of matrix product using " PRINT *, "Intel(R) MKL DGEMM subroutine" PRINT *, "" S_INITIAL = DSECND() DO R = 1, LOOP_COUNT CALL DGEMM('N','N',M,N,K,ALPHA,A,M,B,K,BETA,C,M) END DO S_ELAPSED = (DSECND()  S_INITIAL) / LOOP_COUNT PRINT *, "== Matrix multiplication using Intel(R) MKL DGEMM ==" PRINT 50, " == completed at ",S_ELAPSED*1000," milliseconds ==" 50 FORMAT(A,F12.5,A) PRINT *, ""
Measure Performance Without Using dgemm
In order to show the improvement resulting from using
, perform the same measurement, but use a triplynested loop to multiply the matrices.
dgemm
* Fortran source code is found in matrix_multiplication.f PRINT *, "Making the first run of matrix product using " PRINT *, "triple nested loop to get stable run time" PRINT *, "measurements" PRINT *, "" DO I = 1, M DO J = 1, N TEMP = 0.0 DO L = 1, K TEMP = TEMP + A(I,L) * B(L,J) END DO C(I,J) = TEMP END DO END DO PRINT *, "Measuring performance of matrix product using " PRINT *, "triple nested loop" PRINT *, "" S_INITIAL = DSECND() DO R = 1, LOOP_COUNT DO I = 1, M DO J = 1, N TEMP = 0.0 DO L = 1, K TEMP = TEMP + A(I,L) * B(L,J) END DO C(I,J) = TEMP END DO END DO END DO S_ELAPSED = (DSECND()  S_INITIAL) / LOOP_COUNT PRINT *, "== Matrix multiplication using triple nested loop ==" PRINT 50, " == completed at ",S_ELAPSED*1000," milliseconds ==" 50 FORMAT(A,F12.5,A) PRINT *, ""
Compare the results in the first exercise using
to the results of the second exercise without using
.
dgemm
dgemm
You can find more information about measuring
performance from the article "A simple example to measure the performance of an
function" in the
Knowledge Base.
oneMKL
oneMKL
Intel® oneAPI
Math Kernel LibraryProduct and Performance Information


Performance varies by use, configuration and other factors. Learn more at
www.Intel.com/PerformanceIndex.
Notice revision #20201201
