LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: fallening

大家都用什么CFLAGS?

[复制链接]
发表于 2008-4-25 08:35:37 | 显示全部楼层
顺便再说一下,native生成的包明显要比其他的小一点。
回复 支持 反对

使用道具 举报

发表于 2008-4-25 10:18:09 | 显示全部楼层
按照你的结果来说确实,针对cpu优化的结果居然不如默认的。

不过我做这个测试的时候不知道为何,每次结果相差都很大,10s到8s的都有,甚至貌似和重复的间隔都有关系,继续关注中。

而且这个是取随机数的测试其实也不能代表全部结果。貌似都是那什么-fomit-frame-pointer的功劳
回复 支持 反对

使用道具 举报

发表于 2008-5-2 03:50:12 | 显示全部楼层
最终报告:

-O2 -march=pentium-m -pipe====================>9.3"
-O2 -march=pentium-m -pipe -fomit-frame-pointer========>9.4+"
-O2 -march=i686 -mtune=generic  -pipe===============>9.3"
-O2 -march=i686 -mtune=generic  -pipe -fomit-frame-pointer==>8.8"
-O2 -march=native -pipe========================>9.3"
-O2 -march=native -pipe -fomit-frame-pointer===========>8.8"

这样终于明朗化了,-fomit-frame-pointer可以起到关键的作用,但第二组的结果让我很意外。

结论:i686下,非多媒体程序(即采用sse指令的如mplayer, audacious等),除了上面所列的第二组是例外,源里所打的包与自己用所谓的-march最优化参数编译的并无区别,-fomit-frame-pointer参数在不少情况下会有提升,但不明显(%5左右),而该参数在x86_64下默认是开启的,也即是说,64位的源已经对绝大多数程序作出了优化,包括默认打开了sse2。据我所知,好像还没有一个程序支持sse2+的指令,用64位系统的同学们欢呼吧~不必羡慕什么gentoo榨干机器的油水,arch万岁!

希望看到64位系统下的测试,如果wiki所说属实,那么应该不会有什么区别。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-10-6 20:01:49 | 显示全部楼层
用64位的测试了一下:
$ g++ -o test test.cc ran.cc $CFLAGS
[feng@enlightenment test]$ ./test
It costs 3.1 second(s) to generate 100000000 random numbers.
Sum of them is 4.99974e+07
[feng@enlightenment test]$ g++ -o test test.cc ran.cc -O2 -march=nocona -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
[feng@enlightenment test]$ ./test
It costs 3.07 second(s) to generate 100000000 random numbers.
Sum of them is 5.00028e+07
[feng@enlightenment test]$ g++ -o test test.cc ran.cc -O3 -march=nocona -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
[feng@enlightenment test]$ ./test
It costs 3.08 second(s) to generate 100000000 random numbers.
Sum of them is 5.00023e+07
[feng@enlightenment test]$ g++ -o test test.cc ran.cc -O3 -march=native -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
[feng@enlightenment test]$ ./test
It costs 3.08 second(s) to generate 100000000 random numbers.
Sum of them is 5.00038e+07
[feng@enlightenment test]$ g++ -o test test.cc ran.cc -O2 -march=native -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
[feng@enlightenment test]$ ./test
It costs 3.09 second(s) to generate 100000000 random numbers.
Sum of them is 5.00012e+07
[feng@enlightenment test]$ g++ -o test test.cc ran.cc -O2 -march=native -pipe -fomit-frame-pointer
[feng@enlightenment test]$ ./test
It costs 3.08 second(s) to generate 100000000 random numbers.
Sum of them is 4.99989e+07
[feng@enlightenment test]$ g++ -o test test.cc ran.cc -O3 -march=native -pipe -fomit-frame-pointer
[feng@enlightenment test]$ ./test
It costs 3.09 second(s) to generate 100000000 random numbers.
Sum of them is 4.99966e+07
[feng@enlightenment test]$ g++ -o test test.cc ran.cc
[feng@enlightenment test]$ ./test
It costs 4.87 second(s) to generate 100000000 random numbers.
Sum of them is 4.99989e+07
[feng@enlightenment test]$ icpc -o test test.cc ran.cc
ran.cc(36): warning #279: controlling expression is constant
        if("Random Number Generation: Impossible Thing Happened! EXIT...\n");
           ^
[feng@enlightenment test]$ ./test
It costs 4.24 second(s) to generate 100000000 random numbers.
Sum of them is 5.00023e+07
[feng@enlightenment test]$ icpc -o test test.cc ran.cc -fast
ran.cc(36): warning #279: controlling expression is constant
        if("Random Number Generation: Impossible Thing Happened! EXIT...\n");
           ^

ipo: remark #11000: performing multi-file optimizations
ipo: remark #11005: generating object file /tmp/ipo_icpcbu3gnn.o
[feng@enlightenment test]$ ./test
It costs 3 second(s) to generate 100000000 random numbers.
Sum of them is 5.00055e+07
回复 支持 反对

使用道具 举报

发表于 2008-10-7 22:59:00 | 显示全部楼层
不行的话。可以使用 time makepkg
看看每次的参数改变所用的时间。
回复 支持 反对

使用道具 举报

发表于 2008-10-8 21:46:57 | 显示全部楼层
CFLAGS="-march=k8-sse3 -O2 -pipe -fomit-frame-pointer"
回复 支持 反对

使用道具 举报

发表于 2008-10-9 19:01:23 | 显示全部楼层
Post by tpxc;1819238
CFLAGS="-march=k8 -O3 -pipe -fomit-frame-pointer -msse3"

我的。


GCC 4.3 可以用k8-sse3这个集合了
回复 支持 反对

使用道具 举报

发表于 2008-10-9 22:16:01 | 显示全部楼层
Post by hejux;1892164
GCC 4.3 可以用k8-sse3这个集合了


觉得还是直接native算了……
回复 支持 反对

使用道具 举报

发表于 2008-10-9 23:00:47 | 显示全部楼层
-match=core2
回复 支持 反对

使用道具 举报

发表于 2009-3-28 17:25:30 | 显示全部楼层
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=core2 -mtune=core2 -O2 -pipe -mssse3 -fomit-frame-pointer"

cpu: core2 duo t5870
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表