Page 23 of 23

Re: Stockfish NN release (NNUE)

Posted: Sun Jul 26, 2020 7:59 pm
by Aleksei
petero2 wrote:
Sun Jul 26, 2020 7:18 am
Hi Aleksei,

I don't like using PM for things that could be of interest for more than one person

Ok got it. I prefer PM because I don't want to look "silly", with my dump questions.. :oops:
petero2 wrote:
Sun Jul 26, 2020 7:18 am
but here are some more things I found out:

I also got crashes when using NDK r21d, so I used version r20b instead. I suspect this is related to the -fopenmp flag and I also suspect you only need this flag to run the training code, but I have not tested this.

For recent NDK versions you no longer need to create a standalone toolchain. You can run the compiler directly from the bin directory created when unpacking the NDK zip file, e.g. something like d:\android-ndk-r20b\toolchains\llvm\prebuilt\windows_something\bin. It may still work to create a standalone toolchain though, I have not tested that.

You don't need to change the Makefile when using your bat file because it is invoking the compiler directly so the Makefile is not used.
I've downloaded android-ndk-r20b-windows-x86_64, unzipped it, and rename the folder to "0", so directory is now "D:\Downloads\0".
First i created standalone toolchain, it didn't work, i got this errors.

Code: Select all

Generating 64 bit engine for ARM-Android.
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::NNUE::Fea
tureTransformer::RefreshAccumulator(Position const&) const':
ld-temp.o:(.text._ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Posit
ion[_ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Position]+0x40): u
ndefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)
0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Features::IndexList*
)'
ld-temp.o:(.text._ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Posit
ion[_ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Position]+0x50): u
ndefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)
0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Features::IndexList*
)'
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::evaluate(
Position const&)':
ld-temp.o:(.text._ZN4Eval8evaluateERK8Position+0x98): undefined reference to `Ev
al::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::AppendActiveIndices(P
osition const&, Color, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval8evaluateERK8Position+0xc4): undefined reference to `Ev
al::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::AppendChangedIndices(
Position const&, Color, Eval::NNUE::Features::IndexList*, Eval::NNUE::Features::
IndexList*)'
ld-temp.o:(.text._ZN4Eval8evaluateERK8Position+0xec): undefined reference to `Ev
al::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::AppendActiveIndices(P
osition const&, Color, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval8evaluateERK8Position+0x108): undefined reference to `E
val::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::AppendChangedIndices
(Position const&, Color, Eval::NNUE::Features::IndexList*, Eval::NNUE::Features:
:IndexList*)'
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::NNUE::Tes
tCommand(Position&, std::__ndk1::basic_istream<char, std::__ndk1::char_traits<ch
ar> >&)':
ld-temp.o:(.text._ZN4Eval4NNUE11TestCommandER8PositionRNSt6__ndk113basic_istream
IcNS3_11char_traitsIcEEEE+0x53c): undefined reference to `Eval::NNUE::Features::
HalfKP<(Eval::NNUE::Features::Side)0>::AppendActiveIndices(Position const&, Colo
r, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval4NNUE11TestCommandER8PositionRNSt6__ndk113basic_istream
IcNS3_11char_traitsIcEEEE+0x55c): undefined reference to `Eval::NNUE::Features::
HalfKP<(Eval::NNUE::Features::Side)0>::AppendChangedIndices(Position const&, Col
or, Eval::NNUE::Features::IndexList*, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval4NNUE11TestCommandER8PositionRNSt6__ndk113basic_istream
IcNS3_11char_traitsIcEEEE+0x580): undefined reference to `Eval::NNUE::Features::
HalfKP<(Eval::NNUE::Features::Side)0>::AppendActiveIndices(Position const&, Colo
r, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval4NNUE11TestCommandER8PositionRNSt6__ndk113basic_istream
IcNS3_11char_traitsIcEEEE+0x594): undefined reference to `Eval::NNUE::Features::
HalfKP<(Eval::NNUE::Features::Side)0>::AppendChangedIndices(Position const&, Col
or, Eval::NNUE::Features::IndexList*, Eval::NNUE::Features::IndexList*)'
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::NNUE::(an
onymous namespace)::TestFeatures(Position&)::$_1::operator()(Position const&) co
nst':
ld-temp.o:(.text._ZZN4Eval4NNUE12_GLOBAL__N_112TestFeaturesER8PositionENK3$_1clE
RKS2_+0x2ec): undefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::
Features::Side)0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Featu
res::IndexList*)'
ld-temp.o:(.text._ZZN4Eval4NNUE12_GLOBAL__N_112TestFeaturesER8PositionENK3$_1clE
RKS2_+0x2fc): undefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::
Features::Side)0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Featu
res::IndexList*)'
clang80++: error: linker command failed with exit code 1 (use -v to see invocati
on)
Press any key to continue . . .
After that i changed directory in my batch file to "D:\Downloads\0\toolchains\llvm\prebuilt\windows-x86_64\x86_64-linux-android\bin" it didn't work too.

Code: Select all

Generating 64 bit engine for ARM-Android.
'D:\Downloads\0\toolchains\llvm\prebuilt\windows-x86_64\x86_64-linux-android\bin
\clang++' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
So what i'm doing wrong?
My flags

Code: Select all

echo Generating 64 bit engine for ARM-Android.
set "compiler_options=-m64 -march=armv8-a -DIS_64BIT -fPIE -Wl,-pie -lm -DEVAL_NNUE -DENABLE_TEST_CMD -fopenmp -O3 -flto -DUSE_POPCNT -static-libstdc++ -std=c++17 -fno-strict-aliasing -fno-strict-overflow -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-s"

Re: Stockfish NN release (NNUE)

Posted: Sun Jul 26, 2020 11:35 pm
by Aleksei
Aleksei wrote:
Sun Jul 26, 2020 7:59 pm
petero2 wrote:
Sun Jul 26, 2020 7:18 am
Hi Aleksei,

I don't like using PM for things that could be of interest for more than one person

Ok got it. I prefer PM because I don't want to look "silly", with my dump questions.. :oops:
petero2 wrote:
Sun Jul 26, 2020 7:18 am
but here are some more things I found out:

I also got crashes when using NDK r21d, so I used version r20b instead. I suspect this is related to the -fopenmp flag and I also suspect you only need this flag to run the training code, but I have not tested this.

For recent NDK versions you no longer need to create a standalone toolchain. You can run the compiler directly from the bin directory created when unpacking the NDK zip file, e.g. something like d:\android-ndk-r20b\toolchains\llvm\prebuilt\windows_something\bin. It may still work to create a standalone toolchain though, I have not tested that.

You don't need to change the Makefile when using your bat file because it is invoking the compiler directly so the Makefile is not used.
I've downloaded android-ndk-r20b-windows-x86_64, unzipped it, and rename the folder to "0", so directory is now "D:\Downloads\0".
First i created standalone toolchain, it didn't work, i got this errors.

Code: Select all

Generating 64 bit engine for ARM-Android.
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::NNUE::Fea
tureTransformer::RefreshAccumulator(Position const&) const':
ld-temp.o:(.text._ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Posit
ion[_ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Position]+0x40): u
ndefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)
0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Features::IndexList*
)'
ld-temp.o:(.text._ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Posit
ion[_ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Position]+0x50): u
ndefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)
0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Features::IndexList*
)'
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::evaluate(
Position const&)':
ld-temp.o:(.text._ZN4Eval8evaluateERK8Position+0x98): undefined reference to `Ev
al::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::AppendActiveIndices(P
osition const&, Color, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval8evaluateERK8Position+0xc4): undefined reference to `Ev
al::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::AppendChangedIndices(
Position const&, Color, Eval::NNUE::Features::IndexList*, Eval::NNUE::Features::
IndexList*)'
ld-temp.o:(.text._ZN4Eval8evaluateERK8Position+0xec): undefined reference to `Ev
al::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::AppendActiveIndices(P
osition const&, Color, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval8evaluateERK8Position+0x108): undefined reference to `E
val::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::AppendChangedIndices
(Position const&, Color, Eval::NNUE::Features::IndexList*, Eval::NNUE::Features:
:IndexList*)'
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::NNUE::Tes
tCommand(Position&, std::__ndk1::basic_istream<char, std::__ndk1::char_traits<ch
ar> >&)':
ld-temp.o:(.text._ZN4Eval4NNUE11TestCommandER8PositionRNSt6__ndk113basic_istream
IcNS3_11char_traitsIcEEEE+0x53c): undefined reference to `Eval::NNUE::Features::
HalfKP<(Eval::NNUE::Features::Side)0>::AppendActiveIndices(Position const&, Colo
r, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval4NNUE11TestCommandER8PositionRNSt6__ndk113basic_istream
IcNS3_11char_traitsIcEEEE+0x55c): undefined reference to `Eval::NNUE::Features::
HalfKP<(Eval::NNUE::Features::Side)0>::AppendChangedIndices(Position const&, Col
or, Eval::NNUE::Features::IndexList*, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval4NNUE11TestCommandER8PositionRNSt6__ndk113basic_istream
IcNS3_11char_traitsIcEEEE+0x580): undefined reference to `Eval::NNUE::Features::
HalfKP<(Eval::NNUE::Features::Side)0>::AppendActiveIndices(Position const&, Colo
r, Eval::NNUE::Features::IndexList*)'
ld-temp.o:(.text._ZN4Eval4NNUE11TestCommandER8PositionRNSt6__ndk113basic_istream
IcNS3_11char_traitsIcEEEE+0x594): undefined reference to `Eval::NNUE::Features::
HalfKP<(Eval::NNUE::Features::Side)0>::AppendChangedIndices(Position const&, Col
or, Eval::NNUE::Features::IndexList*, Eval::NNUE::Features::IndexList*)'
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::NNUE::(an
onymous namespace)::TestFeatures(Position&)::$_1::operator()(Position const&) co
nst':
ld-temp.o:(.text._ZZN4Eval4NNUE12_GLOBAL__N_112TestFeaturesER8PositionENK3$_1clE
RKS2_+0x2ec): undefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::
Features::Side)0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Featu
res::IndexList*)'
ld-temp.o:(.text._ZZN4Eval4NNUE12_GLOBAL__N_112TestFeaturesER8PositionENK3$_1clE
RKS2_+0x2fc): undefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::
Features::Side)0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Featu
res::IndexList*)'
clang80++: error: linker command failed with exit code 1 (use -v to see invocati
on)
Press any key to continue . . .
After that i changed directory in my batch file to "D:\Downloads\0\toolchains\llvm\prebuilt\windows-x86_64\x86_64-linux-android\bin" it didn't work too.

Code: Select all

Generating 64 bit engine for ARM-Android.
'D:\Downloads\0\toolchains\llvm\prebuilt\windows-x86_64\x86_64-linux-android\bin
\clang++' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
So what i'm doing wrong?
My flags

Code: Select all

echo Generating 64 bit engine for ARM-Android.
set "compiler_options=-m64 -march=armv8-a -DIS_64BIT -fPIE -Wl,-pie -lm -DEVAL_NNUE -DENABLE_TEST_CMD -fopenmp -O3 -flto -DUSE_POPCNT -static-libstdc++ -std=c++17 -fno-strict-aliasing -fno-strict-overflow -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-s"
My flags in batch (corrected).

Code: Select all

set "compiler_64=%compiler_path_64%\clang++"

**********************
echo Generating 64 bit engine for ARM-Android.
set "compiler_options=-m64 -march=armv8-a -DIS_64BIT -fPIE -Wl,-pie -lm -DEVAL_NNUE -DENABLE_TEST_CMD -fopenmp -O3 -flto -DUSE_POPCNT -static-libstdc++ -std=c++17 -fno-strict-aliasing -fno-strict-overflow -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-s"

Re: Stockfish NN release (NNUE)

