I wrote this code:
program exponent
implicit none
real(8) :: sum
integer(8) :: i
integer :: limit
real :: start, end
sum = 0d0
limit = 10000000
call CPU_TIME(start)
do i=1, limit
sum = sum + exp(i*1.d0/limit)
end do
call CPU_TIME(end)
print *, sum
print '("Time = ",f6.3," seconds.")',end-start
end program exponent
And I compiled it with gfortran 10.1.0 and ifort 19.1.3.304 on CentOS Linux 7 using:
ifort *.f90 -O3 -o intel.out
gfortran *.f90 -O3 -o gnu.out
and the outputs are:
gnu:
17182819.143730670
Time = 0.248 seconds.
intel:
17182819.1437313
Time = 0.051 seconds.
When I run a few times, the run time of each is pretty much the same.
Why is ifort faster than gfortran and how can I make gfortran run as fast as ifort?