Starting with Hash Tables.

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Starting with Hash Tables.

Post by Luis Babboni »

Hi people, thanks for let me bother you again! :wink:

Next step in Soberango developement is to add hash tables.

I read the chessprogramming site and seems I understand the idea of them.

My first question is cause I use to read in tournament details for example, that are allowed hash tables of determined size.
Here about CCRL test conditions for example:
Hash size: Should be set to the same value of either 128 or 256 MB for all engines in a match or tourney. There are two exeptions: 1) Engines using 2 CPUs should have double hash size, compared to single-CPU engines in the same tourney. 4-CPU engines should have 4 times amount of hash. 2) Smaller hash size can be used if an engine has problems with particular hash size, or if it does not allow to configure hash size.

An engine must have a parameter able to be adjusted to the size required?
As I said before, I´m not a programming guy and I´m using FreeBasic for programming my engine, I could just dimension a matrix taking care of not exceed that size allowed and use it as my hash table? I mean, surely there are better ways to do it, but could this be one possible way?
The size of the main engine is always far less than a hash tables and that´s why hash tables sizes are stablisehd but engine exes size not?

Sorry for my ignorance! :oops:
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 4:48 am

Re: Starting with Hash Tables.

Post by kbhearn »

In BASIC you'd use 'redim' instead of 'dim' to define a variable sized array. at first you can just size it to an ok size that won't exceed your memory, and then later define the set hash command for whatever protocol you're using to change the size which is just another redim statement with the new size
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Starting with Hash Tables.

Post by Luis Babboni »

kbhearn wrote:In BASIC you'd use 'redim' instead of 'dim' to define a variable sized array. at first you can just size it to an ok size that won't exceed your memory, and then later define the set hash command for whatever protocol you're using to change the size which is just another redim statement with the new size
Thanks Kevin!

"your memory" is that´s the rules of the tournament or test says?
Robert Pope
Posts: 558
Joined: Sat Mar 25, 2006 8:27 pm

Re: Starting with Hash Tables.

Post by Robert Pope »

By "your memory", I think he means if your computer has 4GB of memory, don't set up an 8GB hash table. It needs to comfortably fit in RAM at the same time as the opponent's memory usage.

You are just getting started here - just hard code a mid-size/small table (512MB - 1GB) that works for your computer and get to work on it. That's well below most people's limits, and you can worry about re-sizing after you have it working.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Starting with Hash Tables.

Post by Luis Babboni »

Robert Pope wrote:By "your memory", I think he means if your computer has 4GB of memory, don't set up an 8GB hash table. It needs to comfortably fit in RAM at the same time as the opponent's memory usage.

You are just getting started here - just hard code a mid-size/small table (512MB - 1GB) that works for your computer and get to work on it. That's well below most people's limits, and you can worry about re-sizing after you have it working.
Understood!! I think! :P
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Starting with Hash Tables.

Post by hgm »

small = 16MB. large = 256MB.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Starting with Hash Tables.

Post by Ras »

hgm wrote:small = 16MB. large = 256MB.
256MB is large? In DeepShredder, I'm using 2GB of hash tables, and in multivariant analysis, my 6-core fills them up within some minutes.

Then again, 16MB isn't that small either - the CT800 has 120kB of hash tables, and the Chess Genius Pro probably even less. ;-)
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Starting with Hash Tables.

Post by hgm »

Most computers that are around probably do not have more than 1GB RAM. Playing two engines against each other with 256MB each might already be too taxing.

Not everyone buys a new computer every year...
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Starting with Hash Tables.

Post by Ras »

hgm wrote:Most computers that are around probably do not have more than 1GB RAM.
Uhm.. even my somewhat crappy netbook from 2010 has 2GB.
Not everyone buys a new computer every year...
The desktop 6-core machine I'm using for chess analysis is also from 2010 and has 16 GB RAM. Pretty much any computer delivered after 2010 should have at least 4 GB (except for somewhat crappy netbooks, of course).
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Starting with Hash Tables.

Post by hgm »

Well, crappy netbooks are cheap, so many people buy them. And the technical life time of laptops that are not used very intensively can easily be more than 6 years.

Even with 4GB running 4 games in parallel with 256MB hash for each egine would consume more than half the memory, and could already cause problems if you have other stuff open as well.