zzzzz151 / Starzix

Do What The F*ck You Want To Public License
21 stars 3 forks source link

compiling on Linux fails #3

Closed tissatussa closed 11 months ago

tissatussa commented 1 year ago

your code seems decent but aimed at Windows, am i right? I managed to correct some basic errors, which terminal shows at compilation :

in time_management.hpp and move_scoring.hpp _error: use of undeclared identifier 'INTMAX' i had to #include <limits.h> in these files.

but one error i can NOT solve at the moment .. i have little experience with C++ and C code, but often i'm able to deduce errors (on Linux) and fix them -- not this time .. it's when reading the NN file in nnue.hpp : the function loadNetFromFile() contains this line :

errno_t error = fopen_s(&netFile, NET_FILE, "rb");

first i see error: unknown type name 'errno_t'; did you mean 'error_t'? on StackOverflow i read this is due to some specific compiler and C-version or so (..) and it seems you can just use int here. but another error on this line is more severe : fopen_s() can not be used, C++ documentation and search on StackOverflow shows we should use std::fstream instead, and #include <fstream> !? But i wasn't able to write proper code here .. can you understand and rewrite this code line for Windows AND Linux ? [ it seems this is the only error in your code .. pitty! ]

zzzzz151 commented 1 year ago

Hey, thanks for the alert. I fixed the linux issues in the most recent commit, and also added a compilation example for linux in the README. If you prefer me to release linux binaries or have any other issue, don't hesitate to open an issue or contact me :)

tissatussa commented 1 year ago

nicely done! your code looks great now .. i like the simple make code line .. although i used 'clang++-16' while it's the newest version on my notebook .. no single error or warning while compiling .. and Z5 runs fine in CuteChess and (even) SCID .. however, Z5 seems to take a rather long initialisation time, fooling SCID at first ("not an UCI engine.."), but then it runs anyhow (to me SCID is buggy in handling the protocols).

in nnue.hpp : using just fopen for Linux seems simple -- you'll have noticed i'm not into C much, supplying my (wrong) code corrections.

Z5 seems to be strong ! i test now with 8 min+10sec just to see how it plays.. any rating known?

zzzzz151 commented 1 year ago

Thanks and yeah z5 does have a lot of initialization code: zobrist numbers, attacks, loading NN, etc. Never had any problems with that though (cutechess) and the CCRL testers also haven't.

z5 1.0 is 3242 elo in blitz: https://ccrl.chessdom.com/ccrl/404/ z5 2.1 and dev should be around 3450 in blitz

Share the results :)

tissatussa commented 1 year ago

the neural network training is impressive, and less then 1 Mb ! Z5 can solve my newest test position quickly : r1bqk2r/pp1n2bp/2p3p1/4pp2/2P5/2N1PNP1/PPQ2PP1/2KR1B1R w kq - 0 12

g4-or-not-g4

White to move : it's a position from one of my own recent club games, i had the Black pieces .. it seems, using StockFish and many other STRONG multi-pv engines, there's CLEARLY only one bestmove here : g4! with eval about +1.5 .. 3 or 4 other moves are about 0.0 here .. so a few weeks ago i decided to run a batch evaluation with many strong and weak engines, to see if they would find g4! : now, to me this position is special for such test ..

what do you think ? are you a good chess player yourself ? i encounter few programmers playing chess ..

tissatussa commented 12 months ago

after downloading the v2.1 version, again i had to change its code accordingly to compile .. shouldn't you fix v2.1 too ?

zzzzz151 commented 12 months ago

No need, 2.1 has the binaries ready to use, and 3.0 will be released soon :)

tissatussa commented 9 months ago

again i can not compile v4.0 on Linux .. but now i have other errors then before .. as you see i tried clang++-17, the newest clang++ version, but it didn't help .. also trying g++(-13) doesn't solve these errors ..

