Difference between revisions of "CFish"

From Chessprogramming wiki
Jump to: navigation, search
 
(10 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
'''CFish''',<br/>
 
'''CFish''',<br/>
 
a [[Stockfish#ports|port]] of Stockfish written in plain [[C]] by [[Ronald de Man]], first published on [https://en.wikipedia.org/wiki/GitHub GitHub] in July 2016. Possibly inspired by the [[asmFish]] project to speed up Stockfish using a programming language closer to the machine, the purpose of CFish is to explore possible optimization issues of C versus [[Cpp|C++]] compilers <ref>[http://www.talkchess.com/forum/viewtopic.php?t=61280&start=9 Re: CFish] by [[Louis Zulli]], [[CCC]], September 01, 2016</ref>.  
 
a [[Stockfish#ports|port]] of Stockfish written in plain [[C]] by [[Ronald de Man]], first published on [https://en.wikipedia.org/wiki/GitHub GitHub] in July 2016. Possibly inspired by the [[asmFish]] project to speed up Stockfish using a programming language closer to the machine, the purpose of CFish is to explore possible optimization issues of C versus [[Cpp|C++]] compilers <ref>[http://www.talkchess.com/forum/viewtopic.php?t=61280&start=9 Re: CFish] by [[Louis Zulli]], [[CCC]], September 01, 2016</ref>.  
 +
 +
=AVX2 Attacks=
 +
Since May 2020, CFish contains experimental [[AVX2]]/[[AVX-512]] computational [[Sliding Piece Attacks|sliding piece attack]] code by Okuhara
 +
as memory saving alternative to [[Magic Bitboards|Magic bitboards]] <ref>[https://github.com/syzygy1/Cfish/blob/master/src/avx2-bitboard.h Cfish/avx2-bitboard.h at master · syzygy1/Cfish · GitHub]</ref>. It applies a kind of  [[Classical Approach#Branchless|branchless classical approach]].
 +
For instance, the four [[Classical Approach#Positive Rays|positive rays]] and [[Classical Approach#Negative Rays|negative rays]] of a [[Queen|queen]]
 +
are processed as vector of 4 [[Bitboards|bitboards]] in one 256-bit ymm register each. Positive and negative rays were intersected with the vector of broadcast [[Occupancy|occupancies]],
 +
to get the relevant blockers if any, [[General Setwise Operations#TheLeastSignificantOneBitLS1B|LS1B]] for positive, and [[General Setwise Operations#TheMostSignificantOneBitMS1B|MS1B]] for negative rays.
 +
While the positive rays were processed by [[BMI1#BLSMSK|BLSMSK]] aka <code>((x-1) ^ x)</code> to clear the ray squares above the LS1B blockers,
 +
the negative rays use a [[Parallel Prefix Algorithms#Fill Stuff|parallel prefix fill]] with three vector right shifts and ors, to clear all ray bits below the MS1B blockers.
 +
The eight ray attack sets were vertically and two times horizontally ored together for the final result.
 +
The conditional compiled AVX-512 version takes advantage of the [[AVX-512#VPLZCNT|_mm256_lzcnt_epi64]] <ref>[https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_lzcnt_epi64&expand=5560,5471,3497 _mm256_lzcnt_epi64]</ref> and [[AVX-512#VPTERNLOG|_mm256_ternarylogic_epi64]] <ref>[https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_ternarylogic_epi64&expand=5560,5471,3497,5873 _mm256_ternarylogic_epi64]</ref> intrinsics.
 +
Rook and bishop naturally suffer from less vector utilization, and combine some other well known techniques, i.e. the bishop attack getter processes only positive rays by swapping bytes.
 +
 +
=[[NNUE]]=
 +
Since August 2020, CFish also provides the [[NNUE]] evaluation ported from its C++ base [[Stockfish NNUE]] <ref>[https://github.com/syzygy1/Cfish/blob/master/src/nnue.c Cfish/nnue.c at master · syzygy1/Cfish · GitHub]</ref>,
 +
further utilizing [[SIMD and SWAR Techniques|SIMD instructions]].
  
 
=See also=  
 
=See also=  
 
* [[asmFish]]
 
* [[asmFish]]
 +
* [[Fat Titz]]
 
* [[Portfish]]
 
* [[Portfish]]
 +
* [[Rustfish]]
 +
* [[Stockfish NNUE]]
  
 
=Forum Posts=
 
=Forum Posts=
Line 23: Line 42:
 
* [http://www.talkchess.com/forum/viewtopic.php?t=66462 Cfish 9 is OUT!] by [[Louis Zulli]], [[CCC]], January 31, 2018
 
* [http://www.talkchess.com/forum/viewtopic.php?t=66462 Cfish 9 is OUT!] by [[Louis Zulli]], [[CCC]], January 31, 2018
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=70932 Cfish, shiny and new...] by [[Dann Corbit]], [[CCC]], June 05, 2019
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=70932 Cfish, shiny and new...] by [[Dann Corbit]], [[CCC]], June 05, 2019
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=71027 Some NUMA data for Stockfish-dev and Cfish-dev] by [[Louis Zulli]], [[CCC]], June 17, 2019 » [[NUMA]], [[Stockfish]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=71311 Bin book adapter?] by Ovyron, [[CCC]], July 18, 2019 » [[PolyGlot]]
 +
==2020 ...==
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=74369 Where to find CFish 11 Latest exe file] by Eric Hughes Santiago, [[CCC]], July 05, 2020
 +
: [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=74369&start=6 Re: Where to find CFish 11 Latest exe file] by [[Ronald de Man]], [[CCC]], July 05, 2020
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=74402 Cfish is back!] by [[Louis Zulli]], [[CCC]], July 07, 2020
 +
: [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=74402&start=10 Re: Cfish is back!] by [[Ronald de Man]], [[CCC]], July 07, 2020
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=75400 Hacking around CFish NNUE] by [[Maksim Korzh]], [[CCC]], October 15, 2020 » [[NNUE]]
  
 
=External Links=  
 
=External Links=  
 
* [https://github.com/syzygy1/Cfish GitHub - syzygy1/Cfish: C port of Stockfish]
 
* [https://github.com/syzygy1/Cfish GitHub - syzygy1/Cfish: C port of Stockfish]
* [https://en.wikipedia.org/wiki/Fish_Go_Deep Fish Go Deep] - The Jazz (2002), [https://en.wikipedia.org/wiki/YouTube YouTube] Video
+
* [https://github.com/okuhara/Cfish GitHub - okuhara/Cfish: C port of Stockfish]
 +
* [[:Category:Fish Go Deep|Fish Go Deep]] - The Jazz (2002), [https://en.wikipedia.org/wiki/YouTube YouTube] Video
 
: {{#evu:https://www.youtube.com/watch?v=biwGNuoaEyQ|alignment=left|valignment=top}}
 
: {{#evu:https://www.youtube.com/watch?v=biwGNuoaEyQ|alignment=left|valignment=top}}
  
Line 32: Line 60:
 
<references />
 
<references />
 
'''[[Stockfish|Up one Level]]'''
 
'''[[Stockfish|Up one Level]]'''
[[Category:Fish]]
 
 
[[Category:GPL]]
 
[[Category:GPL]]
 
[[Category:Open Source]]
 
[[Category:Open Source]]
 
[[Category:Joachim Beuckelaer]]
 
[[Category:Joachim Beuckelaer]]
 
[[Category:UCI]]
 
[[Category:UCI]]
[[Category:Music]]
+
[[Category:PC]]
 +
[[Category:X86]]
 +
[[Category:X64]]
 +
[[Category:Linux]]
 +
[[Category:Mac]]
 +
[[Category:Windows]]
 +
[[Category:NNUE]]
 +
[[Category:Fish]]
 +
[[Category:Fish Go Deep]]

Latest revision as of 13:58, 7 November 2021

Home * Engines * Stockfish * CFish

Joachim Beuckelaer - Fish Market [1]

CFish,
a port of Stockfish written in plain C by Ronald de Man, first published on GitHub in July 2016. Possibly inspired by the asmFish project to speed up Stockfish using a programming language closer to the machine, the purpose of CFish is to explore possible optimization issues of C versus C++ compilers [2].

AVX2 Attacks

Since May 2020, CFish contains experimental AVX2/AVX-512 computational sliding piece attack code by Okuhara as memory saving alternative to Magic bitboards [3]. It applies a kind of branchless classical approach. For instance, the four positive rays and negative rays of a queen are processed as vector of 4 bitboards in one 256-bit ymm register each. Positive and negative rays were intersected with the vector of broadcast occupancies, to get the relevant blockers if any, LS1B for positive, and MS1B for negative rays. While the positive rays were processed by BLSMSK aka ((x-1) ^ x) to clear the ray squares above the LS1B blockers, the negative rays use a parallel prefix fill with three vector right shifts and ors, to clear all ray bits below the MS1B blockers. The eight ray attack sets were vertically and two times horizontally ored together for the final result. The conditional compiled AVX-512 version takes advantage of the _mm256_lzcnt_epi64 [4] and _mm256_ternarylogic_epi64 [5] intrinsics. Rook and bishop naturally suffer from less vector utilization, and combine some other well known techniques, i.e. the bishop attack getter processes only positive rays by swapping bytes.

NNUE

Since August 2020, CFish also provides the NNUE evaluation ported from its C++ base Stockfish NNUE [6], further utilizing SIMD instructions.

See also

Forum Posts

2016

2017 ...

2020 ...

Re: Where to find CFish 11 Latest exe file by Ronald de Man, CCC, July 05, 2020
Re: Cfish is back! by Ronald de Man, CCC, July 07, 2020

External Links

References

Up one Level