引用:
浮点优化选项 -ffast-math:极大地提高浮点运算速度
http://blog.csdn.net/zjujoe/archive/2008/07/02/2604157.aspx
非常感谢,这是我在MPC5121上的运行结果:
测试1,带ffast-math
编译选项:CFLAGS= -O3 -mcpu=603e -fomit-frame-pointer -pipe -fsigned-char -funroll-loops -mhard-float -ffast-math
[root@EMA-Polar floattest]# ./floattest_songlixin
Start time is: 0.0
DIV End time is: 0.59649
MUL End time is: 0.119019
ADD End time is: 0.171965
SUB End time is: 0.224903
result1:37944672758190.882812
测试2,不带ffast-math
编译选项:CFLAGS= -O3 -mcpu=603e -fomit-frame-pointer -pipe -fsigned-char -funroll-loops -mhard-floa
[root@EMA-Polar floattest]# ./floattest_songlixin
Start time is: 0.0
DIV End time is: 0.319820
MUL End time is: 0.379179
ADD End time is: 0.432115
SUB End time is: 0.485192
result1:37944672758190.882812
测试3,软件模拟浮点,结果竟然是0
编译选项:CFLAGS= -O3 -mcpu=603e -fomit-frame-pointer -pipe -fsigned-char -funroll-loops -msoft-float
[root@EMA-Polar floattest]# ./floattest_songlixin
Start time is: 0.0
DIV End time is: 0.75
MUL End time is: 0.95
ADD End time is: 0.99
SUB End time is: 0.106
result1:0.000000