# Testing the performance of \`matmul\` under default compiler settings

**URL:** <https://fortran-lang.discourse.group/t/testing-the-performance-of-matmul-under-default-compiler-settings/4096>\
**Category:** Help\
**Created:** [July 31, 2022, 2:55am UTC](https://fortran-lang.discourse.group/t/testing-the-performance-of-matmul-under-default-compiler-settings/4096 "2022-07-31T02:55:16Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![CRquantum](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/crquantum/32/730_2.png) [@CRquantum](https://fortran-lang.discourse.group/u/CRquantum)\
**Post date:** [July 31, 2022, 3:59am UTC](https://fortran-lang.discourse.group/t/testing-the-performance-of-matmul-under-default-compiler-settings/4096/9 "2022-07-31T03:59:53Z")

</div>

That is because I used Intel MKL’s matmul which automatically uses multiple cores. So call cpu\_time() will not show real wall time.

> [@Does LAPACK/BLAS automatically use multi cores or threads?](https://fortran-lang.discourse.group/t/does-lapack-blas-automatically-use-multi-cores-or-threads/4072/23):
>
> I found one problem, it seems call cpu\_time() does not measure the time correctly when multiple threads are involved. When using Intel OneAPI with MKL, I use John Burkardt’s wtime() instead, so I run the code below, program kxk integer, parameter :: wp=selected\_real\_kind(14), n=5000 real(wp) :: a(n,n), b(n,n), c(n,n) real(wp) :: cpu1, cpu0 call random\_number( a ); a = a - 0.5\_wp call random\_number( b ); b = b - 0.5\_wp c = 0.0\_wp cpu0 = wtime() c = matmul( a, b ) …

About showing true wall time, you may check,

> [@How to show the true wall time instead of cpu\_time?](https://fortran-lang.discourse.group/t/how-to-show-the-true-wall-time-instead-of-cpu-time/2189):
>
> Deal all, A quick question, I want to see how long the subroutine XXX took, so should be t2-t1 below, call cpu\_time(t1) call XXX() call cpu\_time(t2) write(6,\*) 'time = ', t2-t1 But, when I use intel fortran, with /qparallel flag, I found sometime the cpu\_time no longer tell the true wall time. Eg, it actually took 1 second wall time, but with /qparallel, t2-t2 can show 10 seconds, obviously it show all the cpu\_time involved. But I only want the true wall time So, is there a way to show the…

---

_[View the full topic](https://fortran-lang.discourse.group/t/testing-the-performance-of-matmul-under-default-compiler-settings/4096)._
