Stockfish Maximum Hash Size

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Stockfish Maximum Hash Size

Post by BBauer »

Yes, if you are doing analysis you need as much hash as you can get.
Therefore the question comes up again and again.
Crafty has no such 2GB limitation and the is no reason to have such a limitation in stockfish.
Woul'd you be so kind and change it?

kind regards
Bernhard
Martin Thoresen
Posts: 1833
Joined: Thu Jun 22, 2006 12:07 am

Re: Stockfish Maximum Hash Size

Post by Martin Thoresen »

BBauer wrote: Crafty has no such 2GB limitation and the is no reason to have such a limitation in stockfish.

kind regards
Bernhard
I was going to ask someone about this, I can't get my Crafty to use more than 1024M hash.

This happens if I try something bigger:

Code: Select all

Crafty v23.1 JA <4 cpus>

White<1>&#58; hash 2048m
AlignedRemalloc<> failed, not enough memory.
hash table memory =       0 bytes.
White<1>&#58;
I have about 5 GB free RAM and I can set 2GB hash in Stockfish without problems (also verified in task manager). Running Win 7 64-bit.

Any idea?
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Stockfish Maximum Hash Size

Post by zullil »

Martin T wrote: I was going to ask someone about this, I can't get my Crafty to use more than 1024M hash.

This happens if I try something bigger:

Code: Select all

Crafty v23.1 JA <4 cpus>

White<1>&#58; hash 2048m
AlignedRemalloc<> failed, not enough memory.
hash table memory =       0 bytes.
White<1>&#58;
I have about 5 GB free RAM and I can set 2GB hash in Stockfish without problems (also verified in task manager). Running Win 7 64-bit.

Any idea?
Hi Martin,

Take a look here.

Louis
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Stockfish Maximum Hash Size

Post by zullil »

I should have linked to this post by Bob Hyatt, which led to my question.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Stockfish Maximum Hash Size

Post by mcostalba »

zullil wrote:I should have linked to this post by Bob Hyatt, which led to my question.
Hi Louis,

could you please try the following patch and tell me if it works ? Now you should set up to 8GB (8192).

Code: Select all

Date&#58; Mon, 1 Feb 2010 12&#58;12&#58;41 +0100
Subject&#58; &#91;PATCH&#93; Extend maximum hash size to 8 GB

---
 src/tt.cpp        |    4 ++--
 src/tt.h          |    2 +-
 src/ucioption.cpp |    2 +-
 3 files changed, 4 insertions&#40;+), 4 deletions&#40;-)

diff --git a/src/tt.cpp b/src/tt.cpp
index 1b2ae72..1fa60b1 100644
--- a/src/tt.cpp
+++ b/src/tt.cpp
@@ -55,9 +55,9 @@ TranspositionTable&#58;&#58;~TranspositionTable&#40;) &#123;
 
 void TranspositionTable&#58;&#58;set_size&#40;unsigned mbSize&#41; &#123;
 
-  assert&#40;mbSize >= 4 && mbSize <= 2048&#41;;
+  assert&#40;mbSize >= 4 && mbSize <= 8192&#41;;
 
-  unsigned newSize = 1024;
+  size_t newSize = 1024;
 
   // We store a cluster of ClusterSize number of TTEntry for each position
   // and newSize is the maximum number of storable positions.
diff --git a/src/tt.h b/src/tt.h
index 5d0df72..c3017c6 100644
--- a/src/tt.h
+++ b/src/tt.h
@@ -114,7 +114,7 @@ private&#58;
   unsigned writes; // heavy SMP read/write access here
   unsigned char pad_after&#91;64&#93;;
 
-  unsigned size;
+  size_t size;
   TTCluster* entries;
   uint8_t generation;
 &#125;;
diff --git a/src/ucioption.cpp b/src/ucioption.cpp
index 0f9c2f8..9fc1f41 100644
--- a/src/ucioption.cpp
+++ b/src/ucioption.cpp
@@ -123,7 +123,7 @@ namespace &#123;
     o&#91;"Minimum Split Depth"&#93; = Option&#40;4, 4, 7&#41;;
     o&#91;"Maximum Number of Threads per Split Point"&#93; = Option&#40;5, 4, 8&#41;;
     o&#91;"Threads"&#93; = Option&#40;1, 1, THREAD_MAX&#41;;
-    o&#91;"Hash"&#93; = Option&#40;32, 4, 2048&#41;;
+    o&#91;"Hash"&#93; = Option&#40;32, 4, 8192&#41;;
     o&#91;"Clear Hash"&#93; = Option&#40;false, BUTTON&#41;;
     o&#91;"New Game"&#93; = Option&#40;false, BUTTON&#41;;
     o&#91;"Ponder"&#93; = Option&#40;true&#41;;
-- 
1.6.5.1.1367.gcd48
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Stockfish Maximum Hash Size

Post by mcostalba »

BBauer wrote:Yes, if you are doing analysis you need as much hash as you can get.
Therefore the question comes up again and again.
Crafty has no such 2GB limitation and the is no reason to have such a limitation in stockfish.
Woul'd you be so kind and change it?

