This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Weird performance behaviour
- From: Oleg Endo <oleg dot endo at t-online dot de>
- To: Marcel Keller <m dot keller at bristol dot ac dot uk>, gcc-help at gcc dot gnu dot org
- Date: Sat, 12 Aug 2017 02:23:46 +0900
- Subject: Re: Weird performance behaviour
- Authentication-results: sourceware.org; auth=none
- References: <84ab7584-07c5-e4c8-808e-9e5613f4c122@bristol.ac.uk>
On Fri, 2017-08-11 at 18:01 +0100, Marcel Keller wrote:
> Hi,
>
> I've noticed that the performance of mpn_addmul_1 from MPIR can
> depend considerably on whether I link against libpthread, which
> strikes me as very weird:
>
> $ g++ -O3 Time-addmul_1.cpp addmul_1.o -o a.out
>
> $ g++ -O3 Time-addmul_1.cpp addmul_1.o -o b.out -lpthread
>
> $ ./a.out
> mpn_addmul_1: 0.506279
>
> $ ./b.out
> mpn_addmul_1: 0.682086
>
> Disassembling the binaries shows that the mpn function in
> Time-addmul_1.cpp is compiled exactly the same way.
There is nothing else in the code, except the 2 calls to clock_gettime.
So the time difference must come from there somehow.
You can check its implementation:
https://github.com/lattera/glibc/blob/master/sysdeps/unix/clock_gettime.c
So if there is __pthread_clock_gettime, it will try to use that.
__pthread_clock_gettime gets there by pulling in libpthread.
Cheers,
Oleg