This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/5997] New: Very slow execution of sinf function


With this test case:

#include <stdio.h>
#include <math.h>

unsigned int ta;

main ()
{
  double result;
  for (ta = 1; ta <= 8000000; ta++)
    {
      result = sin(ta * 3.14159);
    }
  printf("result = \t%.13e\n", result);
}

Using sin vs sinf.

sin:

$ time ./a.out
result =        -6.9068092664138e-01

real    0m0.782s
user    0m0.778s
sys     0m0.004s

sinf:

$ time ./a.out
result =        -6.9068092107773e-01

real    0m8.622s
user    0m8.605s
sys     0m0.009s

The difference in assembly code (-S output):

44,47c44,47
< 	call	sin
< 	movsd	%xmm0, -40(%rbp)
< 	movq	-40(%rbp), %rax
< 	movq	%rax, -8(%rbp)
---
> 	cvtsd2ss	%xmm0, %xmm0
> 	call	sinf
> 	cvtss2sd	%xmm0, %xmm0
> 	movsd	%xmm0, -8(%rbp)

I don't think the conversion functions should account for this huge time
difference. Also with -m32 and sinf I get:

$ time ./a.out
result =        -6.9068092664141e-01

real    0m1.157s
user    0m0.765s
sys     0m0.002s

Which is more reasonable.

$ gcc -v
Using built-in specs.
Target: x86_64-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=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)

I am running latest Fedora 8

See also gfortran bug pr34128.

-- 
           Summary: Very slow execution of sinf function
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: jvdelisle at gcc dot gnu dot org
                CC: glibc-bugs at sources dot redhat dot com
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-redhat-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=5997

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]