Is in this world really no compile of Sf-NNUE for arm-8?

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
User avatar
Thomas Lagershausen
Posts: 292
Joined: Mon Jun 11, 2007 4:59 pm

Is in this world really no compile of Sf-NNUE for arm-8?

Post by Thomas Lagershausen » Mon Jul 20, 2020 5:31 pm

Sorry for asking here.

Yesterday i had asked in discord stockfish-nnue- general and -help and got no answer.

Today the same game.

Really, no one is interested?

Where is the hero who makes a arm-8 compile for the 256x nn.bin?

Please,make the world a better place :!:
TL

supersharp77
Posts: 1011
Joined: Sat Jul 05, 2014 5:54 am
Location: Southwest USA

Re: Is in this world really no compile of Sf-NNUE for arm-8?

Post by supersharp77 » Mon Jul 20, 2020 8:35 pm

Thomas Lagershausen wrote:
Mon Jul 20, 2020 5:31 pm
Sorry for asking here.

Yesterday i had asked in discord stockfish-nnue- general and -help and got no answer.

Today the same game.

Really, no one is interested?

Where is the hero who makes a arm-8 compile for the 256x nn.bin?

Please,make the world a better place :!:
Skynet "Well, before making android engine i've put the nn.bin file in src/eval folder, here is simple lto arm8 engine (non pgo). First of all, when Droidfish or Chess for Android GUIs loading the engine, they not providing any information about nn.bin if it was loaded or not." "Almost all android devices has the same path / directory to the internal memory,
which is /storage/emulated/0, I created a folder with name "eval" and put the nn.bin file there, whole path
/storage/emulated/0/eval/nn.bin, and i still don't have any idea if engine is using nn.bin. Try by yourself, maybe you find the correct path. "
Btw, using NDK's CLANG i didn't saw a single warning.


http://outskirts.altervista.org/forum/d ... php?id=831

All Thx to Skynet........ :) :wink:

User avatar
Thomas Lagershausen
Posts: 292
Joined: Mon Jun 11, 2007 4:59 pm

Re: Is in this world really no compile of Sf-NNUE for arm-8?

Post by Thomas Lagershausen » Tue Jul 21, 2020 6:18 am

I am looking for a working compile for arm-8 on android.

Please check sf-nnue with a testposition.

Here is one:



22/45 00:04 17.874.055 3.874.713 +1,59 Sg4-h6+ g7xh6 Th1xh6 Sf8-g6 Td1-h1 Kg8-f8 Dd3xg6 Kf8-e7 Th6-h7 Te8-f8 Th1-h6 Dd8-e8 Dg6-e4 De8-c8 f4-f5 Dc8xc4 Th6xe6+ Ke7-d8 Te6xd6+ Kd8-c8 g5-g6 Dc4-f1+ Kc1-b2 Df1-b5+ Kb2-c2 Kc8-c7 Th7xf7+ Tf8xf7 g6xf7 Sb8-d7 Td6xd4

To find Nh6+ so fast shows that sf-nnue loaded net 256halfkp-Gekkehenker.

Thx in advance.
TL

petero2
Posts: 612
Joined: Mon Apr 19, 2010 5:07 pm
Location: Sweden
Contact:

Re: Is in this world really no compile of Sf-NNUE for arm-8?

Post by petero2 » Fri Jul 24, 2020 2:12 pm

Here is a version for 64-bit Android that should work at least for Android 7 and later:

https://www.dropbox.com/s/zz6cgi5kxbupd ... api24?dl=1

I needed a small patch to enable ARM NEON vector instructions, which on my Galaxy S10 phone makes the engine about 2.75x faster than without vector instructions. This is still only around 30% of the regular Stockfish speed, so not as good as on Intel hardware.

I don't know how vector instructions affect thermal throttling though. The speedup for longer searches using more cores may be different.

I used the following patch for the nodchip code to enable ARM NEON vector instructions:

Code: Select all

diff --git a/src/Makefile b/src/Makefile
index 2e6c415d..b47aacf0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -312,8 +312,10 @@ endif
 
 ifeq ($(COMP),clang)
 	comp=clang
-	CXX=clang++
-	CXXFLAGS += -pedantic -Wextra -Wshadow
+#	CXX=clang++
+	p=$(ANDROID_BASE)/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin
+	CXX=$(p)/aarch64-linux-android24-clang++
+	CXXFLAGS += -Wall -DIS_ARM
 
 	ifneq ($(KERNEL),Darwin)
 	ifneq ($(KERNEL),OpenBSD)
