Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Compiler Optimization and CPU_FLAGS_X86
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
BHReach
n00b
n00b


Joined: 24 Jan 2012
Posts: 30

PostPosted: Sun Dec 13, 2015 1:23 am    Post subject: Compiler Optimization and CPU_FLAGS_X86 Reply with quote

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

Code:
/proc/cpuinfo

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)
Code:
MAKEOPTS="-j9"

works better than smaller numbers. For example chromium compiles 20% to 25% faster with j9 than with j5 or j3.
Back to top
View user's profile Send private message
Keruskerfuerst
Advocate
Advocate


Joined: 01 Feb 2006
Posts: 2097

PostPosted: Sun Dec 13, 2015 9:56 am    Post subject: Reply with quote

CFLAGS="-O2 -march=native"

I would set makeopts="-j2"
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 5421

PostPosted: Sun Dec 13, 2015 11:01 am    Post subject: Reply with quote

https://www.gentoo.org/support/news-items/2015-01-28-cpu_flags_x86-introduction.html
Back to top
View user's profile Send private message
Ant P.
Advocate
Advocate


Joined: 18 Apr 2009
Posts: 3552
Location: UK

PostPosted: Sun Dec 13, 2015 5:43 pm    Post subject: Reply with quote

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.
_________________
overlay | runit-scripts
Back to top
View user's profile Send private message
BHReach
n00b
n00b


Joined: 24 Jan 2012
Posts: 30

PostPosted: Sun Dec 13, 2015 5:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
BHReach
n00b
n00b


Joined: 24 Jan 2012
Posts: 30

PostPosted: Sun Dec 13, 2015 6:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum