View previous topic :: View next topic |
Author |
Message |
BHReach n00b
Joined: 24 Jan 2012 Posts: 40
|
Posted: Sun Dec 13, 2015 1:23 am Post subject: Compiler Optimization and CPU_FLAGS_X86 |
|
|
This is my experience with an A4-3400 AMD CPU (Dual Core).
I did not know what to use for CPU_FLAGS_X86. I found this website (http://blog.stuart.shelton.me/archives/2590) which has a script that gets all the CPU features from
I used it and wow was that a mistake. I was installing a new system and had numerous cryptic compiling errors (even some illegal instruction errors). I did more research and found these web pages:
http://gentoo-en.vfose.ru/wiki/Safe_Cflags/AMD
http://gentoo-en.vfose.ru/wiki/Safe_Cflags/Intel
They have safe optimization settings for various CPUs. The pages look like they come from the Gentoo wiki but they seem to have more detailed information than the current wiki pages do.
Code: | CFLAGS="-O2 -march=amdfam10 -mcx16 -mpopcnt -pipe"
CPU_FLAGS_X86="3dnow 3dnowext mmx mmxext sse sse2 sse3 sse4a" |
Those settings work well and everything compiled without issues.
I also discovered empirically that (4 X Number of Cores + 1)
works better than smaller numbers. For example chromium compiles 20% to 25% faster with j9 than with j5 or j3. |
|
Back to top |
|
|
Keruskerfuerst Advocate
Joined: 01 Feb 2006 Posts: 2289 Location: near Augsburg, Germany
|
Posted: Sun Dec 13, 2015 9:56 am Post subject: |
|
|
CFLAGS="-O2 -march=native"
I would set makeopts="-j2" |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Sun Dec 13, 2015 5:43 pm Post subject: |
|
|
AMD chips post-PhenomII have no 3DNow instruction sets, so expect all kinds of subtle system failures in future if you keep using those CFLAGS. |
|
Back to top |
|
|
BHReach n00b
Joined: 24 Jan 2012 Posts: 40
|
Posted: Sun Dec 13, 2015 5:54 pm Post subject: |
|
|
Keruskerfuerst wrote: | CFLAGS="-O2 -march=native"
I would set makeopts="-j2" |
I tried native, putting in the exact CPU with safe features works better. Using more generic settings seems to cause some packages not to compile resulting in lost time debugging problems. With my current settings, all packages (998) compile without any problems.
Why -j2?
The original Gentoo handbook said to set it to the number of cores plus 1.
Modern CPU cores can execute more than 1 instruction simultaneously so I tried larger j values finding that 4 X cores plus 1 seems to work best (true for other CPUs as well). I did not do an exhaustive study trying all reasonable j values and I don't use the computer when it is compiling. |
|
Back to top |
|
|
BHReach n00b
Joined: 24 Jan 2012 Posts: 40
|
Posted: Sun Dec 13, 2015 6:03 pm Post subject: |
|
|
Ant P. wrote: | AMD chips post-PhenomII have no 3DNow instruction sets, so expect all kinds of subtle system failures in future if you keep using those CFLAGS. |
What is the source of your info? The CPU reports that it has those features.
Code: | cat /proc/cpuinfo |grep flags |
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt arat hw_pstate npt lbrv svm_lock nrip_save pausefilter vmmcal |
|
Back to top |
|
|
|