Stockfish haswell optimized build

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

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
syzygy
Posts: 4496
Joined: Tue Feb 28, 2012 10:56 pm

Re: Stockfish haswell optimized build

Post by syzygy » Sun Apr 06, 2014 8:42 pm

phenri wrote:Why in the makefile, POPCNT comes with the flag -msse3 instead of -msse4.2 while POPCNT is present only for architectures with a minimum SSE4.2.
It is not entirely true that POPCNT needs SSE4.2. On AMD native popcnt came with SSE4a.

I tried compiling with -msse4.2. It did not improve the speed.
And why the flag -mpopcnt is not included?

Code: Select all

### 3.9 popcnt
ifeq ($(popcnt),yes)
	CXXFLAGS += -msse3 -DUSE_POPCNT
endif
Because stockfish uses inline assembly for native popcount, so the compiler does not need to be told it can generate the popcnt instruction. It would be different if stockfish used the __builtin_popcountll() compiler intrinsic.
Same for preftech why the flag is so low?

Code: Select all

### 3.7 prefetch[/quote]
I did not check, but I suppose the prefetch instruction is available on systems with sse. So no need to generate executables that don't work on systems that do not have sse2 or higher.

syzygy
Posts: 4496
Joined: Tue Feb 28, 2012 10:56 pm

Re: Stockfish haswell optimized build

Post by syzygy » Sun Apr 06, 2014 8:43 pm

j_romang wrote:I didn't try :wink:
See the suggested code changes I posted above. They try.

User avatar
AdminX
Posts: 5374
Joined: Mon Mar 13, 2006 1:34 pm
Location: Acworth, GA
Contact:

Re: Stockfish haswell optimized build

Post by AdminX » Sun Apr 06, 2014 9:02 pm

j_romang wrote:Hello,
I just tried to make a haswell optimized build : https://www.dropbox.com/s/ghbs1vw18q6q4 ... 8_bmi2.zip
Thanks to Ronald de Man's code, I implemented BMI2 instructions in stockfish. This build also supports his syzygy's tablebases.
Please tell me if it works, you should have a ~4% speedup with the corresponding abrok.eu version. Of course you need a Haswell processor to run it !
Please note that this is NOT an official build, but just an experiment :wink:
About to take it out for a spin. :)

Thanks
"Good decisions come from experience, and experience comes from bad decisions."
__________________________________________________________________
Ted Summers

phenri
Posts: 284
Joined: Tue Aug 13, 2013 7:44 am

Re: Stockfish haswell optimized build

Post by phenri » Sun Apr 06, 2014 9:55 pm

Thank's Ronald

The makefile should be upgraded to the SSE4.2

syzygy
Posts: 4496
Joined: Tue Feb 28, 2012 10:56 pm

Re: Stockfish haswell optimized build

Post by syzygy » Sun Apr 06, 2014 11:01 pm

phenri wrote:The makefile should be upgraded to the SSE4.2
Not a good idea, unless it would gain speed. It does not for me.

Compiling with -msse4.2 means it won't work on machines that have sse3 but not sse4.2.

phenri
Posts: 284
Joined: Tue Aug 13, 2013 7:44 am

Re: Stockfish haswell optimized build

Post by phenri » Sun Apr 06, 2014 11:35 pm

syzygy wrote:
phenri wrote:The makefile should be upgraded to the SSE4.2
Not a good idea, unless it would gain speed. It does not for me.

Compiling with -msse4.2 means it won't work on machines that have sse3 but not sse4.2.
But sse3 is relatively very old, why it come with modern profile

phenri
Posts: 284
Joined: Tue Aug 13, 2013 7:44 am

Re: Stockfish haswell optimized build

Post by phenri » Wed Apr 09, 2014 12:13 am

Hi,
I have another question: For Stockfish supports a CPU with AVX, should we add additional code or simply use the flag -mavx?

syzygy
Posts: 4496
Joined: Tue Feb 28, 2012 10:56 pm

Re: Stockfish haswell optimized build

Post by syzygy » Wed Apr 09, 2014 5:55 am

phenri wrote:
syzygy wrote:
phenri wrote:The makefile should be upgraded to the SSE4.2
Not a good idea, unless it would gain speed. It does not for me.

Compiling with -msse4.2 means it won't work on machines that have sse3 but not sse4.2.
But sse3 is relatively very old, why it come with modern profile
Ok, third time.

Why do you want to make life difficult for people with older hardware.
If it gains you anything, I can understand. If it gains you nothing, I do not understand.

I have measured. It gains you nothing.
So you just want to make life difficult for people with older hardware?

BBauer
Posts: 658
Joined: Wed Mar 08, 2006 7:58 pm

Re: Stockfish haswell optimized build

Post by BBauer » Wed Apr 09, 2014 7:15 am

It's up to anybody to change the Makefile.
I use
PGOBENCH = ./$(EXE) bench 1024 1 4 default time
which results in a longer compile time.
CXXFLAGS += -msse4a -DUSE_POPCNT
and have deleted -msse.
CXXFLAGS += -Ofast -march=native
I have the feeling that native may give a small speed up.

So do what you like, but for the general distribution we should think of others needs too.
Kind regards
Bernhard

zullil
Posts: 6072
Joined: Mon Jan 08, 2007 11:31 pm
Location: PA USA
Full name: Louis Zulli

Re: Stockfish haswell optimized build

Post by zullil » Wed Apr 09, 2014 9:41 am

BBauer wrote:It's up to anybody to change the Makefile.
I use
PGOBENCH = ./$(EXE) bench 1024 1 4 default time
which results in a longer compile time.
CXXFLAGS += -msse4a -DUSE_POPCNT
and have deleted -msse.
CXXFLAGS += -Ofast -march=native
I have the feeling that native may give a small speed up.

So do what you like, but for the general distribution we should think of others needs too.
Kind regards
Bernhard
No need for -msse4a since you have -march=native.

Try -O3 -fno-tree-pre instead of -Ofast.

Post Reply