On 4/6/22 04:08, Joel Stanley wrote:
On Thu, 31 Mar 2022 at 23:46, Segher Boessenkool
<seg...@kernel.crashing.org> wrote:

On Thu, Mar 31, 2022 at 12:19:52PM -0300, Murilo Opsfelder Araújo wrote:
My understanding is that the default cpu type for -mcpu=powerpc64 can
change.

Different subtargets (Linux, AIX, Darwin, the various BSDs, bare ELF,
etc.) have different default CPUs.  It also can be set at configure time
for most subtargets.

Linux can be built with compilers not targetting *-linux*, so it would
be best to specify a specific CPU always.

I did a little test using my buildroot compiler which has
with-cpu=power10. I used the presence of PCREL relocations as evidence
that it was build for power10.

$ powerpc64le-buildroot-linux-gnu-gcc -mcpu=power10 -c test.c
$ readelf -r test.o |grep -c PCREL
24

It respected the -mcpu=power10 you provided.

Of course.

And that's my concern.  We're relying on the compiler default cpu type.

That is not the compiler default.  It is the default from who built the
compiler.  It can vary wildly and unpredictably.

The actual compiler default will not change so easily at all, basically
only when its subtarget drops support for an older CPU.

If gcc defaults -mcpu=powerpc64le to power10, you're going to have
the same problem again.

That will not happen before power10 is the minimum supported CPU.
Anything else is madness.

Murilo, does Segher's explanation address your concerns?

The comment:

"Different subtargets (Linux, AIX, Darwin, the various BSDs, bare ELF,
etc.) have different default CPUs.  It also can be set at configure time
for most subtargets.

Linux can be built with compilers not targetting *-linux*, so it would
be best to specify a specific CPU always."

made me think that it's better to specify -mcpu=power8 instead of 
-mcpu=powerpc64le
because of such compilers not targetting *-linux*.

Did I understand Segher's comment correctly?  To be honest, I don't know
how much concerned we should be about this scenario.

Just for the sake of consistency, if we decide to go with -mcpu=powerpc64le,
then I think we should also change arch/powerpc/Makefile CFLAGS.
Otherwise, we could follow what we already have in the tree and use
-mcpu=power8 in BOOTCLAGS, too.

Practically speaking, either way works for us.  In any case:

Reviewed-by: Murilo Opsfelder Araujo <muri...@linux.ibm.com>


I believe the patch I sent fixes the problem that you're worried
about. It should be compatible into the future too.

Cheers,

Joel


It happens that the power8 default cpu type
is compatible to your system by coincidence.

No, power8 is (and always was) the minimum supported CPU type for
powerpc64le-linux.

In gcc/config/rs6000/rs6000-cpus.def, they are set to different processors:

     254 RS6000_CPU ("powerpc64", PROCESSOR_POWERPC64, MASK_PPC_GFXOPT |
     MASK_POWERPC64)
     255 RS6000_CPU ("powerpc64le", PROCESSOR_POWER8, MASK_POWERPC64 |
     ISA_2_7_MASKS_SERVER

Those can and will change though, over time.  But -mcpu=powerpc64 (etc.)
always will mean what the current documentation says it does:
      '-mcpu=powerpc', '-mcpu=powerpc64', and '-mcpu=powerpc64le' specify
      pure 32-bit PowerPC (either endian), 64-bit big endian PowerPC and
      64-bit little endian PowerPC architecture machine types, with an
      appropriate, generic processor model assumed for scheduling
      purposes.

My suggestion was to explicitly set -mcpu=power8 instead of
-mcpu=powerpc64le.

That is implied anyway, it is the minimum supported for
powerpc64le-linux.  Using -mcpu=powerpc64le might schedule better for
newer CPUs, in the future (but the code will always work on all still
supported CPUs).


Segher

--
Murilo

Reply via email to