Hi,
I got a new PC (AMD 5950X), and I have some question about compilation.
By defaut, I only use : -march=native. It works great, for example : perft(8) in 180 s, ie 473 Mnodes/s.
My problem is to make an executable for older machines. I tried to replace "-march=native" with several
other options, but I couldn't find any to even got the native performance.
This is what I use : -msse -msse2 -msse3 -mpopcnt -msse4.1 -mssse3 -mmmx -DUSE_PEXT -mbmi2 -mavx2
I works with QTcreator (Windows), the compiler is mingw 11.2.0 64 bits
Thanks for informations.
Philippe
Compiler options
Moderator: Ras
-
- Posts: 161
- Joined: Thu Jan 20, 2022 9:42 am
- Location: France
- Full name: Philippe Chevalier
-
- Posts: 26
- Joined: Wed Feb 16, 2022 6:21 am
- Full name: P. M. Zamboni
Re: Compiler options
I don’t think what you want is possible. When you compile with ’-march=native’, you are letting the compiler assume the code is going to run on your computer specifically, so it is able to use instructions that are available only on your CPU. When you compile without ‘-march=native’, you are asking the compiler to compile code that runs on any x86‐64 CPU (in your case). In each case, the generated machine code will look different, and it’s not possible to create code that uses native optimisations that is capable of running on CPUs without support for the same instructions.
-
- Posts: 4397
- Joined: Fri Mar 10, 2006 5:23 am
- Location: http://www.arasanchess.org
Re: Compiler options
Generally you'll get worse performance if you cannot assume all supported instructions on your machine are present.
"Older" can also mean a lot of things. Arasan's Makefile provides support for the following program variants:
arasanx-64-old - assumes no SIMD instructions, not even SSE2. Will run on very old x86 hardware.
arasanx-64-modern - requires a x86 processor with POPCNT, SSSE3 and SSE4.1 instructions (Intel Nehalem or later, i.e. 2008 era or more recent).
arasanx-64-avx2 - requires a more modern x86 processor with AVX2 instructions, as well as those required by the "modern" build. Recommended for AMD Excavator through Zen2 processors.
arasanx-64-avx2-bmi2 - requires a more modern x86 processor with AVX2 and BMI2 instructions, as well as those required by the "modern" build. Recommended for Intel Haswell or later processors and AMD processors on the Zen3 architecture (Nov. 2020) or later.
arasanx-64-avx512 - requires a modern x86 processor with AVX512 instructions (Intel Skylake X and Cannon Lake, or later), as well as those required by the "avx2" build.
arasanx-64-neon - ARM executable with support for NEON instruction set.
"Older" can also mean a lot of things. Arasan's Makefile provides support for the following program variants:
arasanx-64-old - assumes no SIMD instructions, not even SSE2. Will run on very old x86 hardware.
arasanx-64-modern - requires a x86 processor with POPCNT, SSSE3 and SSE4.1 instructions (Intel Nehalem or later, i.e. 2008 era or more recent).
arasanx-64-avx2 - requires a more modern x86 processor with AVX2 instructions, as well as those required by the "modern" build. Recommended for AMD Excavator through Zen2 processors.
arasanx-64-avx2-bmi2 - requires a more modern x86 processor with AVX2 and BMI2 instructions, as well as those required by the "modern" build. Recommended for Intel Haswell or later processors and AMD processors on the Zen3 architecture (Nov. 2020) or later.
arasanx-64-avx512 - requires a modern x86 processor with AVX512 instructions (Intel Skylake X and Cannon Lake, or later), as well as those required by the "avx2" build.
arasanx-64-neon - ARM executable with support for NEON instruction set.
-
- Posts: 161
- Joined: Thu Jan 20, 2022 9:42 am
- Location: France
- Full name: Philippe Chevalier
Re: Compiler options
Hi,
Thanks for explanations.
I will look for Arasan, and will adapt the pro file in QtCreator in order to generate several binaries.
With my new hardware, I gain something of 10-15 elo. But the most interesting thing
is that I can now run 16 (or 15 ?) games at the same time.
Thanks for explanations.
I will look for Arasan, and will adapt the pro file in QtCreator in order to generate several binaries.
With my new hardware, I gain something of 10-15 elo. But the most interesting thing
is that I can now run 16 (or 15 ?) games at the same time.
-
- Posts: 1953
- Joined: Tue Apr 19, 2016 6:08 am
- Location: U.S.A
- Full name: Andrew Grant
Re: Compiler options
I did not read any other responses here; my quick response:
You are missing -mavx, which might be useful.
You are also missing -mbmi which contains ANDN, and very useful operation that compilers like.
You are also missing -msse4. And possibly -msse4.2.
It _might_ be the case that -mavx2 implies -mavx, and bmi2 -> bmi, and so forth. But I don't know that to be true.
You can use -mtune=znver2 to optimize for a platform like zen2, without explicitly ensuring you use their instructions.
I would not expect a compile with these flags to be that much slower compared to march/mtune=native.
There are diagnostics inside gcc that let you output all instruction sets enabled, or all of the individual -m.... flags.