- To: Andrew Haley <aph@xxxxxxxxxx>
- Subject: Re: GCC's -ffast-math behavior
- From: xunxun <xunxun1982@xxxxxxxxx>
- Date: Thu, 09 Feb 2012 18:20:57 +0800
- Cc: gcc-help@xxxxxxxxxxx
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1329387706; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC: Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=E85Ig1n+AefyqbnolhpwZk8HePE=; b=NJ+fglJLJYxQMO/ACCf30kdUYCPz43nMJ6LRCeoOP+uufS+9keKI07UZlvNMeJ wSwjBbFs1gyzrYs2CGb/2zdgawoi+NY+L6mvF2+UuOoAPsW/6YcymzvAlVyG7nMe 5CvDufhbA/tMBuBs519edolGXJkg1UkfmuK3PwBdU8Eqg=
- In-reply-to: <4F339BA8.3050809@redhat.com>
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20120129 Thunderbird/10.0
于 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?
Andrew.
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,
xunxun
#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]