This is an oldie - I'm surprised Intel got hung by it.
I'm not sure I've got the details right (maybe Van Snyder or Jeanne
Martin can tell it better), but what I remember goes somewhat like this:
Around 1980 we were running Cray's at Lawrence Berkeley Lab, when Cray
released their latest super-optimized Fortran compiler. It did all kinds
of array ops etc about 5 times faster than the previous version
(depending on the bench-mark of course) and it was the first time the
hot-shot programmers who worked for me actually considered abandoning
hand-coded optimization.
We only found one real flaw in that compiler. It "knew" that all Fortran
intrinsic functions were "pure" (as one might say some 10 years later),
so it could call RANDOM once and copy the result into all the array
elements.
Various users found this flaw in about the first 10 microseconds of
benchmarking, and Cray issued a bug fix right away.
= Loren P Meissner
-----Original Message-----
From: Fortran 90 List [mailto:[log in to unmask]] On Behalf
Of Michael Metcalf
Sent: Saturday, November 06, 2004 7:36 AM
To: [log in to unmask]
Subject: Re: error of rand with intel fortran compiler
> do i=1,4
> a(i)=rand()
> c if the following line is added, it works again.
> c write(*,*)a(i)
> end do
The compiler sees a function called with unchanged (no) arguments, and
optimizes the calls to a single reference. Clever compiler. With the
write statement in place, the optimization is not performed as this is
equivalent to a call to a subroutine.
Regards,
Mike Metcalf
|