kind regards
Bernhard
What about your compile problems under gcc ?
BBauer
Posts: 658
Joined: Wed Mar 08, 2006 8:58 pm

Re: Stockfish Maximum Hash Size

Post by BBauer »

I have no compile problems under gcc.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Stockfish Maximum Hash Size

Post by mcostalba »

BBauer wrote:I have no compile problems under gcc.
yes, sorry it was intel.

What about your compile problems with icc ?
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Stockfish Maximum Hash Size

Post by zullil »

mcostalba wrote:
zullil wrote:I should have linked to this post by Bob Hyatt, which led to my question.
Hi Louis,

could you please try the following patch and tell me if it works ? Now you should set up to 8GB (8192).

Code: Select all

Date&#58; Mon, 1 Feb 2010 12&#58;12&#58;41 +0100
Subject&#58; &#91;PATCH&#93; Extend maximum hash size to 8 GB

---
 src/tt.cpp        |    4 ++--
 src/tt.h          |    2 +-
 src/ucioption.cpp |    2 +-
 3 files changed, 4 insertions&#40;+), 4 deletions&#40;-)

diff --git a/src/tt.cpp b/src/tt.cpp
index 1b2ae72..1fa60b1 100644
--- a/src/tt.cpp
+++ b/src/tt.cpp
@@ -55,9 +55,9 @@ TranspositionTable&#58;&#58;~TranspositionTable&#40;) &#123;
 
 void TranspositionTable&#58;&#58;set_size&#40;unsigned mbSize&#41; &#123;
 
-  assert&#40;mbSize >= 4 && mbSize <= 2048&#41;;
+  assert&#40;mbSize >= 4 && mbSize <= 8192&#41;;
 
-  unsigned newSize = 1024;
+  size_t newSize = 1024;
 
   // We store a cluster of ClusterSize number of TTEntry for each position
   // and newSize is the maximum number of storable positions.
diff --git a/src/tt.h b/src/tt.h
index 5d0df72..c3017c6 100644
--- a/src/tt.h
+++ b/src/tt.h
@@ -114,7 +114,7 @@ private&#58;
   unsigned writes; // heavy SMP read/write access here
   unsigned char pad_after&#91;64&#93;;
 
-  unsigned size;
+  size_t size;
   TTCluster* entries;
   uint8_t generation;
 &#125;;
diff --git a/src/ucioption.cpp b/src/ucioption.cpp
index 0f9c2f8..9fc1f41 100644
--- a/src/ucioption.cpp
+++ b/src/ucioption.cpp
@@ -123,7 +123,7 @@ namespace &#123;
     o&#91;"Minimum Split Depth"&#93; = Option&#40;4, 4, 7&#41;;
     o&#91;"Maximum Number of Threads per Split Point"&#93; = Option&#40;5, 4, 8&#41;;
     o&#91;"Threads"&#93; = Option&#40;1, 1, THREAD_MAX&#41;;
-    o&#91;"Hash"&#93; = Option&#40;32, 4, 2048&#41;;
+    o&#91;"Hash"&#93; = Option&#40;32, 4, 8192&#41;;
     o&#91;"Clear Hash"&#93; = Option&#40;false, BUTTON&#41;;
     o&#91;"New Game"&#93; = Option&#40;false, BUTTON&#41;;
     o&#91;"Ponder"&#93; = Option&#40;true&#41;;
-- 
1.6.5.1.1367.gcd48
Hi Marco,

I applied the patch, but it does not work. Choosing a Hash value above 2048 reserves the same amount of memory for Stockfish that Hash=2048 does. Choosing Hash=4096 reserves just 16M.

I'm using top to monitor memory usage, and all seems to work right if Hash <= 2048.

I have 6GB ram, so I did not try Hash > 4096.

Louis
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Stockfish Maximum Hash Size

Post by mcostalba »

zullil wrote: I applied the patch, but it does not work.
Sorry to bother you but I don't have 2GB nor 64 bit PC so I cannot properly test myself.

Please add the following of top of previous patch:

Code: Select all

--- a/src/tt.cpp
+++ b/src/tt.cpp
@@ -53,7 +53,7 @@ TranspositionTable&#58;&#58;~TranspositionTable&#40;) &#123;
 /// TranspositionTable&#58;&#58;set_size sets the size of the transposition table,
 /// measured in megabytes.
 
-void TranspositionTable&#58;&#58;set_size&#40;unsigned mbSize&#41; &#123;
+void TranspositionTable&#58;&#58;set_size&#40;size_t mbSize&#41; &#123;
 
   assert&#40;mbSize >= 4 && mbSize <= 8192&#41;;
 
diff --git a/src/tt.h b/src/tt.h
index c3017c6..2b2ce60 100644
--- a/src/tt.h
+++ b/src/tt.h
@@ -95,7 +95,7 @@ class TranspositionTable &#123;
 public&#58;
   TranspositionTable&#40;);
   ~TranspositionTable&#40;);
-  void set_size&#40;unsigned mbSize&#41;;
+  void set_size&#40;size_t mbSize&#41;;
   void clear&#40;);
   void store&#40;const Key posKey, Value v, ValueType type, Depth d, Move m&#41;;
   TTEntry* retrieve&#40;const Key posKey&#41; const;