[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #10 from fxcoudert at gcc dot gnu dot org 2009-03-28 13:21 --- I think this is glibc issue, which can be worked around (as Jerry demonstrated) e.g. by using -ffast-math or by using a differently math library. Thus, I'm closing this PR. -- fxcoudert at gcc dot gnu dot org changed: What|Removed |Added CC||fxcoudert at gcc dot gnu dot ||org Status|NEW |RESOLVED GCC build triplet|x86_64-unknown-linux-gnu| GCC host triplet|x86_64-unknown-linux-gnu| Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #9 from jvdelisle at gcc dot gnu dot org 2008-03-29 21:19 --- I have submitted glibc PR http://sources.redhat.com/bugzilla/show_bug.cgi?id=5997 With a C test case that clearly shows the problem. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #8 from jvdelisle at gcc dot gnu dot org 2008-03-29 05:27 --- Browsing through the glibc sources I see two kinds of implementations for the sinf function, FPU and software. The FPU versions appear to be succinct assembly code with the expected FPU instructions. The software versions appear to be fairly elaborate and written in C using taylor series expansions. I wonder if the time difference being seen is that the slow sinf function is a software implementation rather than FPU. The problem does not occur with cos. I speculate that this is a configuration related problem. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #7 from jvdelisle at gcc dot gnu dot org 2008-03-29 04:48 --- The disparity goes away mostly using -ffast-math $ g77 -ffast-math demo1.f -o g771 $ time ./g771 result = -0.690680927 real0m0.594s user0m0.590s sys 0m0.004s $ gfc -ffast-math demo1.f -o gfc1 $ time ./gfc1 result = -0.69068092664138392 real0m0.720s user0m0.716s sys 0m0.003s Regardless sinf needs some work. See also glibc bug 1163: http://sources.redhat.com/bugzilla/show_bug.cgi?id=1163 Which identifies some other issues. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #6 from jvdelisle at gcc dot gnu dot org 2007-12-08 19:04 --- Note in comment #5 the g77 wrong result when using -m32. Not a good thing. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #5 from jvdelisle at gcc dot gnu dot org 2007-12-08 18:59 --- On x86-64 (gfc = gfortran) $ gfc -m32 demo1.f $ time ./a.out result = -0.69068092664140723 real0m0.552s user0m0.551s sys 0m0.001s $ gfc -m64 demo1.f $ time ./a.out result = -0.69068092107772827 real0m8.533s user0m8.532s sys 0m0.002s $ g77 -m32 demo1.f $ time ./a.out result = -0.990368962 real0m0.546s user0m0.545s sys 0m0.002s $ g77 -m64 demo1.f $ time ./a.out result = -0.690680921 real0m0.877s user0m0.874s sys 0m0.003s $ Something definitely wrong here. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #4 from burnus at gcc dot gnu dot org 2007-11-18 08:37 --- > It's 64-bit only, and it appears to be a glibc bug: with glibc on x86_64, > sinf((float) integer_variable) is slower than (float)sin((double) > integer_variable). Can it be that it has been fixed meanwhile? Using demo1.f on x86-64 (openSUSE factory; glibc 2.6.1 (20070803), g77 3.3.5 20050117; gfortran 4.3.0 20071117; AMD Athlon64 x2 4800+) I get the following timings with "-O2": g77 gfortran -m32 real(4) 0.408s 0.421s -m64 real(4) 1.040s 0.589s -m32 real(8) 0.411s 0.408s -m64 real(8) 0.976s 0.968s -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #3 from fxcoudert at gcc dot gnu dot org 2007-11-17 22:42 --- It's 64-bit only, and it appears to be a glibc bug: with glibc on x86_64, sinf((float) integer_variable) is slower than (float)sin((double) integer_variable). Paul Brook looked into it a bit, and said that while glibc's sin() was clearly well optimized, its sinf() was poor. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #2 from bdavis at gcc dot gnu dot org 2007-11-17 22:35 --- here is what i got on a P4, running FC8. [EMAIL PROTECTED] gfc]$ /usr/bin/gfortran -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=i386-redhat-linux Thread model: posix gcc version 4.1.2 20070925 (Red Hat 4.1.2-33) [EMAIL PROTECTED] gfc]$ /usr/bin/gfortran demo1.f [EMAIL PROTECTED] gfc]$ time ./a.out result = -0.690680926641407 real0m0.948s user0m0.914s sys 0m0.002s [EMAIL PROTECTED] gfc]$ /usr/bin/gfortran demo2.f [EMAIL PROTECTED] gfc]$ time ./a.out result =1570795059.20410 real0m1.853s user0m1.808s sys 0m0.004s [EMAIL PROTECTED] gfc]$ g77 --version GNU Fortran (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8) Copyright (C) 2006 Free Software Foundation, Inc. GNU Fortran comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of GNU Fortran under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING or type the command `info -f g77 Copying'. [EMAIL PROTECTED] gfc]$ g77 demo1.f [EMAIL PROTECTED] gfc]$ time ./a.out result = -0.990368962 real0m0.938s user0m0.912s sys 0m0.002s [EMAIL PROTECTED] gfc]$ g77 demo2.f [EMAIL PROTECTED] gfc]$ time ./a.out result = 1.57079506E+09 real0m2.386s user0m2.354s sys 0m0.004s gfortran g77 demo1 0m0.948s0m0.938s demo2 0m1.853s0m2.386s the answers were different on demo1.f with these versions, and on the P4 under linux, i say gfortran is OK. --bud -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128
[Bug fortran/34128] slow gfortran 4.x (library?) compared to g77 3.4
--- Comment #1 from fxcoudert at gcc dot gnu dot org 2007-11-17 00:07 --- While I'm trying to understand what happens, I should say that a simply workaround is to make your calculation happen in double precision (change "3.14159" into "3.14159d0"; after all, you want a double-precision result). g77 called sin() to perform the calculation, while gfortran calls sinf(). And sinf() happens to be way slower than sin() (I wonder why!). Maybe a bugreport to glibc will be in order here. -- fxcoudert at gcc dot gnu dot org changed: What|Removed |Added CC||fxcoudert at gcc dot gnu dot ||org Status|UNCONFIRMED |NEW Component|libfortran |fortran Ever Confirmed|0 |1 Keywords||missed-optimization Last reconfirmed|-00-00 00:00:00 |2007-11-17 00:07:55 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34128