public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Large slowdown with gfortran vs f77 (x7)
@ 2009-09-04 15:04 FX
  2009-09-04 15:48 ` Tobias Burnus
  0 siblings, 1 reply; 4+ messages in thread
From: FX @ 2009-09-04 15:04 UTC (permalink / raw)
  To: gcc, Fortran List; +Cc: jss

Hi Jeremy,

   -- it's unarguably a glibc issue: if exp() is fast and expf() is  
slow, why doesn't glibc implement expf() by calling exp()? (yes, there  
can be other issues like rounding or so, but they can also be dealt  
with separately)
   -- a similar bug was already reported a year and a half ago, and no  
activity was recorded on that front  (http://sources.redhat.com/bugzilla/show_bug.cgi?id=5997 
); overall, the math lib from glibc can be buggy and slow (and its  
development is not exactly proceeding at a steady pace) but political  
reasons prevent GCC to include its own math lib
   -- there is a GNU Fortran mailing-list where Fortran-related issues  
are welcome

Regards,
FX

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Large slowdown with gfortran vs f77 (x7)
@ 2009-09-04  8:45 Jeremy Sanders
  2009-09-08 19:28 ` James Cloos
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Sanders @ 2009-09-04  8:45 UTC (permalink / raw)
  To: gcc

Hi - We noticed some code was very slow in gfortran vs g77, almost a factor 
of 7 times slower. This appears to be because gfortran uses the expf 
liubrary function call for the fortran exp() function for single precision 
numbers, but g77 uses the exp library function (i.e. the double precision 
function).

You can see the very large speed differences by telling gfortran to always 
use double precision numbers.

This can be replicated with this simple program:

test.f:
      implicit none
      integer i,j
      real a, u
      do j=1,10
         do i=1,10000000
            a=exp(1.0+1.0/i)
            u = u+a
         end do
      end do
      print *,u
      end

Compiled with gfortran -O2:
real    0m29.921s
user    0m29.912s
sys     0m0.000s

Compiled with gfortran -O2 -fdefault-real-8:
real    0m4.306s
user    0m4.304s
sys     0m0.000s

This is with a newly built gcc 4.4.1 on Fedora 10 (glibc 2.9), x86-64.

As the difference comes down to the speed difference between exp and expf, 
is it a gcc issue or a glibc issue? Should gcc be using this slow function? 
It seems amazing that the same function call is 7 times slower for lower 
precision numbers!

Thanks

Jeremy

-- 
Jeremy Sanders <jss@ast.cam.ac.uk>   http://www-xray.ast.cam.ac.uk/~jss/
X-Ray Group, Institute of Astronomy, University of Cambridge, UK.
Public Key Server PGP Key ID: E1AAE053

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-08 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-04 15:04 Large slowdown with gfortran vs f77 (x7) FX
2009-09-04 15:48 ` Tobias Burnus
  -- strict thread matches above, loose matches on Subject: below --
2009-09-04  8:45 Jeremy Sanders
2009-09-08 19:28 ` James Cloos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).