slow math sin function for some values on amd64
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GLibC |
Fix Released
|
Wishlist
|
|||
glibc (Ubuntu) |
Triaged
|
Medium
|
Unassigned |
Bug Description
Hello.
I have found that math sin function is unreasonable slow (400us on Athlon64 A2 4800+) for some values. It only happens on 64bit distribution.
Used versions:
Kubuntu 7.10 amd64 gutsy gutter
linux kernel 2.6.24
libc6 2.6.1-1ubuntu10
libc6-dev 2.6.1-1ubuntu10
Some of those values: -------
0.9334058229264
2.3328432680770
3.7439477503636
3.9225160069792
4.0711651639931
4.7858438478542
5.9840767662578
Short program for testing: -------
#include <stdlib.h>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <sys/time.h>
using namespace std;
int main(int argc, char** argv) {
volatile union {
double dbl;
unsigned char hex[sizeof(
} value;
if (argc == sizeof(double)+1) {
for (int i=0; i < sizeof(double); i++) {
int tmp;
s >> hex >> tmp;
}
} else if (argc == 2) {
double tmp;
s >> tmp;
value.dbl = tmp;
} else {
cout << "usage: sintest 00 b0 6b e3 75 de ed 3f\n"
" sintest 0.9334058229264
return (EXIT_FAILURE);
}
cout.
cout << value.dbl << endl;
cout << "start\n";
struct timeval time1, time2;
gettimeofda
for (int i=0; i < 10000; i++) {
volatile double out = sin(value.dbl);
}
gettimeofda
long long diftime = 1000000ll * (time2.tv_sec - time1.tv_sec) +
cout << "end: " << diftime / 1000000ll << '.' << setw(6) << setfill('0') << diftime % 1000000ll << " s" << endl;
return (EXIT_SUCCESS);
}
Petr Cervenka
Changed in glibc: | |
status: | Unknown → Confirmed |
Changed in glibc: | |
importance: | Undecided → Medium |
status: | Incomplete → Triaged |
Changed in glibc: | |
importance: | Unknown → Medium |
Changed in glibc: | |
status: | Confirmed → Incomplete |
Changed in glibc: | |
status: | Incomplete → In Progress |
Changed in glibc: | |
importance: | Medium → Wishlist |
Changed in glibc: | |
status: | In Progress → Fix Released |
I would like to repost my previously deleted bug by (lazy IMHO) projects/ glibc/build/ libc_pic. a projects/ glibc/build/ elf/librtld. map.o '-Wl,-(' projects/ glibc/build/ elf/dl- allobjs. os projects/ glibc/build/ libc_pic. a -lgcc '-Wl,-)' /home/inova/ projects/ glibc/build/ elf/librtld. mapT projects/ glibc/build/ libc_pic. a(init- first.os) :(.data+ 0x0): multiple multiple_ libcs' projects/ glibc/build/ elf/dl- allobjs. os:/home/ inova/projects/ glibc/src/ glibc-20080218/ elf/rtld. c:641: projects/ glibc/build/ libc_pic. a(dl-addr. os): In function inside_ object' : projects/ glibc/src/ glibc-20080218/ elf/dl- addr.c: 158: multiple inside_ object' projects/ glibc/build/ elf/dl- allobjs. os:/home/ inova/projects/ glibc/src/ glibc-20080218/ elf/dl- open.c: 700: inova/projects/ glibc/build/ elf/librtld. map] Error 1 inova/projects/ glibc/src/ glibc-20080218/ elf' inova/projects/ glibc/src/ glibc-20080218'
<email address hidden>. The math sin function is at least 1000x slower on 64bit
distributions for special numbers (and carlos dosn't care about it).
I can't try it with CVS head, because I cannot connect to cvs through our firewall.
But even when I tried the latest snapshot, I couldn't build it (maybe another bug):
a - elf/dl-vdso.os
: /home/inova/
gcc -nostdlib -nostartfiles -r -o
/home/inova/
/home/inova/
/home/inova/
-Wl,-Map,
/home/inova/
definition of `__libc_
/home/inova/
first defined here
/home/inova/
`_dl_addr_
/home/inova/
definition of `_dl_addr_
/home/inova/
first defined here
collect2: ld returned 1 exit status
make[2]: *** [/home/
make[2]: Leaving directory `/home/
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/home/
make: *** [all] Error 2
Please, anyone with 64bit distribution and glibc CVS head, could you try the
attached example and post the time results of it? (or help me to build the
snapshot...)
Thank you
====== Original bug report ======= ======= ======= ======= ======= === 883266296237707 1381 0x3fedde75e36bb000 916363144351635 128 0x4002a9a9bb38add0 453548097051680 088 0x400df39ae0cdf500 437411706487182 528 0x400f615012801950 289992091478779 912 0x401048df854fdc20 097982426639646 292 0x401324b43fe92fc0 002727968851104 379 0x4017efb1d1df52a0
The math sin(double) function is in 64bit distribution (Kubuntu 7.10 AMD64 and
Fedora - unknown version) unreasonable slow (~400 microseconds on Atlon64 X2
4800+!!!) for some special values. In 32bit distribution is everything fine.
I captured some of those values:
0.9334058229264
2.3328432680770
3.7439477503636
3.9225160069792
4.0711651639931
4.7858438478542
5.9840767662578
Example: 883266296237707 1381;
#include <math.h>
int main(int argc, char** argv) {
volatile double value = 0.9334058229264
volatile double out;
int i;
for (i=0; i < 20000; i++)
out = sin(value);
return 0;
}