This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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] | |
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.682086Disassembling the binaries shows that the mpn function in Time-addmul_1.cpp is compiled exactly the same way.
I'm running CentOS 7 and GCC 6.2 on a Haswell CPU, but the difference also appears on an Ivy Bridge. All inputs and outputs are attached.
Does anyone have any idea why this could be? Best regards, Marcel
Attachment:
b.out
Description: Binary data
Attachment:
a.out
Description: Binary data
#include <mpir.h>
#include <stdlib.h>
#include <time.h>
const int t = 5;
const int n = 1e8;
void mpn(mp_limb_t* zz, mp_limb_t* x, mp_limb_t y)
{
struct timespec start, stop;
clock_gettime(CLOCK_REALTIME, &start);
for (int i = 0; i < n; i++)
zz[t] = mpn_addmul_1(zz, x, t, y);
clock_gettime(CLOCK_REALTIME, &stop);
printf("mpn_addmul_1: %f\n", 1e-9 * (stop.tv_nsec - start.tv_nsec) +
(stop.tv_sec - start.tv_sec));
}
int main()
{
mp_limb_t x[t+1], y, z[t+1];
mpn(z, x, y);
}
Attachment:
addmul_1.o
Description: Binary data
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |