Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Heads up that -march=native doesn't always detect CPUs.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
C1REX
l33t
l33t


Joined: 02 Jan 2004
Posts: 762
Location: Poland/UK

PostPosted: Fri Feb 14, 2020 12:49 am    Post subject: Heads up that -march=native doesn't always detect CPUs. Reply with quote

https://www.reddit.com/r/NixOS/comments/ekbxcy/ryzen_znver2_stdenv_support/?utm_medium=android_app&utm_source=share


Just for your information that selecting specific CPU might be a good idea instead of relying on auto detection.
_________________
CLICK HERE to help move gentoo up on distrowatch.

f you like Gentoo you can thank devs here - https://www.gentoo.org/donate/
Back to top
View user's profile Send private message
wrc1944
Advocate
Advocate


Joined: 15 Aug 2002
Posts: 3344
Location: Gainesville, Florida

PostPosted: Fri Feb 14, 2020 6:07 pm    Post subject: Reply with quote

Hmmm.. Don't know anything about NixOS, but I have on my Gentoo installs using -march=native and the kernel processor option "native" the following output, which seems that gcc cpu detection is OK:
Code:
wrc@gentoo-main ~ $ uname -p
AMD Ryzen 7 3700X 8-Core Processor

wrc@gentoo-main ~ $ uname -i
AuthenticAMD

wrc@gentoo-main ~ $ gcc -march=native -Q --help=target | grep march
  -march=                               znver2
  Known valid arguments for -march= option:
wrc@gentoo-main ~ $

_________________
Main box- AsRock x370 Gaming K4
Ryzen 7 3700x, 3.6GHz, 16GB GSkill Flare DDR4 3200mhz
Samsung SATA 1000GB, Radeon HD R7 350 2GB DDR5
Gentoo ~amd64 plasma, glibc-2.30-r3, gcc-9.2.0 kernel-5.5.5-gentoo USE=experimental
Back to top
View user's profile Send private message
C1REX
l33t
l33t


Joined: 02 Jan 2004
Posts: 762
Location: Poland/UK

PostPosted: Fri Feb 14, 2020 7:43 pm    Post subject: Reply with quote

It seems that the problem with CPU detection is rare and we shouldn't worry. Just maybe worth to check.
_________________
CLICK HERE to help move gentoo up on distrowatch.

f you like Gentoo you can thank devs here - https://www.gentoo.org/donate/
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 44706
Location: 56N 3W

PostPosted: Fri Feb 14, 2020 10:01 pm    Post subject: Reply with quote

C1REX,

Code:
gcc -### -E - -march=native 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )|( -mno-[^\ ]+)//g'

Try that. It may put your mind at rest.

distcc users should use the output of that in place of -march=native anyway.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
wrc1944
Advocate
Advocate


Joined: 15 Aug 2002
Posts: 3344
Location: Gainesville, Florida

PostPosted: Sat Feb 15, 2020 2:42 am    Post subject: Reply with quote

This is the output on my new 3700x system, which has bmi2 enabled by default:
Code:
wrc@gentoo-main ~ $ gcc -### -E - -march=native 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )|( -mno-[^\ ]+)//g'
-march=znver2 -mmmx -msse -msse2 -msse3 -mssse3 -msse4a -mcx16 -msahf -mmovbe -maes -msha -mpclmul -mpopcnt -mabm -mfma -mbmi -mbmi2 -mwbnoinvd -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mrdrnd -mf16c -mfsgsbase -mrdseed -mprfchw -madx -mfxsr -mxsave -mxsaveopt -mclflushopt -mxsavec -mxsaves -mclwb -mmwaitx -mclzero -mrdpid --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=znver2

Over on the other thread, https://forums.gentoo.org/viewtopic-t-1108258.html
Ant P. wrote:
Quote:
Quote:
-march=native may be counterproductive on some workloads; for Zen you probably want to add -mno-bmi2


I looked up the option on gcc docs and the BMI wiki page, but am still unclear if -mno-bmi2 is good for a general use desktop system, pro/con? https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets
The wiki page has lots of info, and I understood some of it, but I'm still in way over my head as to making an informed judgement. :roll:
Is there any more in depth info, or where to look for something on the subject written in a more general and easily understood format for a novice?
_________________
Main box- AsRock x370 Gaming K4
Ryzen 7 3700x, 3.6GHz, 16GB GSkill Flare DDR4 3200mhz
Samsung SATA 1000GB, Radeon HD R7 350 2GB DDR5
Gentoo ~amd64 plasma, glibc-2.30-r3, gcc-9.2.0 kernel-5.5.5-gentoo USE=experimental
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6217

PostPosted: Sat Feb 15, 2020 9:45 am    Post subject: Reply with quote

It's hard to find much of any info on this, but according to this the instruction speed is dependent on the input, and worst-case performance is abysmal (~300 cycles for something that should take 1!).

I've done a bit more reading and instead of -mno-bmi2, maybe using -fno-builtin-* to avoid only the bad parts could work.
There's corresponding functions in /usr/lib/gcc/$CHOST/$gcc_ver/include/bmi2intrin.h, so I think this should do it:
Code:
-fno-builtin-ia32_pdep_si -fno-builtin-ia32_pext_si -fno-builtin-ia32_pdep_di -fno-builtin-ia32_pext_di

I don't know how to verify if things compiled differently though...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming 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