On Tue, Sep 5, 2017 at 10:43 PM, Grant <[email protected]> wrote:
>>>>>> Now I'm running into "trap invalid opcode" errors on the older
>>>>>> systems.  Can I disable some of the newer CPU instruction sets on the
>>>>>> master laptop when compiling to hopefully generate binaries that will
>>>>>> work on the older systems?
>>>>>
>>>>>   Yes.  You need to find out CPU_FLAGS_X86 and "-march=" values the
>>>>> machines have, and use that in make.conf.  Run the commands...
>>>>>
>>>>> cpuinfo2cpuflags-x86
>>>>> gcc -c -Q -march=native --help=target | grep march=
>>>>>
>>>>> ...on the target machines.  This will tell you what "native" is and
>>>>> what CPU_FLAGS_X86 values to use.
>>>>>
>>>>> https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/x86-Options.html#x86-Options
>>>>> lists available "march=" options, and what instruction sets they support.
>>>>> E.g. my old core2 desktop shows...
>>>>>
>>>>> [d531][waltdnes][~] cpuinfo2cpuflags-x86
>>>>> CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 ssse3"
>>>>>
>>>>> [d531][waltdnes][~] gcc -c -Q -march=native --help=target | grep march=
>>>>>   -march=                               core2
>>>>>
>>>>>
>>>>>   Unless the laptops are really old, you can probably get away with...
>>>>> CFLAGS="-O2 march=core2 -mfpmath=sse -fopenmp -fomit-frame-pointer -pipe 
>>>>> -fno-unwind-tables -fno-asynchronous-unwind-tables"
>>>>>
>>>>> booby trap 1) Unless all machines are Intel "Atom" family, do *NOT* use
>>>>> a "march=" that implements the "movbe" instruction.
>>>>>
>>>>> booby trap 2) If you throw in any AMD-based machines proceed with care.
>>>>>
>>>>>   Can you post the output of...
>>>>> gcc -c -Q -march=native --help=target | grep march=
>>>>> ...for all the target machines?
>>>>
>>>>
>>>> Let's see how -mtune=native goes and resort to the above if necessary.
>>>> It doesn't look too bad though.
>>>
>>>
>>> emerge -e world has finished and pushed and -mtune=native seems to
>>> have solved the issue for now.
>>>
>>
>> You might be interested in "-march=x86-64 -mtune=generic" though this
>> will mean you might miss out on some optimizations.
>
>
> If I could miss out on optimizations, what is the advantage compared
> to -mtune=native?  Better compatibility across CPUs?
>

Well, having looked it up (again), -march will break backwards
compatibility while -mtune=native will not if you stay within a family
of processors. So, yes.

One of the finer points of -mtune is that is specifies processor cache
sizes. If this is set to an incorrect value you could get very poor
performance relative to leaving it unset (with -mtune=generic).

For the exact differences, try:

gcc -march=native -mtune=native -E -v - </dev/null 2>&1 | grep cc1
echo | gcc -dM -E - -march=native

Which will show you the expanded compilation flags and macro
definitions, respectively.

Reply via email to