@@ -388,7 +390,7 @@ ifneq ($(comp),mingw)
 	ifneq ($(OS),Android)
 		# Haiku has pthreads in its libroot, so only link it in on other platforms
 		ifneq ($(KERNEL),Haiku)
-			LDFLAGS += -lpthread
+#			LDFLAGS += -lpthread
 		endif
 	endif
 endif
@@ -532,6 +534,8 @@ ifeq ($(OS), Android)
 	LDFLAGS += -fPIE -pie
 endif
 
+LDFLAGS += -static
+
 ### ==========================================================================
 ### Section 4. Public Targets
 ### ==========================================================================
diff --git a/src/eval/nnue/nnue_common.h b/src/eval/nnue/nnue_common.h
index cffb0098..549e05ca 100644
--- a/src/eval/nnue/nnue_common.h
+++ b/src/eval/nnue/nnue_common.h
@@ -13,6 +13,8 @@
 #include <tmmintrin.h>
 #elif defined(USE_SSE2)
 #include <emmintrin.h>
+#elif defined(IS_ARM)
+#include <arm_neon.h>
 #endif
 
 namespace Eval {

Aleksei
Posts: 22
Joined: Thu Jul 05, 2018 11:14 pm
Full name: Aleksei

Re: Is in this world really no compile of Sf-NNUE for arm-8?

Post by Aleksei » Fri Jul 24, 2020 2:38 pm

petero2 wrote:
Fri Jul 24, 2020 2:12 pm
Here is a version for 64-bit Android that should work at least for Android 7 and later:

https://www.dropbox.com/s/zz6cgi5kxbupd ... api24?dl=1

I needed a small patch to enable ARM NEON vector instructions, which on my Galaxy S10 phone makes the engine about 2.75x faster than without vector instructions. This is still only around 30% of the regular Stockfish speed, so not as good as on Intel hardware.

I don't know how vector instructions affect thermal throttling though. The speedup for longer searches using more cores may be different.

I used the following patch for the nodchip code to enable ARM NEON vector instructions:

Code: Select all

diff --git a/src/Makefile b/src/Makefile
index 2e6c415d..b47aacf0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -312,8 +312,10 @@ endif
 
 ifeq ($(COMP),clang)
 	comp=clang
-	CXX=clang++
-	CXXFLAGS += -pedantic -Wextra -Wshadow
+#	CXX=clang++
+	p=$(ANDROID_BASE)/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin
+	CXX=$(p)/aarch64-linux-android24-clang++
+	CXXFLAGS += -Wall -DIS_ARM
 
 	ifneq ($(KERNEL),Darwin)
 	ifneq ($(KERNEL),OpenBSD)
@@ -388,7 +390,7 @@ ifneq ($(comp),mingw)
 	ifneq ($(OS),Android)
 		# Haiku has pthreads in its libroot, so only link it in on other platforms
 		ifneq ($(KERNEL),Haiku)
-			LDFLAGS += -lpthread
+#			LDFLAGS += -lpthread
 		endif
 	endif
 endif
@@ -532,6 +534,8 @@ ifeq ($(OS), Android)
 	LDFLAGS += -fPIE -pie
 endif
 
+LDFLAGS += -static
+
 ### ==========================================================================
 ### Section 4. Public Targets
 ### ==========================================================================
diff --git a/src/eval/nnue/nnue_common.h b/src/eval/nnue/nnue_common.h
index cffb0098..549e05ca 100644
--- a/src/eval/nnue/nnue_common.h
+++ b/src/eval/nnue/nnue_common.h
@@ -13,6 +13,8 @@
 #include <tmmintrin.h>
 #elif defined(USE_SSE2)
 #include <emmintrin.h>
+#elif defined(IS_ARM)
+#include <arm_neon.h>
 #endif
 
 namespace Eval {
Hi Peter, can you help me with my batch file here? viewtopic.php?p=853009#p853009

User avatar
Thomas Lagershausen
Posts: 292
Joined: Mon Jun 11, 2007 4:59 pm

Re: Is in this world really no compile of Sf-NNUE for arm-8?

Post by Thomas Lagershausen » Fri Jul 24, 2020 2:49 pm

@petero2

You bring the sun back to our live. :P :P :P :P :P :P :P

This is a big step forward in quality of live. :!:

Thx so much ! 8-)
TL

MMarco
Posts: 186
Joined: Sat Apr 11, 2020 11:09 pm
Full name: Marc-O Moisan-Plante

Re: Is in this world really no compile of Sf-NNUE for arm-8?

Post by MMarco » Sat Jul 25, 2020 2:07 am

petero2 wrote:
Fri Jul 24, 2020 2:12 pm
Here is a version for 64-bit Android that should work at least for Android 7 and later:

https://www.dropbox.com/s/zz6cgi5kxbupd ... api24?dl=1

I needed a small patch to enable ARM NEON vector instructions, which on my Galaxy S10 phone makes the engine about 2.75x faster than without vector instructions. This is still only around 30% of the regular Stockfish speed, so not as good as on Intel hardware.

I don't know how vector instructions affect thermal throttling though. The speedup for longer searches using more cores may be different.

I used the following patch for the nodchip code to enable ARM NEON vector instructions:

Code: Select all

diff --git a/src/Makefile b/src/Makefile
index 2e6c415d..b47aacf0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -312,8 +312,10 @@ endif
 
 ifeq ($(COMP),clang)
 	comp=clang
-	CXX=clang++
-	CXXFLAGS += -pedantic -Wextra -Wshadow
+#	CXX=clang++
+	p=$(ANDROID_BASE)/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin
+	CXX=$(p)/aarch64-linux-android24-clang++
+	CXXFLAGS += -Wall -DIS_ARM
 
 	ifneq ($(KERNEL),Darwin)
 	ifneq ($(KERNEL),OpenBSD)
@@ -388,7 +390,7 @@ ifneq ($(comp),mingw)
 	ifneq ($(OS),Android)
 		# Haiku has pthreads in its libroot, so only link it in on other platforms
 		ifneq ($(KERNEL),Haiku)
-			LDFLAGS += -lpthread
+#			LDFLAGS += -lpthread
 		endif
 	endif
 endif
@@ -532,6 +534,8 @@ ifeq ($(OS), Android)
 	LDFLAGS += -fPIE -pie
 endif
 
+LDFLAGS += -static
+
 ### ==========================================================================
 ### Section 4. Public Targets
 ### ==========================================================================
diff --git a/src/eval/nnue/nnue_common.h b/src/eval/nnue/nnue_common.h
index cffb0098..549e05ca 100644
--- a/src/eval/nnue/nnue_common.h
+++ b/src/eval/nnue/nnue_common.h
@@ -13,6 +13,8 @@
 #include <tmmintrin.h>
 #elif defined(USE_SSE2)
 #include <emmintrin.h>
+#elif defined(IS_ARM)
+#include <arm_neon.h>
 #endif
 
 namespace Eval {
Awesome!! Everything runs fine!! I get 180knps in the startposition on one thread on a Kirin 710. SF 110720 gets 530knps (so I'm at 34%).

Thank you so much.

Would it be possible to built for a net size of 96? Smaller nets are appearing on SF discord and they could be interesting to have on Android as they are faster.
Small 7.5 MB net ,size halfkp_96x32x32 ,Komodo playing level or maybe slightly better,very fast.With binaries.

https://gofile.io/d/1OgCOc

Aleksei
Posts: 22
Joined: Thu Jul 05, 2018 11:14 pm
Full name: Aleksei

Re: Is in this world really no compile of Sf-NNUE for arm-8?

Post by Aleksei » Sun Aug 02, 2020 3:53 pm

petero2 wrote:
Fri Jul 31, 2020 6:40 pm
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
Hi Peter!
So, for use static linking i have to change flag in my batch from -static-libstdc++ to -static, add -DIS_ARM flag, and i need to add in to Makefile, right?

Code: Select all

+#	CXX=clang++
+	p=$(ANDROID_BASE)/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin
+	CXX=$(p)/aarch64-linux-android24-clang++
+	CXXFLAGS += -Wall -DIS_ARM

+#			LDFLAGS += -lpthread

+#elif defined(IS_ARM)
+#include <arm_neon.h>

RogerC
Posts: 35
Joined: Tue Oct 29, 2019 7:33 pm
Location: French Polynesia
Full name: Roger C.

Re: Is in this world really no compile of Sf-NNUE for arm-8?

Post by RogerC » Sun Aug 09, 2020 12:08 am

petero2 wrote:
Fri Jul 24, 2020 2:12 pm
Here is a version for 64-bit Android that should work at least for Android 7 and later:

https://www.dropbox.com/s/zz6cgi5kxbupd ... api24?dl=1

I needed a small patch to enable ARM NEON vector instructions, which on my Galaxy S10 phone makes the engine about 2.75x faster than without vector instructions. This is still only around 30% of the regular Stockfish speed, so not as good as on Intel hardware.

I don't know how vector instructions affect thermal throttling though. The speedup for longer searches using more cores may be different.
Hi petero2, your Android compilation that enable NEON vector instructions and NNUE nets is great !
Would you please compile the SFdev version of August 8 that is 20-30 elo points added to NNUE nets ? Thank you very much.

Post Reply