callgrind and sin/cos under GCC
Markus Trippelsdorf
markus@trippelsdorf.de
Tue Sep 11 15:16:00 GMT 2012
On 2012.09.11 at 16:00 +0100, Andrew Haley wrote:
> On 09/11/2012 03:56 PM, Pete Flugstad wrote:
> > Hi,
> >
> > I'm trying to profile (using valgrind's callgrind) some code that
> > uses sin/cos and I'm seeing some things I'm not expecting.
> >
> > My OS is Ubuntu 12.04/x86_64, hardware is an Intel Xeon X5690. GCC
> > is the distro version, gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1. I'm
> > compiling with -O2.
> >
> > The strange thing is that I'm seeing sincos (from libm.so) is
> > showing up in the callgrind output. From reading the manual, GCC
> > should replace our calls to sin and cos with __builtin_ versions,
> > right?
>
> Yes, it does, and one of the things that expanding the builtins does is
> call sincos().
BTW, s_sincos.S was removed from glibc a while ago. So if you're running
a recent glibc version you end up with the slow floating-point sin/cos
implementation, that causes a 50% slowdown.
See: http://sourceware.org/bugzilla/show_bug.cgi?id=14412
However Intel has recently posted fast SSE sin/cos/sincos versions for
libm (sinf, cosf and sincosf). I think gcc should be updated to call
those instead.
--
Markus
More information about the Gcc-help
mailing list