Re: GCC's -ffast-math behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

于 2012/2/9 18:10, Andrew Haley 写道:

Okay.  Can you tell us how much faster than the builtins the Intel lib
actually, is, and how you measured that?


I use the code main.c (test sin speed)

On Win7 64bit, gcc 4.6.2 32bit

gcc -O3 -ffast-math main.c -o main.exe

run main.exe will cost 6.853s.

When linking with intel libM no fastmath

gcc -O3 main.c -o main.exe libmmt.lib libircmt.lib

run main.exe will cost 4.367s.

ps : libmmt.lib and libircmt.lib comes from Intel C/C++ Compiler.

Best Regards,

#include <stdio.h>
#include <stdlib.h> 
#include <time.h> 
#include <math.h>

#define INTEG_FUNC(x)  abs(sin(x))

int main(void)
   unsigned int i, j, N;
   double step, x_i, sum;
   double start, finish, duration;
   double interval_begin = 0.0;
   double interval_end = 2.0 * 3.141592653589793238;

   start = clock();

   printf("     \n");
   printf("    Number of    | Computed Integral | \n");
   printf(" Interior Points |                   | \n");
   for (j=2;j<27;j++)
    printf("------------------------------------- \n");

     N =  1 << j;
     step = (interval_end - interval_begin) / N;
     sum = INTEG_FUNC(interval_begin) * step / 2.0;

     for (i=1;i<N;i++)
        x_i = i * step;
        sum += INTEG_FUNC(x_i) * step;

     sum += INTEG_FUNC(interval_end) * step / 2.0;

     printf(" %10d      |  %14e   | \n", N, sum);
   finish = clock();
   duration = (finish - start);
   printf("     \n");
   printf("   Application Clocks   = %10e  \n", duration);
   printf("     \n");

[Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

Add to Google