Posted: Mon Jul 27, 2020 6:52 pm
by Aleksei
No one can help with android version? :(

Re: Stockfish NN release (NNUE)

Posted: Mon Jul 27, 2020 10:37 pm
by Aleksei
petero2 wrote:
Sun Jul 26, 2020 7:18 am
For recent NDK versions you no longer need to create a standalone toolchain. You can run the compiler directly from the bin directory created when unpacking the NDK zip file, e.g. something like d:\android-ndk-r20b\toolchains\llvm\prebuilt\windows_something\bin.
Ok Peter, so what now?
Image

Re: Stockfish NN release (NNUE)

Posted: Tue Jul 28, 2020 6:11 pm
by petero2
Aleksei wrote:
Sun Jul 26, 2020 7:59 pm
I've downloaded android-ndk-r20b-windows-x86_64, unzipped it, and rename the folder to "0", so directory is now "D:\Downloads\0".
First i created standalone toolchain, it didn't work, i got this errors.

Code: Select all

Generating 64 bit engine for ARM-Android.
C:\Users\User\AppData\Local\Temp\lto-llvm-f2f5b6.o: In function `Eval::NNUE::Fea
tureTransformer::RefreshAccumulator(Position const&) const':
ld-temp.o:(.text._ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Posit
ion[_ZNK4Eval4NNUE18FeatureTransformer18RefreshAccumulatorERK8Position]+0x40): u
ndefined reference to `Eval::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)
0>::AppendActiveIndices(Position const&, Color, Eval::NNUE::Features::IndexList*
)'
...
I think this happens because your script is not compiling all required files. You need to compile all files corresponding to the SRCS variable in the Makefile.
Aleksei wrote:
Sun Jul 26, 2020 7:59 pm
After that i changed directory in my batch file to "D:\Downloads\0\toolchains\llvm\prebuilt\windows-x86_64\x86_64-linux-android\bin" it didn't work too.

Code: Select all

Generating 64 bit engine for ARM-Android.
'D:\Downloads\0\toolchains\llvm\prebuilt\windows-x86_64\x86_64-linux-android\bin
\clang++' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
So what i'm doing wrong?
That file does not exist. I think it should be:

D:\Downloads\0\toolchains\llvm\prebuilt\windows-x86_64\x86_64-linux-android\bin\aarch64-linux-android24-clang++

Re: Stockfish NN release (NNUE)

Posted: Wed Jul 29, 2020 11:53 pm
by Aleksei
petero2 wrote:
Tue Jul 28, 2020 6:11 pm
I think this happens because your script is not compiling all required files. You need to compile all files corresponding to the SRCS variable in the Makefile.
Yes Peter you are right, i overlooked some files, tnx!
petero2 wrote:
Tue Jul 28, 2020 6:11 pm
That file does not exist. I think it should be:
D:\Downloads\0\toolchains\llvm\prebuilt\windows-x86_64\x86_64-linux-android\bin\aarch64-linux-android24-clang++
I don't have aarch64-linux-android24-clang++ in bin folder.
Image
-----------------------------------
I managed to make android version (from nodechip source) using standalone toolchain, and i want to ask you something. Why your compilation is 1.446 KB while mine is 723 KB, also your is faster about 200 nps, did you make it on Linux PC? Or there is another way for engines compiling with NDK's clang?

Re: Stockfish NN release (NNUE)

Posted: Fri Jul 31, 2020 6:40 pm
by petero2
Aleksei wrote:
Wed Jul 29, 2020 11:53 pm
I managed to make android version (from nodechip source) using standalone toolchain, and i want to ask you something. Why your compilation is 1.446 KB while mine is 723 KB, also your is faster about 200 nps, did you make it on Linux PC? Or there is another way for engines compiling with NDK's clang?
I used static linking (-static) to make the engine work on more android devices. This makes the compiled file a lot larger though.

The speed difference is probably because I enabled ARM NEON vector instructions (-DIS_ARM). To make this work I had to add an include file to nnue_common.h. For details see:

viewtopic.php?f=2&t=74515&p=853010#p853010

Re: Stockfish NN release (NNUE)

Posted: Fri Jul 31, 2020 7:04 pm
by Damir
Hi Peter

Will we soon see Texel with NNUE support ? :) :)