GCC 8.1 vs GCC 10.1

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Dann Corbit
Posts: 11216
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: GCC 8.1 vs GCC 10.1

Post by Dann Corbit » Thu Jul 02, 2020 6:16 am

It is really important if you have a new AMD not to use defaults. The AMD CPU emulates some bit operations in software and the emulation code is not good, so you need to lie to the compiler and tell it you have a modern x86 CPU with SSE.
For evidence of this look at ipman's tests of AsmFish with BMI and with SSE on the Ryzen chips. You lose a horrid chunk of speed with a BMI compile.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

Gabor Szots
Posts: 504
Joined: Sat Jul 21, 2018 5:43 am
Location: Szentendre, Hungary
Full name: Gabor Szots

Re: GCC 8.1 vs GCC 10.1

Post by Gabor Szots » Thu Jul 02, 2020 10:41 am

Things are worse than I thought. I tried to compile the new Raven 1.00. With GCC 8.1 everything's OK. With GCC 10.1.0-3 I get a 200 kB error file, the start of which is this:
e:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\cicus\AppData\Local\Temp\cc4pmSs5.o (symbol from plugin):(.text+0x0): multiple definition of `posstack'; C:\Users\cicus\AppData\Local\Temp\ccDAWlqJ.o (symbol from plugin):(.text+0x0): first defined here
e:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\cicus\AppData\Local\Temp\cc4pmSs5.o (symbol from plugin):(.text+0x0): multiple definition of `posstackend'; C:\Users\cicus\AppData\Local\Temp\ccDAWlqJ.o (symbol from plugin):(.text+0x0): first defined here
e:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\cicus\AppData\Local\Temp\cc4pmSs5.o (symbol from plugin):(.text+0x0): multiple definition of `movestackend'; C:\Users\cicus\AppData\Local\Temp\ccDAWlqJ.o (symbol from plugin):(.text+0x0): first defined here
e:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\cicus\AppData\Local\Temp\cc4pmSs5.o (symbol from plugin):(.text+0x0): multiple definition of `totalendtime'; C:\Users\cicus\AppData\Local\Temp\ccDAWlqJ.o (symbol from plugin):(.text+0x0): first defined here
Etc.

Can it be the paths? My GCC 8.1 path is e:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\, while my GCC 10.1 path is e:\msys64\mingw64\bin\.

Or maybe GCC 10.1 is not properly installed.
Gabor Szots
CCRL testing group

Ras
Posts: 1401
Joined: Tue Aug 30, 2016 6:19 pm
Full name: Rasmus Althoff
Contact:

Re: GCC 8.1 vs GCC 10.1

Post by Ras » Thu Jul 02, 2020 11:03 am

Gabor Szots wrote:
Thu Jul 02, 2020 10:41 am
Things are worse than I thought. I tried to compile the new Raven 1.00. With GCC 8.1 everything's OK. With GCC 10.1.0-3 I get a 200 kB error file, the start of which is this:
That's new with GCC 10 and actually caused by sloppy code. External variables should be declared as "external". Try compiling/linking with the "-fcommon" flag.

See also https://gcc.gnu.org/gcc-10/porting_to.html , first section.
Rasmus Althoff
https://www.ct800.net

Gabor Szots
Posts: 504
Joined: Sat Jul 21, 2018 5:43 am
Location: Szentendre, Hungary
Full name: Gabor Szots

Re: GCC 8.1 vs GCC 10.1

Post by Gabor Szots » Thu Jul 02, 2020 11:34 am

Ras wrote:
Thu Jul 02, 2020 11:03 am
Gabor Szots wrote:
Thu Jul 02, 2020 10:41 am
Things are worse than I thought. I tried to compile the new Raven 1.00. With GCC 8.1 everything's OK. With GCC 10.1.0-3 I get a 200 kB error file, the start of which is this:
That's new with GCC 10 and actually caused by sloppy code. External variables should be declared as "external". Try compiling/linking with the "-fcommon" flag.

See also https://gcc.gnu.org/gcc-10/porting_to.html , first section.
The -fcommon flag worked. Thanks Rasmus. :D
Gabor Szots
CCRL testing group

User avatar
lucasart
Posts: 3109
Joined: Mon May 31, 2010 11:29 am
Full name: lucasart
Contact:

Re: GCC 8.1 vs GCC 10.1

Post by lucasart » Thu Jul 02, 2020 12:20 pm

Ras wrote:
Thu Jul 02, 2020 11:03 am
Gabor Szots wrote:
Thu Jul 02, 2020 10:41 am
Things are worse than I thought. I tried to compile the new Raven 1.00. With GCC 8.1 everything's OK. With GCC 10.1.0-3 I get a 200 kB error file, the start of which is this:
That's new with GCC 10 and actually caused by sloppy code. External variables should be declared as "external". Try compiling/linking with the "-fcommon" flag.

See also https://gcc.gnu.org/gcc-10/porting_to.html , first section.
I'm shocked that GCC accepted such broken code before :shock:

Edit: just fixed my code :lol:
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.

AndrewGrant
Posts: 588
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

Re: GCC 8.1 vs GCC 10.1

Post by AndrewGrant » Thu Jul 02, 2020 1:47 pm

