Is anyone with this problem *not* running ubuntu?

Me - RHEL 5.2 opteron:

Python 2.6.1 (r261:67515, Jan  5 2009, 10:19:01)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2

Fedora 9 PS3/PPC:

Python 2.5.1 (r251:54863, Jul 17 2008, 13:25:23)
[GCC 4.3.1 20080708 (Red Hat 4.3.1-4)] on linux2


Actually I now have some interesting results that indicate the issue isn't in Python or NumPy at all. I just wrote a C program to try to reproduce the error, and was able to do so (actually the difference is even larger).

Opteron:

float (32) time in usecs: 179698
double (64) time in usecs: 13795

PS3/PPC:

float (32) time in usecs: 614821
double (64) time in usecs: 37163

I've attached the code for others to review and/or try out. I guess this is worth showing to the libc people?

Andrew
#include <stdio.h>
#include <math.h>
#include <sys/time.h>

#define LEN 159161

float inp32[LEN];
float out32[LEN];

double inp64[LEN];
double out64[LEN];

int main(int argc, char** argv)
{
    struct timeval tv_start;
    struct timeval tv_stop;
    int i;

    for(i = 0; i < LEN; i++) {
        //inp32[i] = ((float)i / (float)LEN) *  (2 * M_PI);
        inp32[i] = (float)i;
        out32[i] = 0.0;
    }

    gettimeofday(&tv_start, NULL);
    for(i = 0; i < LEN; i++) {
        out32[i] = (float)cosf((float)inp32[i]);
    }
    gettimeofday(&tv_stop, NULL);

    if(tv_start.tv_sec != tv_stop.tv_sec) {
        puts("seconds changed, re-run the benchmark");
    }

    printf("float (32) time in usecs: %d\n", tv_stop.tv_usec - 
tv_start.tv_usec);


    for(i = 0; i < LEN; i++) {
        //inp32[i] = ((double)i / (double)LEN) *  (2 * M_PI);
        inp64[i] = (float)i;
        out64[i] = 0.0;
    }

    gettimeofday(&tv_start, NULL);
    for(i = 0; i < LEN; i++) {
        out64[i] = (double)cos((double)inp64[i]);
    }
    gettimeofday(&tv_stop, NULL);

    if(tv_start.tv_sec != tv_stop.tv_sec) {
        puts("seconds changed, re-run the benchmark");
    }

    printf("double (64) time in usecs: %d\n", tv_stop.tv_usec - 
tv_start.tv_usec);

    return 0;
}

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to