working source for stockfish 1.6.2

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

ldesnogu

Re: working source for stockfish 1.6.2

Post by ldesnogu »

I have this in my Makefile:

Code: Select all

GCCFLAGS = -O3 -msse -mpopcnt
Also note I forced gcc to recognize my CPU as having popcnt by making cpu_has_popcnt return true.
EDIT: I also defined POPCNT_INTRINSIC(x) __builtin_popcountl(x)

And as far as I can see USE_POPCNT would only impact icc, not gcc.

And to make it sure:

Code: Select all

$ objdump -d stockfish-gcc | grep popcnt
...
  40d2a3:	f3 48 0f b8 c0       	popcnt %rax,%rax
...
$ objdump -d stockfish-icc-profile-popcnt | grep -i popcnt
...
  42102e:	f3 48 0f b8 f6       	popcnt %rsi,%rsi
...
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: working source for stockfish 1.6.2

Post by mcostalba »

ldesnogu wrote:I have this in my Makefile:

Code: Select all

GCCFLAGS = -O3 -msse -mpopcnt
Also note I forced gcc to recognize my CPU as having popcnt by making cpu_has_popcnt return true.
EDIT: I also defined POPCNT_INTRINSIC(x) __builtin_popcountl(x)
Now I understand :-)

I didn't get how was possible you had popcnt support with gcc !

I have quickly written the following patch (took some code from Linux kernel and changed a bit), could you please apply the following and test (in this case passing -DUSE_POPCNT to gcc) ?

Thanks.

Code: Select all

Date: Sat, 30 Jan 2010 19:18:27 +0100
Subject: [PATCH] Add POPCNT support for gcc


---
 src/bitcount.h |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/bitcount.h b/src/bitcount.h
index aa27c04..0641db2 100644
--- a/src/bitcount.h
+++ b/src/bitcount.h
@@ -53,6 +53,29 @@ inline bool cpu_has_popcnt() {
 
 #define POPCNT_INTRINSIC(x) __popcnt64(x)
 
+#elif defined(__GNUC__) && defined(USE_POPCNT) // Gcc compiler
+
+inline void __cpuid(unsigned int op,
+                    unsigned int *eax, unsigned int *ebx,
+                    unsigned int *ecx, unsigned int *edx)
+{
+  *eax = op;
+  *ecx = 0;
+  __asm__("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
+                  : "0" (*eax), "2" (*ecx));
+}
+
+inline bool cpu_has_popcnt() {
+
+  unsigned int eax, ebx, ecx, edx;
+  __cpuid(1, &eax, &ebx, &ecx, &edx);
+  return (ecx >> 23) & 1;
+}
+
+#define POPCNT_INTRINSIC(x) ({ Bitboard __ret; \
+   __asm__("popcnt %1, %0" : "=r" (__ret) : "r" (x));
+   __ret; })
+
 #else // Safe fallback for unsupported compilers or when USE_POPCNT is disabled
 
 inline bool cpu_has_popcnt() { return false; }
-- 
1.6.5.1.1367.gcd48
ldesnogu

Re: working source for stockfish 1.6.2

Post by ldesnogu »

Works fine except that you missed a \ in the POPCNT_INTRINSIC macro :)

Code: Select all

Total time (ms) : 29066
Nodes searched  : 42390880
Nodes/second    : 1458435
BBauer
Posts: 658
Joined: Wed Mar 08, 2006 8:58 pm

Re: working source for stockfish 1.6.2

Post by BBauer »

Here my output

Code: Select all

g++ -msse -MM application.cpp bitboard.cpp pawns.cpp material.cpp endgame.cpp evaluate.cpp main.cpp misc.cpp move.cpp movegen.cpp history.cpp movepick.cpp search.cpp piece.cpp position.cpp direction.cpp tt.cpp value.cpp uci.cpp ucioption.cpp mersenne.cpp book.cpp bitbase.cpp san.cpp benchmark.cpp > .depend
make \
	CXX='/opt/intel/Compiler/11.1/current/bin/intel64/icpc' \
	CXXFLAGS="-O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503" \
	all
make[1]: Betrete Verzeichnis '/home/bbauer/64/Stockfish/stockfish-162-ja/src'
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o application.o application.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o bitboard.o bitboard.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o pawns.o pawns.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o material.o material.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o endgame.o endgame.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o evaluate.o evaluate.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o main.o main.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o misc.o misc.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o move.o move.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o movegen.o movegen.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o history.o history.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o movepick.o movepick.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o search.o search.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o piece.o piece.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o position.o position.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o direction.o direction.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o tt.o tt.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o value.o value.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o uci.o uci.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o ucioption.o ucioption.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o mersenne.o mersenne.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o book.o book.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o bitbase.o bitbase.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o san.o san.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -O3   -DNDEBUG -g -Wall -fno-exceptions -fno-rtti -wd383,869,981,10187,10188,11505,11503   -c -o benchmark.o benchmark.cpp
/opt/intel/Compiler/11.1/current/bin/intel64/icpc -lpthread -o stockfish application.o bitboard.o pawns.o material.o endgame.o evaluate.o main.o misc.o move.o movegen.o history.o movepick.o search.o piece.o position.o direction.o tt.o value.o uci.o ucioption.o mersenne.o book.o bitbase.o san.o benchmark.o
make[1]: Verlasse Verzeichnis '/home/bbauer/64/Stockfish/stockfish-162-ja/src'
hope that helps
Bernhard
ldesnogu

Re: working source for stockfish 1.6.2

Post by ldesnogu »

It doesn't really help. You are experimenting an issue I don't have.

Having stockfish not even dump version information is really strange.

Things to try:

- try to launch stockfish with a debugger and see where it hangs.
- is your Linux system up to date (there might be a library issue)?
- a more recent version of Intel Compiler (I use 11.1 20091130)

I know that might be a pain, but well it works for me and others it seems :)
maxchgr

Re: working source for stockfish 1.6.2

Post by maxchgr »

I'm a bit confused as to what is the latest version of Stockfish, and which is the best versin? I understand there is a Jim Abblet version and a Dan Corbit version? (Also, who are those guys? Sorry - not keeping myself up to date these days)
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: working source for stockfish 1.6.2

Post by zullil »

maxchgr wrote:I'm a bit confused as to what is the latest version of Stockfish, and which is the best versin? I understand there is a Jim Abblet version and a Dan Corbit version? (Also, who are those guys? Sorry - not keeping myself up to date these days)
The current version is 1.6.2. A bug-fix version is supposed to be released soon. You might want to wait until then.
maxchgr

Re: working source for stockfish 1.6.2

Post by maxchgr »

Thank you Zulli. Let me pick your brain. What is 1.6s? What is the bug that needs fixing? Thanks