Stockfish version with hash saving capability

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

Moderators: hgm, Rebel, chrisw

User avatar
Zerbinati
Posts: 122
Joined: Mon Aug 18, 2014 7:12 pm
Location: Trento (Italy)

Re: Stockfish version with hash saving capability

Post by Zerbinati »

cdani wrote:Done! Now they can work with files larger than 2 GB.

Andscacs:

www.andscacs.com/downloads/andscacs091237.zip

Stockfish:

www.andscacs.com/downloads/stockfish_x6 ... vehash.zip

Stockfish changes:

Code: Select all

bool TranspositionTable::save() {
	std::ofstream b_stream(hashfilename,
		std::fstream::out | std::fstream::binary);
	if (b_stream)
	{
		//b_stream.write&#40;reinterpret_cast<char const *>&#40;table&#41;, clusterCount * sizeof&#40;Cluster&#41;);
		for &#40;long long i = 0; i < clusterCount * sizeof&#40;Cluster&#41;; i += &#40;1 << 30&#41;) &#123; //1GB
			long long j = __min&#40;&#40;1 << 30&#41;, &#40;clusterCount * sizeof&#40;Cluster&#41;) - i&#41;;
			b_stream.write&#40;reinterpret_cast<char const *>&#40;table&#41; + i, j&#41;;
		&#125;
		return &#40;b_stream.good&#40;));
	&#125;
	return false;
&#125;

void TranspositionTable&#58;&#58;load&#40;) &#123;
	//file size&#58; https&#58;//stackoverflow.com/questions/2409504/using-c-filestreams-fstream-how-can-you-determine-the-size-of-a-file
	std&#58;&#58;ifstream file;
	file.open&#40;hashfilename, std&#58;&#58;ios&#58;&#58;in | std&#58;&#58;ios&#58;&#58;binary&#41;;
	file.ignore&#40;std&#58;&#58;numeric_limits<std&#58;&#58;streamsize>&#58;&#58;max&#40;));
	std&#58;&#58;streamsize size = file.gcount&#40;);
	file.clear&#40;);   //  Since ignore will have set eof.
	resize&#40;size / 1024 / 1024&#41;;
	file.seekg&#40;0, std&#58;&#58;ios&#58;&#58;beg&#41;;
	file.read&#40;reinterpret_cast<char *>&#40;table&#41;, clusterCount * sizeof&#40;Cluster&#41;);
&#125;
Thx Daniel!
Rodolfo Leoni
Posts: 545
Joined: Tue Jun 06, 2017 4:49 pm
Location: Italy

Re: Stockfish version with hash saving capability

Post by Rodolfo Leoni »

cdani wrote:Done! Now they can work with files larger than 2 GB.

Andscacs:

www.andscacs.com/downloads/andscacs091237.zip

Stockfish:

www.andscacs.com/downloads/stockfish_x6 ... vehash.zip

Stockfish changes:

Code: Select all

bool TranspositionTable&#58;&#58;save&#40;) &#123;
	std&#58;&#58;ofstream b_stream&#40;hashfilename,
		std&#58;&#58;fstream&#58;&#58;out | std&#58;&#58;fstream&#58;&#58;binary&#41;;
	if &#40;b_stream&#41;
	&#123;
		//b_stream.write&#40;reinterpret_cast<char const *>&#40;table&#41;, clusterCount * sizeof&#40;Cluster&#41;);
		for &#40;long long i = 0; i < clusterCount * sizeof&#40;Cluster&#41;; i += &#40;1 << 30&#41;) &#123; //1GB
			long long j = __min&#40;&#40;1 << 30&#41;, &#40;clusterCount * sizeof&#40;Cluster&#41;) - i&#41;;
			b_stream.write&#40;reinterpret_cast<char const *>&#40;table&#41; + i, j&#41;;
		&#125;
		return &#40;b_stream.good&#40;));
	&#125;
	return false;
&#125;

void TranspositionTable&#58;&#58;load&#40;) &#123;
	//file size&#58; https&#58;//stackoverflow.com/questions/2409504/using-c-filestreams-fstream-how-can-you-determine-the-size-of-a-file
	std&#58;&#58;ifstream file;
	file.open&#40;hashfilename, std&#58;&#58;ios&#58;&#58;in | std&#58;&#58;ios&#58;&#58;binary&#41;;
	file.ignore&#40;std&#58;&#58;numeric_limits<std&#58;&#58;streamsize>&#58;&#58;max&#40;));
	std&#58;&#58;streamsize size = file.gcount&#40;);
	file.clear&#40;);   //  Since ignore will have set eof.
	resize&#40;size / 1024 / 1024&#41;;
	file.seekg&#40;0, std&#58;&#58;ios&#58;&#58;beg&#41;;
	file.read&#40;reinterpret_cast<char *>&#40;table&#41;, clusterCount * sizeof&#40;Cluster&#41;);
&#125;
:D
Joerg already adopted your code, and I hope Mike Byrne will use it too. I sometimes think at the mail I sent you 3 months ago about PHs... Thanks Daniel.
F.S.I. Chess Teacher
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Stockfish version with hash saving capability

Post by zullil »

duncan wrote:
zullil wrote: asmFish eventually found mate-in-11 from the original position. But it took a while.

Code: Select all

info depth 54 seldepth 24 multipv 1 time 5491130 nps 50956798 score mate 11 nodes 279810404462 hashfull 999 tbhits 0 pv a2a4 h7h5 d2d4 c7c6 e2e4 g7g6 d4d5 g6g5 d1h5 e8d8 h5f7 c6d5 f1b5 d5e4 f7d5 d8c8 d5d7 c8b8 b5a6 b8a8 d7b7

is your nps 50956798 which is very fast and quicker than threadripper.? May I ask what sytem you are using?
Not sure what your first sentence is trying to ask. :wink: Yes, the nodes/sec is 50956798, which is indeed very fast. I don't know anything about Threadripper. I have 2 x Intel(R) Xeon(R) CPU E5-2687W v3 @ 3.10GHz and 64GB RAM. I tend to use asmFish because it is NUMA-aware, which seems to improve performance on my system.
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: Stockfish version with hash saving capability

Post by Joerg Oster »

Rodolfo Leoni wrote:
cdani wrote:Done! Now they can work with files larger than 2 GB.

Andscacs:

www.andscacs.com/downloads/andscacs091237.zip

Stockfish:

www.andscacs.com/downloads/stockfish_x6 ... vehash.zip

Stockfish changes:

Code: Select all

bool TranspositionTable&#58;&#58;save&#40;) &#123;
	std&#58;&#58;ofstream b_stream&#40;hashfilename,
		std&#58;&#58;fstream&#58;&#58;out | std&#58;&#58;fstream&#58;&#58;binary&#41;;
	if &#40;b_stream&#41;
	&#123;
		//b_stream.write&#40;reinterpret_cast<char const *>&#40;table&#41;, clusterCount * sizeof&#40;Cluster&#41;);
		for &#40;long long i = 0; i < clusterCount * sizeof&#40;Cluster&#41;; i += &#40;1 << 30&#41;) &#123; //1GB
			long long j = __min&#40;&#40;1 << 30&#41;, &#40;clusterCount * sizeof&#40;Cluster&#41;) - i&#41;;
			b_stream.write&#40;reinterpret_cast<char const *>&#40;table&#41; + i, j&#41;;
		&#125;
		return &#40;b_stream.good&#40;));
	&#125;
	return false;
&#125;

void TranspositionTable&#58;&#58;load&#40;) &#123;
	//file size&#58; https&#58;//stackoverflow.com/questions/2409504/using-c-filestreams-fstream-how-can-you-determine-the-size-of-a-file
	std&#58;&#58;ifstream file;
	file.open&#40;hashfilename, std&#58;&#58;ios&#58;&#58;in | std&#58;&#58;ios&#58;&#58;binary&#41;;
	file.ignore&#40;std&#58;&#58;numeric_limits<std&#58;&#58;streamsize>&#58;&#58;max&#40;));
	std&#58;&#58;streamsize size = file.gcount&#40;);
	file.clear&#40;);   //  Since ignore will have set eof.
	resize&#40;size / 1024 / 1024&#41;;
	file.seekg&#40;0, std&#58;&#58;ios&#58;&#58;beg&#41;;
	file.read&#40;reinterpret_cast<char *>&#40;table&#41;, clusterCount * sizeof&#40;Cluster&#41;);
&#125;
:D
Joerg already adopted your code, ...
Huh? Where? :?
Jörg Oster
Rodolfo Leoni
Posts: 545
Joined: Tue Jun 06, 2017 4:49 pm
Location: Italy

Re: Stockfish version with hash saving capability

Post by Rodolfo Leoni »

Joerg Oster wrote: Huh? Where? :?
SF Zander maybe? :wink:
F.S.I. Chess Teacher
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: Stockfish version with hash saving capability

Post by Joerg Oster »

Rodolfo Leoni wrote:
Joerg Oster wrote: Huh? Where? :?
SF Zander maybe? :wink:
It seems there is some misunderstanding here.
I'm not responsible for what other people do.

In fact, Marco Z. published SF Zander without dropping any message or asking if that's ok with me.
Which he must not do as far as I know, of course.
Nevertheless, I'm not very happy about it ...
Jörg Oster
Rodolfo Leoni
Posts: 545
Joined: Tue Jun 06, 2017 4:49 pm
Location: Italy

Re: Stockfish version with hash saving capability

Post by Rodolfo Leoni »

Joerg Oster wrote:
Rodolfo Leoni wrote:
Joerg Oster wrote: Huh? Where? :?
SF Zander maybe? :wink:
It seems there is some misunderstanding here.
I'm not responsible for what other people do.

In fact, Marco Z. published SF Zander without dropping any message or asking if that's ok with me.
Which he must not do as far as I know, of course.
Nevertheless, I'm not very happy about it ...
Then, I hope both of you will clear the misunderstanding. And I hope you'll keep the option in the next releases too. BTW, I'd need a readme file (or an Encyclopedia) about all the UCI options there.

And... thanks for the new version, anyway. :)
F.S.I. Chess Teacher
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: Stockfish version with hash saving capability

Post by Joerg Oster »

Rodolfo Leoni wrote:
Joerg Oster wrote:
Rodolfo Leoni wrote:
Joerg Oster wrote: Huh? Where? :?
SF Zander maybe? :wink:
It seems there is some misunderstanding here.
I'm not responsible for what other people do.

In fact, Marco Z. published SF Zander without dropping any message or asking if that's ok with me.
Which he must not do as far as I know, of course.
Nevertheless, I'm not very happy about it ...
Then, I hope both of you will clear the misunderstanding. And I hope you'll keep the option in the next releases too. BTW, I'd need a readme file (or an Encyclopedia) about all the UCI options there.

And... thanks for the new version, anyway. :)
Looks like YOU still don't understand.

