Cfish for Windows possible ?

Discussion of chess software programming and technical issues.

Moderator: Ras

dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Cfish for Windows possible ?

Post by dangi12012 »

Rebel wrote: Sun Dec 05, 2021 2:44 pm
dangi12012 wrote: Sun Dec 05, 2021 2:26 pm People here say CFish is faster than SF. so C++ is slower than C which is incorrect.
What other conclusion is there?

This is Stockfish 12 - avx2

Code: Select all

info depth 25 seldepth 31 multipv 1 score cp 24 nodes 8616999 nps 411548 hashfull 1000 tbhits 0 time 20938 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 d5c4 e2e3 a7a6 f1c4 b7b5 c4b3 c8b7 e1g1 f8e7 f1e1 c7c5 e3e4 c5d4 f3d4 e7c5 d4e6 f7e6
bestmove d2d4 ponder g8f6
And this is Cfish 12 - avx2

Code: Select all

info depth 25 seldepth 31 multipv 1 score cp 24 nodes 8616999 nps 587749 hashfull 1000 tbhits 0 time 14661 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 d5c4 e2e3 a7a6 f1c4 b7b5 c4b3 c8b7 e1g1 f8e7 f1e1 c7c5 e3e4 c5d4 f3d4 e7c5 d4e6 f7e6
bestmove d2d4 ponder g8f6
Same number of nodes.

SF12 NPS = 411.548
Cfish NPS = 587.749
You tell me! C and C++ compilers share the same backend.
I wrote before that they didnt do a 1:1 translation but changed al lot of code too for the translation. You can see it Cfish commit history.
Maybe you know another reason?
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
User avatar
Rebel
Posts: 7299
Joined: Thu Aug 18, 2011 12:04 pm
Full name: Ed Schröder

Re: Cfish for Windows possible ?

Post by Rebel »

dangi12012 wrote: Sun Dec 05, 2021 3:20 pm
Rebel wrote: Sun Dec 05, 2021 2:44 pm
dangi12012 wrote: Sun Dec 05, 2021 2:26 pm People here say CFish is faster than SF. so C++ is slower than C which is incorrect.
What other conclusion is there?

This is Stockfish 12 - avx2

Code: Select all

info depth 25 seldepth 31 multipv 1 score cp 24 nodes 8616999 nps 411548 hashfull 1000 tbhits 0 time 20938 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 d5c4 e2e3 a7a6 f1c4 b7b5 c4b3 c8b7 e1g1 f8e7 f1e1 c7c5 e3e4 c5d4 f3d4 e7c5 d4e6 f7e6
bestmove d2d4 ponder g8f6
And this is Cfish 12 - avx2

Code: Select all

info depth 25 seldepth 31 multipv 1 score cp 24 nodes 8616999 nps 587749 hashfull 1000 tbhits 0 time 14661 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 d5c4 e2e3 a7a6 f1c4 b7b5 c4b3 c8b7 e1g1 f8e7 f1e1 c7c5 e3e4 c5d4 f3d4 e7c5 d4e6 f7e6
bestmove d2d4 ponder g8f6
Same number of nodes.

SF12 NPS = 411.548
Cfish NPS = 587.749
You tell me! C and C++ compilers share the same backend.
I wrote before that they didnt do a 1:1 translation but changed al lot of code too for the translation. You can see it Cfish commit history.
Maybe you know another reason?
You say it yourself, the red.

Or in a nutshell, with C++ you leave many things to the compiler, with C you have much more control over the compiler.
90% of coding is debugging, the other 10% is writing bugs.
DrEinstein
Posts: 75
Joined: Wed Sep 15, 2021 8:50 pm
Full name: Albert Einstein

Re: Cfish for Windows possible ?

Post by DrEinstein »

RdM: 'C is not automatically faster than C++, I have to find speed ups to make it faster. Some of the speed ups have found their way back into Stockfish, such as my SEE implementation.'

https://github.com/syzygy1/Cfish/issues/119
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Cfish for Windows possible ?

Post by dangi12012 »

Rebel wrote: Sun Dec 05, 2021 3:28 pm Or in a nutshell, with C++ you leave many things to the compiler, with C you have much more control over the compiler.
No rebel its the other way around. With C++ you have templates, constexpr, consteval, a strong typesystem, STL, and a lot of keywords that dont exist in C to make simple code faster like [[likely]] and [[unlikely]]. You can directly talk to the compiler with C++. With C you are limited to mere hints like inline.

Thats why its really suprising to me that C is faster in Cfish.

The real answer is they optimized the C code a lot and some of these optimisations went back to upstream C++ Stockfish.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
User avatar
Rebel
Posts: 7299
Joined: Thu Aug 18, 2011 12:04 pm
Full name: Ed Schröder

Re: Cfish for Windows possible ?

Post by Rebel »

dangi12012 wrote: Sun Dec 05, 2021 3:36 pm
Rebel wrote: Sun Dec 05, 2021 3:28 pm Or in a nutshell, with C++ you leave many things to the compiler, with C you have much more control over the compiler.
No rebel its the other way around. With C++ you have templates, constexpr, consteval, a strong typesystem, STL, and a lot of keywords that dont exist in C to make simple code faster like [[likely]] and [[unlikely]]. You can directly talk to the compiler with C++. With C you are limited to mere hints like inline.

Thats why its really suprising to me that C is faster in Cfish.

The real answer is they optimized the C code a lot and some of these optimisations went back to upstream C++ Stockfish.
The author of Cfish simply out-smarted the compiler, that should not be something new for you.
90% of coding is debugging, the other 10% is writing bugs.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Cfish for Windows possible ?

Post by dangi12012 »

Rebel wrote: Sun Dec 05, 2021 3:42 pm
dangi12012 wrote: Sun Dec 05, 2021 3:36 pm
Rebel wrote: Sun Dec 05, 2021 3:28 pm Or in a nutshell, with C++ you leave many things to the compiler, with C you have much more control over the compiler.
No rebel its the other way around. With C++ you have templates, constexpr, consteval, a strong typesystem, STL, and a lot of keywords that dont exist in C to make simple code faster like [[likely]] and [[unlikely]]. You can directly talk to the compiler with C++. With C you are limited to mere hints like inline.

Thats why its really suprising to me that C is faster in Cfish.

The real answer is they optimized the C code a lot and some of these optimisations went back to upstream C++ Stockfish.
The author of Cfish simply out-smarted the compiler, that should not be something new for you.
It is not. Its more that other people trolled me with comments and that got under my skin.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer