Public bug reported:

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.93340582292648832662962377071381      00 b0 6b e3 75 de ed 3f         
0x3fedde75e36bb000
2.3328432680770916363144351635128       d0 ad 38 bb a9 a9 02 40         
0x4002a9a9bb38add0
3.7439477503636453548097051680088       00 f5 cd e0 9a f3 0d 40         
0x400df39ae0cdf500
3.9225160069792437411706487182528       50 19 80 12 50 61 0f 40         
0x400f615012801950
4.0711651639931289992091478779912       20 dc 4f 85 df 48 10 40         
0x401048df854fdc20
4.7858438478542097982426639646292       c0 2f e9 3f b4 24 13 40         
0x401324b43fe92fc0
5.9840767662578002727968851104379       a0 52 df d1 b1 ef 17 40         
0x4017efb1d1df52a0

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(double)];
    } value;
    
    if (argc == sizeof(double)+1) {
        for (int i=0; i < sizeof(double); i++) {
            istringstream s(argv[i+1]);
            int tmp;
            s >> hex >> tmp;
            value.hex[i] = tmp;
        }
    } else if (argc == 2) {
        istringstream s(argv[1]);
        double tmp;
        s >> tmp;
        value.dbl = tmp;
    } else {
        cout << "usage: sintest 00 b0 6b e3 75 de ed 3f\n"
                "       sintest 0.93340582292648832662962377071381";
        return (EXIT_FAILURE);
    }
    
    cout.precision(32);
    cout << value.dbl << endl;

    cout << "start\n";
    
    struct timeval time1, time2;
    gettimeofday(&time1, NULL);
    for (int i=0; i < 10000; i++) {
        volatile double out = sin(value.dbl);
    }
    gettimeofday(&time2, NULL);
    
    long long diftime = 1000000ll * (time2.tv_sec - time1.tv_sec) +
                         (time2.tv_usec - time1.tv_usec);
    
    cout << "end: " << diftime / 1000000ll << '.' << setw(6) << setfill('0') << 
diftime % 1000000ll << " s" << endl;
    
    return (EXIT_SUCCESS);
}

Petr Cervenka

** Affects: glibc (Ubuntu)
     Importance: Undecided
         Status: New

-- 
slow math sin function for some values on amd64
https://bugs.launchpad.net/bugs/192134
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to