~/Compiled/Starzix-4.0$ clang++-17 -std=c++20 -march=x86-64-v3 -O3 ./src/main.cpp -o starzix
In file included from ./src/main.cpp:3:
In file included from ./src/board.hpp:13:
./src/nnue.hpp:74:5: error: unknown type name '__m256i'
   74 |     __m256i* stmAccumulator;
      |     ^
./src/nnue.hpp:75:5: error: unknown type name '__m256i'
   75 |     __m256i* oppAccumulator;
      |     ^
./src/nnue.hpp:79:27: error: use of undeclared identifier '__m256i'
   79 |         stmAccumulator = (__m256i*)accumulator.white;
      |                           ^
./src/nnue.hpp:79:35: error: expected expression
   79 |         stmAccumulator = (__m256i*)accumulator.white;
      |                                   ^
./src/nnue.hpp:80:27: error: use of undeclared identifier '__m256i'
   80 |         oppAccumulator = (__m256i*)accumulator.black;
      |                           ^
./src/nnue.hpp:80:35: error: expected expression
   80 |         oppAccumulator = (__m256i*)accumulator.black;
      |                                   ^
./src/nnue.hpp:84:27: error: use of undeclared identifier '__m256i'
   84 |         stmAccumulator = (__m256i*)accumulator.black;
      |                           ^
./src/nnue.hpp:84:35: error: expected expression
   84 |         stmAccumulator = (__m256i*)accumulator.black;
      |                                   ^
./src/nnue.hpp:85:27: error: use of undeclared identifier '__m256i'
   85 |         oppAccumulator = (__m256i*)accumulator.white;
      |                           ^
./src/nnue.hpp:85:35: error: expected expression
   85 |         oppAccumulator = (__m256i*)accumulator.white;
      |                                   ^
./src/nnue.hpp:88:5: error: unknown type name '__m256i'
   88 |     __m256i* stmWeights = (__m256i*)&nn->outputWeights[0];
      |     ^
./src/nnue.hpp:88:28: error: use of undeclared identifier '__m256i'
   88 |     __m256i* stmWeights = (__m256i*)&nn->outputWeights[0];
      |                            ^
./src/nnue.hpp:88:36: error: expected expression
   88 |     __m256i* stmWeights = (__m256i*)&nn->outputWeights[0];
      |                                    ^
./src/nnue.hpp:89:5: error: unknown type name '__m256i'
   89 |     __m256i* oppWeights = (__m256i*)&nn->outputWeights[HIDDEN_LAYER_SIZE];
      |     ^
./src/nnue.hpp:89:28: error: use of undeclared identifier '__m256i'
   89 |     __m256i* oppWeights = (__m256i*)&nn->outputWeights[HIDDEN_LAYER_SIZE];
      |                            ^
./src/nnue.hpp:89:36: error: expected expression
   89 |     __m256i* oppWeights = (__m256i*)&nn->outputWeights[HIDDEN_LAYER_SIZE];
      |                                    ^
./src/nnue.hpp:91:11: error: unknown type name '__m256i'
   91 |     const __m256i reluClipMin = _mm256_setzero_si256();
      |           ^
./src/nnue.hpp:91:33: error: use of undeclared identifier '_mm256_setzero_si256'
   91 |     const __m256i reluClipMin = _mm256_setzero_si256();
      |                                 ^
./src/nnue.hpp:92:11: error: unknown type name '__m256i'
   92 |     const __m256i reluClipMax = _mm256_set1_epi16(QA);
      |           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
zzzzz151 commented 9 months ago

@tissatussa Thanks for the issue. Should be fixed now. I've also added linux binaries to 4.0 release.

tissatussa commented 9 months ago

@zzzzz151 indeed it's fixed : i can compile your newest v4.0 source and it gives a 927.3 Kb binary (without any error or warning, using clang++-17) which runs fine in CuteChess ! Your asset is 3.3 Mb !?

i wonder how the engine can be so small : the NN is less than 1 Mb .. once NNUE files were 20 Mb each !? Starzix v4.0 won my first test game (15 minutes, with Black) against Mida v2.3, which has such 20 Mb NNUE ..