official-stockfish / Stockfish

A free and strong UCI chess engine
https://stockfishchess.org/
GNU General Public License v3.0
11.62k stars 2.28k forks source link

Embedded CPU Compilation #3793

Closed he77789 closed 2 years ago

he77789 commented 2 years ago

I am compiling for ARM926EJ-S, and I am not using the makefile (because it does not support armv5). My compilation command is currently arm-linux-gnueabi-g++ -DNDEBUG -Wall -Wshadow -pedantic -Wcast-qual -fno-exceptions -O3 -marm -mcpu=arm926ej-s -mfloat-abi=soft -pthread -Wl,--no-as-needed -latomic -std=c++17 benchmark.cpp bitbase.cpp bitboard.cpp endgame.cpp evaluate.cpp main.cpp material.cpp misc.cpp movegen.cpp movepick.cpp pawns.cpp position.cpp psqt.cpp search.cpp thread.cpp timeman.cpp tt.cpp uci.cpp ucioption.cpp tune.cpp syzygy/tbprobe.cpp nnue/evaluate_nnue.cpp nnue/features/half_ka_v2_hm.cpp -o stockfish

Is there a way that I can compile Stockfish without including NNUE support, e.g. via defining a symbol? I would prefer to have a smaller executable size, as the NNUE file is over 90% of the final executable size. Also, is there a way to reduce the RAM usage? Setting hash table size to 1MB only reduces the RAM usage to around 120MB, but my target platform only has 64MB of RAM.

BTW, I know it will be very slow, I'm just interested to see if it's possible at all.

vondele commented 2 years ago

-DNNUE_EMBEDDING_OFF https://github.com/official-stockfish/Stockfish/blob/f5df517145890ecee3d855e98470241b68645b87/src/evaluate.cpp#L48

vondele commented 2 years ago

memory is more of an issue, there are some history tables that are quite large in size.

he77789 commented 2 years ago

The Linux kernel takes up about 12MB of RAM, so a safe estimate is that I have to get Stockfish to run in 40-50MB of RAM.

Someone has told me that you could get Stockfish to run with 20MB of RAM usage, but I could not find a source or tutorial for that claim.

I wonder if a significant portion of the RAM usage is due to the NNUE residing in memory.

vondele commented 2 years ago

will be nearly impossible, and it certainly is with NNUE. Already the stack size of a search thread is 8MB https://github.com/official-stockfish/Stockfish/blob/f5df517145890ecee3d855e98470241b68645b87/src/thread_win32_osx.h#L36 The NNUE network probably is about 40MB in ram. I think to have something that fits in 40MB, it is better to try and get Stockfish 11 (pre-NNUE) to work.

vondele commented 2 years ago

closing this issue, for discussions on how to develop SF, feel free to join our discord server.