[Fortran] 纯文本查看 复制代码 !---------------------------------------
! Intel Core2 Quad @2.83GHz, Windows 10
! Compiler default optimizations
!
! Intel 9 (sec)
!
! GNU 14
! Absooft 21
! G95 21
! Lahey 24
!
! NAG 121
! PGI 127
!
! Silverfrost 331
! Compaq 546
!---------------------------------------
program no_parallel
implicit none
integer, parameter :: rk = SELECTED_REAL_KIND(P=15)
real(kind=rk) :: pi
integer :: i, n_limit, c1, c2, c_rate, c_max
!-----------------
n_limit = 2000000000
call system_clock(c1, c_rate, c_max)
pi = 0.0_rk
do i = 1, n_limit
pi = pi + (-1)**(i+1) / real( 2*i-1, kind=rk )
end do
pi = pi * 4.0_rk
call system_clock(c2, c_rate)
IF( c2 < c1 ) c2 = c2 + c_max
write(*,*) pi, real(c2-c1)/real(c_rate)
end program no_parallel
Intel的效率確實沒得比, GNU/Absoft/G95/Lahey持平, NAG/PGI令人跌破眼鏡, 還是我的測試有問題? |