From: linuxl4 on
which is the right result?

[~]$gfortran -O3 -mfpmath=sse 1.f90
[~]$./a.out
6.58525669031961858E-003 7.9937691319363333
1.4509816014893020 1.0090300749140695


[~]$gfortran -O3 -march=pentium4 -mfpmath=sse 1.f90
[~]$./a.out
0.44205593600246473 9.2462226979048534
1.4528890918105246 1.3554810697489428


[~]$ifort -O3 1.f90
[~]$./a.out
8.554852640247490E-002 9.54768689794389
1.09689937673841
1.01118314002791


[~]$ifort -O3 -xN 1.f90
[~]$./a.out
4.946287126281090E-003 9.12193913100264
1.13556275072972
1.03430294371455


[~]$gfortran -O3 -march=pentium4 -mfpmath=sse -limf 1.f90
[~]$./a.out
4.94628712628109035E-003 9.1219391310026392
1.1355627507297212 1.0343029437145510

--------------------------------------
program testsse
implicit none
integer,parameter :: N=3000000
real(kind=8) ::
x=0.6333333333_8,y=0.7222222222_8,z=0.43134193_8,t=0.13413_8
real(kind=8) :: z1,z2,z3,z4
integer :: i
do i=1,N
z1 = sin(x)
z2 = cos(y)
z3 = tan(z)
z4 = sin(t)*cos(t)
x = z2 + 1.0_8
y = z3 + 1.0_8
z = z4 + 1.0_8
t = z1 + 1.0_8
enddo
print *, x,y,z,t
end program testsse
From: linuxl4 on
sorry ,the first should be:


[~]$gfortran -O3 -mfpmath=387 1.f90
[~]$./a.out
6.58525669031961858E-003 7.9937691319363333
1.4509816014893020 1.0090300749140695

From: Michel Olagnon on
linuxl4(a)sohu.com wrote:
> which is the right result?

My easy guess is that they are all wrong...

From: Arjen Markus on
On 28 dec, 11:28, Michel Olagnon <molag...(a)ifremer-a-oter.fr> wrote:
> linu...(a)sohu.com wrote:
> > which is the right result?
>
> My easy guess is that they are all wrong...

The program accumulates the unavoidable small errors
over a large number of steps. So, Michel is probably
quite right.

What happens to the answers if you use 10 or 100 steps?
When do the answers start to differ (at what number of
steps)?

But perhaps a more important question: what are you trying
to achieve?

Regards,

Arjen
From: linuxl4 on
This is just a test program to compare gfortran and ifort's speeds of
calculating sin,cos and so on.since ifort calculates those functions
with its simd intrinsics instead of libm, it is faster than gfortran.
But a interesting thing I found is that gfortran can also call
ifort's libimf.so library to caculate sin/cos/tan function and the
result is correct.