I just ran your code using Intel OneAPI, no problem at all.
It took less than 1 second.
For intel Fortran, you probably need to make sure you did,
-heap-arrays
Here maybe another relevant thread,
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 )
…
gfortran should run just fine without adding a flag I think. Although you can add some flags such as
-mcmodel=medium
or -frecursive
or other flags to heap arrays,
Thank you very much Dr. Fortran @sblionel and @shahmoradi !
I see Dr. Fortran @sblionel . Yeah, indeed I notice that it seems gfortran perhaps does not need to manually specify -heap-arrays as it automatically does so. Because the same code in a particular file of mine, for Intel Fortran I have to specify -heap-arrays otherwise it stack overflow, however for gfortran I do not really need a flag for that.
Thank you @shahmoradi , now I am more clear about the usage of ulimit -s unlimited. I just…
2 Likes