Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
gcc tuning Lowest Common Denomintator flags script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 804

PostPosted: Sat Feb 08, 2020 7:36 pm    Post subject: gcc tuning Lowest Common Denomintator flags script Reply with quote

Has anyone written a script to generate a set of "lowest common denominator" for two (or maybe more) different but similar CPUs? (If not, I'll try, but I'd rather not reinvent the wheel.)

<oops>Sorry for the duplicate postings - I got (clearly false) messages saying "Submit" had failed, so I tried again</oops>

To elaborate, my use case is a new AMD Ryzen 9 3900X in my desktop machine, with enough power to compile qtwebengine and anything else, and an AMD A9 9420 in my laptop (approx 13.5 times slower on big stuff like that). In terms of code, the two processors are fairly similar, even though their performance is wildly different. I want to emerge everything just once on the new desktop, and create binary package host that the laptop can use to save compiling stuff thereupon.

Running
Code:
gcc -march=native -Q --help=target
tells me that the Ryzen is march=znver2, and the A9 is march=bdver4, along with a list of target-specific flag settings. Now a naive approach would be to specify:
Code:
CFLAGS="-march=bdver4 -mtune=znver2"
but there are a few flags that need to be disabled in from the bdver4 settings, which if I've compared the help=target listings correctly, gives me:
Code:
CFLAGS="-march=bdver4 -mtune=znver2 -mno-avx256-split-unaligned-store -mno-fma4 -mno-lwp -mno-tbm -mno-xop -mno-xsaves"


As this is a pretty tricky process, it should be relatively easy to automate. In fact, so easy, surely someone's done it already...

Another tweak is possible using differing CPU_FLAGS_X86 settings on the two boxes. Some, but not all, of the differing -m... tuning flags can appear in CPU_FLAGS_X86, and "emerge --usepkg" will spot the different settings and choose to compile a processor-specific version on the A9, but only for packages which specify the relevant USE flags. So this trick will sometimes, but not always, exploit extra optimizations on the A9.

Thinking about this some more, if I set up the LCM binary package host, and then use that to install the running system on the Ryzen, that would allow similar upgrades there. I'm pretty sure there must be a way to create a binary package host as if I were cross-compiling. I presume it's using the chroot and crossdev stuff in the Cross build environment wiki entry, though without many of the problems resulting from 100% dissimilar architectures. (Did I miss a simpler wiki item on cross-building - that one's complicated by totally different hardware architectures requiring qemu?)
_________________
Greybeard
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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