lucasart wrote:
Thu Jul 02, 2020 3:38 am
my experience is that gcc compiles are worse and more bloated than they were with older versions. Somewhere iaround GCC 4.6 we reached the golden age of gcc, we went downhill ever since, whereas LLVM is stronger than ever.
I too have had the same experience, although my "best" form is GCC4.8. For a long time I made sure to always use the older version, but I can say recently that GCC8/9 are able to compete once again. Although still a very worrying trend.

Gabor Szots
Posts: 504
Joined: Sat Jul 21, 2018 5:43 am
Location: Szentendre, Hungary
Full name: Gabor Szots

Re: GCC 8.1 vs GCC 10.1

Post by Gabor Szots » Fri Jul 03, 2020 6:38 am

Thank you all for the replies.
Gabor Szots
CCRL testing group

syzygy
Posts: 4598
Joined: Tue Feb 28, 2012 10:56 pm

Re: GCC 8.1 vs GCC 10.1

Post by syzygy » Fri Jul 03, 2020 3:28 pm

lucasart wrote:
Thu Jul 02, 2020 3:38 am
mar wrote:
Wed Jul 01, 2020 8:04 pm
Right, those idiots try hard to make each new version of gcc slower than the one before. Fortunately we have expert-testers who expose them. Good job Gabor!
I switched to clang long ago and never looked back.

Though I did understand your irony on -s (which some people seem to confuse with -Os), my experience is that gcc compiles are worse and more bloated than they were with older versions. Somewhere iaround GCC 4.6 we reached the golden age of gcc, we went downhill ever since, whereas LLVM is stronger than ever.
For me, gcc-4.72/4.73 remained unbeatable for quite a while (until it stopped working due to changes in libraries or so).

But I cannot remember having ever seen clang beat gcc on speed of the executable. I tried once more very recently, and they were not even close.

User avatar
lucasart
Posts: 3109
Joined: Mon May 31, 2010 11:29 am
Full name: lucasart
Contact:

Re: GCC 8.1 vs GCC 10.1

Post by lucasart » Sat Jul 04, 2020 12:38 am

syzygy wrote:
Fri Jul 03, 2020 3:28 pm
lucasart wrote:
Thu Jul 02, 2020 3:38 am
mar wrote:
Wed Jul 01, 2020 8:04 pm
Right, those idiots try hard to make each new version of gcc slower than the one before. Fortunately we have expert-testers who expose them. Good job Gabor!
I switched to clang long ago and never looked back.

Though I did understand your irony on -s (which some people seem to confuse with -Os), my experience is that gcc compiles are worse and more bloated than they were with older versions. Somewhere iaround GCC 4.6 we reached the golden age of gcc, we went downhill ever since, whereas LLVM is stronger than ever.
For me, gcc-4.72/4.73 remained unbeatable for quite a while (until it stopped working due to changes in libraries or so).

But I cannot remember having ever seen clang beat gcc on speed of the executable. I tried once more very recently, and they were not even close.
It depends on the codebase. Indeed GCC compiles are faster than Clang for Ethereal, for example. But slower for Demolito. Here is a comparison for Demolito:

Compilation (same for both GCC and Clang):

Code: Select all

$ make CC=clang EXE=demo_clang
clang -march=native -std=gnu11 -DNDEBUG -O3 -flto -Wfatal-errors -Wall -Wextra -Wshadow -Wstrict-prototypes -Wsign-conversion -DVERSION=\"dev\" ./*.c -o demo_clang -s -lm -lpthread
$ make CC=gcc EXE=demo_gcc
gcc -march=native -std=gnu11 -DNDEBUG -O3 -flto -Wfatal-errors -Wall -Wextra -Wshadow -Wstrict-prototypes -Wsign-conversion -DVERSION=\"dev\" ./*.c -o demo_gcc -s -lm -lpthread
Speed benchmark, 3 runs each:

Code: Select all

$ ./demo_gcc bench|tail -4 && ./demo_gcc bench|tail -4 && ./demo_gcc bench|tail -4
seal  : e3ef8bcccf483111
time  : 5332ms
nodes : 12314404
nps   : 2309528
seal  : e3ef8bcccf483111
time  : 5282ms
nodes : 12314404
nps   : 2331390
seal  : e3ef8bcccf483111
time  : 5279ms
nodes : 12314404
nps   : 2332715
$ ./demo_clang bench|tail -4 && ./demo_clang bench|tail -4 && ./demo_clang bench|tail -4
seal  : e3ef8bcccf483111
time  : 5038ms
nodes : 12314404
nps   : 2444304
seal  : e3ef8bcccf483111
time  : 5051ms
nodes : 12314404
nps   : 2438013
seal  : e3ef8bcccf483111
time  : 5045ms
nodes : 12314404
nps   : 2440913
So Clang compile is 4.7% faster, on the median of 3 runs.

Fabien Letouzey reported the same thing with Senpai, where he recommends compiling with Clang, because GCC compiles were slower (I don't know if that's still true with recent versions). Note that Senpai is C++, not C.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.

Ras
Posts: 1401
Joined: Tue Aug 30, 2016 6:19 pm
Full name: Rasmus Althoff
Contact:

Re: GCC 8.1 vs GCC 10.1

Post by Ras » Sat Jul 04, 2020 7:04 am

lucasart wrote:
Sat Jul 04, 2020 12:38 am
Compilation (same for both GCC and Clang):
-O3 isn't always the fastest. What if you try -O2 instead?
Rasmus Althoff
https://www.ct800.net

Post Reply