LinuxSir.cn,穿越时空的Linuxsir!

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

大家都用什么CFLAGS?

[复制链接]
发表于 2008-2-24 20:47:30 | 显示全部楼层
Post by blance;1819622
记得用gentoo的时候配置文件里面注释的说明写是核心数+1 也就是 单核是j2,双核是j3
难道arch特殊点?


我就是在gentoo版本问的时候别人都这么说的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-2-24 22:36:00 | 显示全部楼层
听8楼的,改成
CFLAGS="-march=native -O2 -pipe"
回复 支持 反对

使用道具 举报

发表于 2008-2-24 23:42:06 | 显示全部楼层
ls,-fomit-frame-pointer也是要的阿。
回复 支持 反对

使用道具 举报

发表于 2008-2-25 10:11:46 | 显示全部楼层
Post by jarryson;1819634
我就是在gentoo版本问的时候别人都这么说的


那arch默认设置是j2怎么解释? 难道是0.5个核心?:)
回复 支持 反对

使用道具 举报

发表于 2008-2-25 12:48:16 | 显示全部楼层
Post by blance;1819773
那arch默认设置是j2怎么解释? 难道是0.5个核心?:)


好像每个版本默认都是j2把,为了安全起见把,怕把cpu占太多了,还有部分程序编译要求j1的好像
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-2-25 13:22:10 | 显示全部楼层
Post by zhuqin_83;1819702
ls,-fomit-frame-pointer也是要的阿。

阿,晕倒,昨天晚上让它编译了n个软件,就等今天中午来装了
回复 支持 反对

使用道具 举报

发表于 2008-2-25 13:34:27 | 显示全部楼层
我一直是遵循Gentoo手册来设置的。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-2-25 14:30:34 | 显示全部楼层
实际测试了一下
分别用
1. -Wall -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
2. -Wall -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
3. -march=native -O2 -pipe -fomit-frame-pointer
4. -march=native -O3 -pipe -fomit-frame-pointer
发现1 > 2 > 4 > 3
以下是

  1. [feng@enlightenment tmp]$ g++ -c ran.cc -Wall -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
  2. [feng@enlightenment tmp]$ g++ -c test.cc -Wall -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
  3. [feng@enlightenment tmp]$ g++ -o test -Wall -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse test.o ran.o
  4. [feng@enlightenment tmp]$ ./test
  5. It costs 9.76 second(s) to generate 100000000 random numbers.
  6. Sum of them is 4.99976e+07

  7. [feng@enlightenment tmp]$ g++ -c -Wall -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse ran.cc
  8. [feng@enlightenment tmp]$ g++ -c -Wall -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse test.cc
  9. [feng@enlightenment tmp]$ g++ -o test -Wall -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse test.o ran.o
  10. [feng@enlightenment tmp]$ ./test
  11. It costs 9.82 second(s) to generate 100000000 random numbers.
  12. Sum of them is 4.99989e+07

  13. [feng@enlightenment tmp]$ g++ -c -march=native -O2 -pipe -fomit-frame-pointer ran.cc
  14. [feng@enlightenment tmp]$ g++ -c -march=native -O2 -pipe -fomit-frame-pointer test.cc
  15. [feng@enlightenment tmp]$ g++ -o test -march=native -O2 -pipe -fomit-frame-pointer test.o ran.o
  16. [feng@enlightenment tmp]$ ./test
  17. It costs 9.98 second(s) to generate 100000000 random numbers.
  18. Sum of them is 4.99979e+07

  19. [feng@enlightenment tmp]$ g++ -c -march=native -O3 -pipe -fomit-frame-pointer ran.cc
  20. [feng@enlightenment tmp]$ g++ -c -march=native -O3 -pipe -fomit-frame-pointer test.cc
  21. [feng@enlightenment tmp]$ g++ -o test -march=native -O3 -pipe -fomit-frame-pointer test.o ran.o
  22. [feng@enlightenment tmp]$ ./test
  23. It costs 9.96 second(s) to generate 100000000 random numbers.
  24. Sum of them is 4.99988e+07

复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-2-25 14:34:28 | 显示全部楼层
check the attachment for the source code.

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2008-2-25 16:11:31 | 显示全部楼层
晕死,不过你这样测试岂不是没有比较。

我测了6组(所有数据都是测多次求均,cpu设为performance,即频率保持最大)
测试环境:arch linux 2.6.24.1,gcc 4.2.3,cpu=Dothan2 1.73GHz,RAM=1.5GB,纯console模式。
1。-O2 -march=pentium-m -pipe -fomit-frame-pointer====================>8.91"
2。-O2 -march=native -pipe -fomit-frame-pointer=======================>9.14"
3。-O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse=>8.91"
4。-O2 -march=native -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse====>9.14"
5。-O3 -march=pentium-m -pipe -fomit-frame-pointer====================>8.91"
6。-O3 -march=native -pipe -fomit-frame-pointer=======================>9.14"

故结论是:
1。-march=pentium-m快于-march=native
2。-msse2 -mmmx之类不必另行添加,有-march就会自动加上相对应的。
3。-mfpmath看不出来作用。
4。-O2和-O3在这个测试中表现一致。其实据官方称,也就最多1%的区别,可能变慢,可能变快,后者体积会更大一些,不稳定一些,风险大。

所以,我们应该选择
-march=xxx(非native)-O2 -pipe -fomit-frame-pointer
绕了半天终于回来了,哭。。。
回复 支持 反对

使用道具 举报

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

本版积分规则

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