I am NOT involved in the release of SF Zander!
I can't keep anything or adopt anything or whatever, as I'm NOT releasing this!

Was that clear enough, now?

And btw., if you need help with all the options, ask Marco Z. for help.
Again, I'm not responsible for the actions of others.
Jörg Oster
Rodolfo Leoni
Posts: 545
Joined: Tue Jun 06, 2017 4:49 pm
Location: Italy

Re: Stockfish version with hash saving capability

Post by Rodolfo Leoni »

Joerg Oster wrote:
Rodolfo Leoni wrote:
Joerg Oster wrote:
Rodolfo Leoni wrote:
Joerg Oster wrote: Huh? Where? :?
SF Zander maybe? :wink:
It seems there is some misunderstanding here.
I'm not responsible for what other people do.

In fact, Marco Z. published SF Zander without dropping any message or asking if that's ok with me.
Which he must not do as far as I know, of course.
Nevertheless, I'm not very happy about it ...
Then, I hope both of you will clear the misunderstanding. And I hope you'll keep the option in the next releases too. BTW, I'd need a readme file (or an Encyclopedia) about all the UCI options there.

And... thanks for the new version, anyway. :)
Looks like YOU still don't understand.

I am NOT involved in the release of SF Zander!
I can't keep anything or adopt anything or whatever, as I'm NOT releasing this!

Was that clear enough, now?

And btw., if you need help with all the options, ask Marco Z. for help.
Again, I'm not responsible for the actions of others.
Joerg, there's no need to get angry. I understand what I read, I can't do any conjecture about what I don't read. When I thought everything was from you, it was because of this:

http://www.talkchess.com/forum/viewtopic.php?t=64841

That states it was your work. Here, you say it wasn't, but I assumed most of the features were from you. Nobody knows what to think about all that stuff, now. Both you and Marco Zerbinati should clear what's happening. Everything is quite confusing.
F.S.I. Chess Teacher
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Stockfish version with hash saving capability

Post by zullil »

Rodolfo Leoni wrote: Both you and Marco Zerbinati should clear what's happening. Everything is quite confusing.
I think Joerg was quite clear about what happened. You can look here to see the work that Joerg has done on Zander. One can assume that the various "extensions" were added by Marco Zerbinati.