已阅读5页,还剩20页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Linux系统中使用GCC CPU参数优化代码编译/er_shi/blog/static/11838168200811310854432/Link - Wed, 13 Feb 2008 10:08:54 +0800 Description:1 Safe CFLAGS to use for Gentoo 1.1 gcc-4.2.0 or newer 1.2 i386 1.3 i486 2 Intel Processors 2.1 Pentium 2.2 Pentium w/ MMX 2.3 Cyrix MediaGX / AMD Geode GX1 2.4 Pentium Pro 2.5 Pentium II 2.6 Celeron (Mendocino), aka Celeron1 2.7 Pentium III 2.8 Celeron (Coppermine) 2.9 Celeron (Willamette) 2.10 Pentium M(Centrino)/Celeron M 2.11 Mobile Pentium 4-M (Northwood) 2.12 Pentium 4 2.13 Pentium 4 (Prescott) / Celeron D 2.14 Pentium D 8xx / 9xx 2.15 Xeon w/o EM64T 2.16 Xeon w/EM64T (also Pentium 4 P6xx) 2.17 Intel Core Solo/Duo, Pentium Dual-Core Txxxx 2.18 Intel Core 2 Duo/Quad / Xeon 51xx/53xx, Pentium Dual-Core Exxxx 3 VIA Processors 3.1 Esther C5J (Via C7) 3.2 C3 Nehemiah (C5X/C5XL/C5P) (VIA) 3.3 C3 Samuel/Ezra (Via EPIA) 4 Transmeta Processors 4.1 Transmeta Crusoe 4.2 Transmeta Efficeon 5 AMD Processors 5.1 K6 (AMD) 5.2 K6-2 (AMD) 5.3 Geode LX (AMD) 5.4 K6-3 (AMD) 5.5 Duron (AMD) 5.6 Mobile Duron (AMD) 5.7 Duron Morgan (AMD) 5.8 Athlon (AMD) 5.9 Athlon-tbird (AMD) 5.10 Athlon-tbird XP/Duron (AMD) 5.11 Athlon 4 (AMD) 5.12 Athlon XP/Geode NX (AMD) 5.13 Athlon MP (AMD) 5.14 Athlon 64 (AMD) 5.15 Athlon 64 X2 (AMD) 5.16 1xx Opteron (AMD) 5.17 2xx/8xx Opteron (AMD) 5.18 22xx Dual-Core Opteron (AMD) 5.19 23xx Quad-Core Barcelona (AMD) 5.20 Sempron/Sempron64 (AMD) 5.21 Turion64 (AMD) 5.22 Mobile Sempron (AMD) 6 PowerPC Processors 6.1 PowerPC 601 6.2 PowerPC 603 6.3 PowerPC 603e 6.4 PowerPC 604 6.5 PowerPC 604e 6.6 PowerPC 604e 6.7 PowerPC 750 (G3) 6.8 PowerPC 750cx (G3e) 6.9 PowerPC 7400 (G4) 6.10 PowerPC 7450 (G4 second generation) 6.11 PowerPC 970 (G5) 6.12 Cell Broadband Engine (Playstation 3) 6.13 PowerPC (If you dont know which one) 6.14 Embedded PowerPC CPUs 7 Other Processors 7.1 Sparc 7.2 Sparc 64 7.3 HPPA 1.1 7.4 HPPA 2.0 7.5 Alpha ev56 7.6 Alpha ev67 8 See Also 8.1 gcccpuopt 8.2 Relevant files in gcc source code 8.3 Other links edit Safe CFLAGS to use for GentooThese CFLAGS are for gcc 3.x and 4.x. To check your version:gcc -versionYou can see which CPU you have with the following command:cat /proc/cpuinfoIf youre running Intel, you can also use x86info to get more detailed info about your chip:emerge -av x86infoThis page is for those who dont want to experiment, and want a stable system, but still optimized for their CPU. But remember, by using these flags, binaries from your system might not work on another one with a different CPU. So if you compiled with optimizations for a Pentium 4 (-march=pentium4), you cant share a hard disk or packages with a friend who only has a Pentium MMX (-march=pentium-mmx). Though the other way around should work, see below.This is the case if you are using the -march flags. If you use -mtune instead without any -march option, your binaries are backward compatible down to i386, but the scheduling is optimized for your choosen architecture. CPUs are also backward compatible so if you update your system with a new CPU you can still use your old packages. There is one exception though; if your old CPU supports a feature, like AMDs 3dnow, that your new CPU doesnt. So if you have an athlon (-march=athlon) and upgrade to a pentium4 your old packages might not work. You can mix -march and -mtune if you, for example, would like to create binaries that would run on any i686 but are optimized for a pentium4. This would be accomplished by using -march=i686 and -mtune=pentium4.Note that -O2 is regarded as safer than -O3, and -O3 can often be a counter-productive attempt at optimization. On computers with limited cache and/or memory, -Os may provide better performance in some cases through smaller binaries, although it is slower when using the OpenSSL library with small keys (DSA keys with less than 2048 bits on VIA C3-2, 1200 MHz and 64 kb on-die cache).Note: This is only true if the platform has unusually fast unaligned access capability since -Os disables some alignment. A better solution is -O2 -fno-reorder-blocks -fno-reorder-functionsPlease note that all the CFLAGS below look like they have a lowercase O. It really is an uppercase O. If you enter a lowercase O in your CFLAGS, then you will break your Portage and you wont be able to install anything. If you see the following error in your emerge output, than it could point to this problem.checking whether the C compiler works. configure: error: cannot run C compiled programs.GCC has a number of flags for CPU features like MMX and SSE; -mmx -msse etc. They are implied if you use a correct -march option so you usually dont need them, with some exceptions. They should not be confused with the similar USE-flags for CPU features. The flag -mfpmath=sse however is not enabled by -march but it usually makes binaries slower due to limitations in the glibc headers. So its better to not use this flag, even if you have an SSE capable CPU. Also -mfpmath=sse,387 is experimental and unstable.The flag -fomit-frame-pointer is enabled at -O1, -O2, -O3 and -Os on arches where it doesnt interfere with debugging, such as AMD64, but not x86. So if youre on x86 you should add it to your CFLAGS. Also dont use -momit-leaf-frame-pointer together with -fomit-frame-pointer. Its pointless as -fomit-frame-pointer already omits all frame pointers. In fact if you use both, -momit-leaf-frame-pointer overrides -fomit-frame-pointer creating less optimized code.If you are, or plan on becoming a programmer/developer, then DO NOT use the -fomit-frame-pointer or -O3 flag as this can make debugging impossible, or at least a lot harder (especially on x86 machines).This is also important if you find a program with a bug in, which you wish to report. Before you submit a bug report, compile with just -O2 -march=i686 -pipe and without -fomit-frame-pointer (see /show_bug.cgi?id=68282 for an explanation.) Basically the frame-pointer is needed for stack traces. edit gcc-4.2.0 or newerIf you are using gcc-4.2.0 or newer it is easiest and probably best to just use:-march=native or-mtune=native.E.g.:32-bitCHOST=i686-pc-linux-gnuCFLAGS=-march=native -O2 -pipeCXXFLAGS=$CFLAGS64-bitCHOST=x86_64-pc-linux-gnuCFLAGS=-march=native -O2 -pipeCXXFLAGS=$CFLAGSedit i386Note: Gentoos minimum hardware requirement for x86 CPUs is the i486. This is due to glibc-2.4 dropping linuxthreads support and requiring NPTL which doesnt work on i386.If you would like to use a newer machine (eg. a Pentium III) to compile code that will still run on i386 machines use the following:CHOST=i386-pc-linux-gnuCFLAGS=-mtune=pentium3 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSorCHOST=i386-pc-linux-gnuCFLAGS=-march=i386 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSThe former will create code optimized for a PIII that will still run on a i386, while the latter will be optimized for the i386 alone. edit i486CHOST=i486-pc-linux-gnuCFLAGS=-march=i486 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Intel Processorsedit Pentiumvendor_id : GenuineIntelcpu family : 5model : 2model name : Pentium 75 - 200CHOST=i586-pc-linux-gnuCFLAGS=-march=pentium -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Pentium w/ MMXCHOST=i586-pc-linux-gnuCFLAGS=-march=pentium-mmx -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Cyrix MediaGX / AMD Geode GX1CFLAGS=-march=pentium-mmx -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Pentium ProCHOST=i686-pc-linux-gnuCFLAGS=-march=pentiumpro -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSorCHOST=i686-pc-linux-gnuCFLAGS=-march=i686 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGS(these are identical) edit Pentium IIvendor_id : GenuineIntelcpu family : 6model : 3, 5CHOST=i686-pc-linux-gnuCFLAGS=-march=pentium2 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSprocessor : 0vendor_id : GenuineIntelcpu family : 6model : 6model name : Mobile Pentium IIstepping : 10cpu MHz : 397.082cache size : 256 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 2wp : yesflags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsrbogomips : 794.75clflush size : 32edit Celeron (Mendocino), aka Celeron1vendor_id : GenuineIntelcpu family : 6model : 6stepping : 0CHOST=i686-pc-linux-gnuCFLAGS=-march=pentium2 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSprocessor : 0vendor_id : GenuineIntelcpu family : 6model : 6model name : Celeron (Mendocino)stepping : 0cpu MHz : 334.108cache size : 128 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 2wp : yesflags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr upbogomips : 686.94clflush size : 32edit Pentium IIIvendor_id : GenuineIntelcpu family : 6model : 7, 8CHOST=i686-pc-linux-gnuCFLAGS=-march=pentium3 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSprocessor : 0vendor_id : GenuineIntelcpu family : 6model : 8model name : Pentium III (Coppermine)stepping : 6cpu MHz : 863.934cache size : 256 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 2wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr ssebogomips : 1728.97clflush size : 32edit Celeron (Coppermine)vendor_id : GenuineIntelcpu family : 6model : 8stepping : 10CHOST=i686-pc-linux-gnuCFLAGS=-march=pentium3 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Celeron (Willamette)vendor_id : GenuineIntelcpu family : 15model : 1model name : Intel(R) Celeron(R) CPU 1.70GHzstepping : 3CHOST=i686-pc-linux-gnuCFLAGS=-march=pentium4 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Pentium M(Centrino)/Celeron Mvendor_id : GenuineIntelcpu family : 6model : 9 or 13model name : Intel(R) Pentium(R) M processor XXXXMHzFor gcc 3.3 or older (Warning: dev-java/sun-jdk needs old libstdc+-3.3.so on X86 Systems) :CHOST=i686-pc-linux-gnuCFLAGS=-march=pentium3 -msse2 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSFor gcc 3.4 and later:CHOST=i686-pc-linux-gnuCFLAGS=-march=pentium-m -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSThe Celeron M is based on the Pentium M but it has half the L2 cache and does not support the SpeedStep technology. edit Mobile Pentium 4-M (Northwood)vendor_id : GenuineIntelcpu family : 15model : 2model name : Mobile Intel(R) Pentium(R) 4 - M CPU X.XXGHzCHOST=i686-pc-linux-gnuCFLAGS=-march=pentium4 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Pentium 4vendor_id : GenuineIntelcpu family : 15model : 0 or 1 or 2model name : Intel(R) Pentium(R) 4 CPU XXXXMHzCHOST=i686-pc-linux-gnuCFLAGS=-march=pentium4 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Pentium 4 (Prescott) / Celeron Dvendor_id : GenuineIntelcpu family : 15model : 3 or 4model name : Intel(R) Pentium(R) 4 CPU XXXGHz -or- Intel(R) Celeron(R) CPU XXXGHz32-bit profile (x86)CHOST=i686-pc-linux-gnuCFLAGS=-march=prescott -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGS64-bit profile (amd64)CHOST=x86_64-pc-linux-gnuCFLAGS=-march=nocona -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSNote: You can verify the chip is a Prescott by looking for pni in the flags section of /proc/cpuinfo. This indicates support for SSE3.In 2004, Intel started branding processors with the Prescott core as Intel Celeron D. edit Pentium D 8xx / 9xxvendor_id : GenuineIntelcpu family : 15model : 4, 6model name : Intel(R) Pentium(R) D CPU x.xxGHz32-bit profile (x86)CHOST=i686-pc-linux-gnuCFLAGS=-march=prescott -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGS64-bit profile (amd64)CHOST=x86_64-pc-linux-gnuCFLAGS=-march=nocona -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Xeon w/o EM64Tvendor_id : GenuineIntelcpu family : 15model : 2model name : Intel(R) Xeon(R) CPU XXXXMHzCHOST=i686-pc-linux-gnuCFLAGS=-march=pentium4 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Xeon w/EM64T (also Pentium 4 P6xx)vendor_id : GenuineIntelcpu family : 15model : 4, 6model name : Intel(R) Xeon(R) CPU XXXXMHz32-bit profile (x86)CHOST=i686-pc-linux-gnuCFLAGS=-march=prescott -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGS64-bit profile (amd64)CHOST=x86_64-pc-linux-gnuCFLAGS=-march=nocona -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Intel Core Solo/Duo, Pentium Dual-Core Txxxxvendor_id : GenuineIntelcpu family : 6model : 14model name : Genuine Intel(R) CPU TXXXX XXXGHzCHOST=i686-pc-linux-gnuCFLAGS=-march=prescott -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSNotes:It has been confirmed by that prescott is the correct microarchitecture to use with this CPU. /p.gcc.devel/83870 The newer (eg. 420) Celeron-M processors are Core Solo based, not Pentium-M based. If your processors family and model are 6 and 14, then you should use the -march=prescott option. edit Intel Core 2 Duo/Quad / Xeon 51xx/53xx, Pentium Dual-Core Exxxxvendor_id : GenuineIntelcpu family : 6model : 15model name : Intel(R) Core(TM)2 CPU XXXX XXXGHz32 bit profile (x86)CHOST=i686-pc-linux-gnuCFLAGS=-march=prescott -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGS64 bit profile (amd64)CHOST=x86_64-pc-linux-gnuCFLAGS=-march=nocona -O2 -pipeCXXFLAGS=$CFLAGSNote:GCC 4.3 has -march=core21, but Gentoo has nothing above 4.2 in portage. edit VIA ProcessorsNote: EPIA is the name of all VIAs mini-ITX and nano-ITX motherboards with onboard VIA processor. Eden is low-power CPU variant, this name itself also does not tell anything about CPU core.edit Esther C5J (Via C7)vendor_id : CentaurHaulscpu family : 6model : 10model name : VIA Esther processor 2000MHzCHOST=i686-pc-linux-gnuCFLAGS=-march=i686 -mmmx -msse -msse2 -msse3 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSAs the C7 has the pni flag in /proc/cpuinfo, it supports SSE3. Search for pni on this page to get the explanation. edit C3 Nehemiah (C5X/C5XL/C5P) (VIA)vendor_id : CentaurHaulscpu family : 6model : 9model name : VIA NehemiahNote: Despite the C5 core name, these processors are marketed as C3s.GCC 3.3 and earlierCHOST=i686-pc-linux-gnuCFLAGS=-march=i686 -msse -mmmx -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSGCC 3.4 and laterCHOST=i686-pc-linux-gnuCFLAGS=-march=c3-2 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSNote: These cores do support the cmov instruction and hence are supported by i686 - and of course c3-2. If you must be compatible with all VIA C3 versions, do not use the settings in this section and instead use the flags in the C3 entry below.edit C3 Samuel/Ezra (Via EPIA)CHOST=i586-pc-linux-gnuCFLAGS=-march=c3 -m3dnow -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSWarning: Do not use any stages or packages containing i686 instructions (such as cmov) with the Samuel 2 and Ezra versions of the C3.The Ezra doesnt have any special instructions that you could optimize for, just consider it a K6-3 - basically a Pentium 2 with 3DNow.Note: The Mini-ITX EPIA-SP features a VIA C3 Eden processor, even if /proc/cpuinfo answers: model name: VIA Nehemiahedit Transmeta Processorsedit Transmeta Crusoevendor_id : GenuineTMx86cpu family : 6model : 4model name : Transmeta(tm) Crusoe(tm) Processor TM5800stepping : 3CHOST=i686-pc-linux-gnuCFLAGS=-march=i686 -Os -mmmx -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Transmeta Efficeonvendor_id : GenuineTMx86cpu family : 15model : 2model name : Transmeta Efficeon(tm) Processor TM8000stepping : 4CHOST=i686-pc-linux-gnuCFLAGS=-mtune=pentium3 -msse2 -O2 -pipe -falign-functions=0 -falign-jumps=0 -falign-loops=0CXXFLAGS=$CFLAGSNote: The Efficeon processor will reorder and realign instructions on translating from x86 to VLIW (Very Long Instruction Word), so not aligning functions/jumps/loops will produce smaller executable without any effect on speed. edit AMD Processorsedit K6 (AMD)CHOST=i586-pc-linux-gnuCFLAGS=-march=k6 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit K6-2 (AMD)vendor_id : AuthenticAMDcpu family : 5model : 8CHOST=i586-pc-linux-gnuCFLAGS=-march=k6-2 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGS# cat /proc/cpuinfoprocessor : 0vendor_id : AuthenticAMDcpu family : 5model : 8model name : AMD-K6(tm) 3D processorstepping : 12cpu MHz : 451.031cache size : 64 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 1wp : yesflags : fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr upbogomips : 902.84clflush size : 32Note: /proc/cpuinfo may be confusing. The model name may say AMD-K6(tm) 3D Processor but it is not a AMD K6-3. Rely on the vendor_id, CPU family, and model number.Note: If you get Illegal Instruction errors on compiles (especially long ones), you may be running into a cooling problem, or worse yet, a Sig11 (segmentation fault/bad ram) problem. Bug #24379 has a discussion about it. edit Geode LX (AMD)vendor_id : AuthenticAMDcpu family : 5model : 10CHOST=i586-pc-linux-gnuCFLAGS=-march=k6-2 -Os -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit K6-3 (AMD)CHOST=i586-pc-linux-gnuCFLAGS=-march=k6-3 -O2 -pipe -fomit-frame-pointerCXXFLAGS=$CFLAGSedit Duron (AMD)From 600 to 900 MHz (these models have a tbird-alike core model)product: AMD Duron(tm) Processor versio
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年江苏省常州市事业单位人员招聘笔试试题与答案详解
- 2026四川凉山州会东县农旅综合服务有限责任公司招聘派遣制人员4人笔试备考题库及答案解析
- 2026遵义市播州区茅栗镇人民政府招聘城镇公益性岗位人员2人考试备考题库及答案解析
- 2026年芜湖市镜湖区公务员人员招聘笔试试题与答案详解
- 2026年兰州市城关区公务员人员招聘考试模拟试题与答案详解
- 某钢厂原料采购办法
- 2027四川省人民医院公开招聘工作人员394人笔试备考题库及答案解析
- 2026年云南省昭通市公务员人员招聘考试试题与答案详解
- 2026年氯化铈(III) 七水合物行业洞察报告及未来五至十年发展趋势报告
- 2026年职业中介服务行业政策研究报告及未来五至十年专精特新与隐形冠军
- 商会采购管理办法
- 校友见面活动方案
- 医疗纠纷预防和处理条例培训课件
- 《幼儿园组织与管理》自考试题及答案解析
- 妈祖文化课件
- 中建医院项目一体化策划汇报
- 云南省公路工程试验检测费用指导价
- JB T 5301-2007滚动轴承碳钢球
- 手机信号屏蔽器的应用
- 刘老根大舞台开幕曲简谱乐谱
- 初中地理大气水分与降水课件
评论
0/150
提交评论