how to get -march=native's value?

Segher Boessenkool segher@kernel.crashing.org
Fri Sep 17 17:53:25 GMT 2021


On Fri, Sep 17, 2021 at 11:26:16AM +0100, Jonathan Wakely via Gcc-help wrote:
> The question is whether -march=native always corresponds to one of the
> other -march=xxx options or not.

[ snip ]

> So the question is whether that is any different to what is enabled by
> just -march=skylake alone.The answer is yes, it's different. On my
> machine -march=native adds -mabm and -mrtm which are not enabled by
> -march=skylake, and it also uses different L1 and L2 cache sizes.

The cache sizes are -mtune=native, not -march=native.

> Is that a bug in the -march=skylake settings? Maybe, I don't know. But
> it shows that -march=native is not the same as just the named -march
> option for my machines.

For x86 -march=something is the same as -march=native, _if_ the compiler
knows about your CPU.  It will guess something reasonable otherwise.

This is all completely arch-specific (and OS-specific).  There are no
guarantees that you will get the same as any named CPU.  Your arch could
check for each feature if it can use it, as one extreme,

In the case of -mabm and -mrtm, it looks like the documentation could
use an update, perhaps.  The way this is structured the code and doc can
diverge easily.


Segher


More information about the Gcc-help mailing list