In my engine I have implemented plain Magic bitboard. I am curious on what performance I can expect if I use condense Fancy magic.
I realize its highly dependent on hardware...but just looking for a general ballpark of expected speed or ratio.
A related question...(this may be a dumb question)
But I am having difficult time of calculating mem sizes in arrays.
U64 mRookAttacks [64][4096]; // 2048K
My logic is 64 bits * 64 * 4096 = 16777216
16777216/8000=2097.152 KB
What am I doing wrong here?
Thanks in advance.
Regarding array size and speed...
Moderators: hgm, Rebel, chrisw
-
- Posts: 482
- Joined: Thu Oct 16, 2008 4:23 am
- Location: Milky Way
Re: Regarding array size and speed...
64/8 * 64 * 4096 = 2097.152 bytes16777216/8000=2097.152 KB
What am I doing wrong here?
Thanks in advance.
2097.152/1024 = 2048 KB
Is that what you mean?
Regards,
Ben-Hur Carlos Langoni Junior
http://sourceforge.net/projects/redqueenchess/
http://sourceforge.net/projects/redqueenchess/
-
- Posts: 154
- Joined: Tue May 17, 2011 8:12 pm
Re: Regarding array size and speed...
So 1KB = 1024 Bytes?
Also..both your formulas are off by a factor of 1000... not sure if that was intentional.
Bill
Also..both your formulas are off by a factor of 1000... not sure if that was intentional.
Bill
-
- Posts: 482
- Joined: Thu Oct 16, 2008 4:23 am
- Location: Milky Way
Re: Regarding array size and speed...
Yes, at least it used to be.voyagerOne wrote:
So 1KB = 1024 Bytes?
The multiples of the byte unit are power of 2: 2^10 bytes=1KB, 2^20 bytes = 1MB, etc...
I would suggest you reading a good book about programming and computer basics in case you are not very familiar with it.Also..both your formulas are off by a factor of 1000... not sure if that was intentional.
Bill
http://www.htdp.org/
Regards,
Ben-Hur Carlos Langoni Junior
http://sourceforge.net/projects/redqueenchess/
http://sourceforge.net/projects/redqueenchess/
-
- Posts: 6401
- Joined: Thu Mar 09, 2006 8:30 pm
- Location: Chicago, Illinois, USA
Re: Regarding array size and speed...
But it is not anymore!bhlangonijr wrote:Yes, at least it used to be.voyagerOne wrote:
So 1KB = 1024 Bytes?
Kilobyte = 1000 bytes
Kibibytes = 1024 bytes.
But programmers keep murdering the metric system.
http://en.wikipedia.org/wiki/Binary_prefix
At least it is not gallons, inches, or any of that crap
Miguel
The multiples of the byte unit are power of 2: 2^10 bytes=1KB, 2^20 bytes = 1MB, etc...
I would suggest you reading a good book about programming and computer basics in case you are not very familiar with it.Also..both your formulas are off by a factor of 1000... not sure if that was intentional.
Bill
http://www.htdp.org/
Regards,
-
- Posts: 482
- Joined: Thu Oct 16, 2008 4:23 am
- Location: Milky Way
Re: Regarding array size and speed...
As the twig is bent, so is the tree inclined...michiguel wrote:
But it is not anymore!
Kilobyte = 1000 bytes
Kibibytes = 1024 bytes.
But programmers keep murdering the metric system.
http://en.wikipedia.org/wiki/Binary_prefix
At least it is not gallons, inches, or any of that crap
Miguel
Ben-Hur Carlos Langoni Junior
http://sourceforge.net/projects/redqueenchess/
http://sourceforge.net/projects/redqueenchess/
-
- Posts: 155
- Joined: Mon Feb 15, 2010 9:33 am
- Location: New Zealand
Re: Regarding array size and speed...
The table below is from this thread:voyagerOne wrote:In my engine I have implemented plain Magic bitboard. I am curious on what performance I can expect if I use condense Fancy magic.
I realize its highly dependent on hardware...but just looking for a general ballpark of expected speed or ratio.
http://www.talkchess.com/forum/viewtopi ... ew=threads
Code: Select all
Times in ms for nominal 11 ply search with different BitBoard slider attack generators.
In each case a preliminary "warmup" run0 was discarded.
KB run1 run2 run3 minimum
plain magic (fixed-shift) 2304 3755 3756 3755 3755
fancy magic* 840 3764 3764 3762 3762
plain magic (var-shift) 2304 3810 3811 3810 3810
classic BB (branch-free) 4 4381 4381 4381 4381
classic BB 4 4871 4867 4867 4867
*from Crafty
-
- Posts: 154
- Joined: Tue May 17, 2011 8:12 pm
Re: Regarding array size and speed...
Last edited by voyagerOne on Sun Sep 25, 2011 4:45 am, edited 1 time in total.
-
- Posts: 154
- Joined: Tue May 17, 2011 8:12 pm
Re: Regarding array size and speed...
Code: Select all
import java.util.Random;
class test
{
static Random generator=new Random();
static byte[] bigArray=new byte[3200000];
static int[] bigArray=new int[3200000];
static long[] bigArray=new long[3200000];
public static void main(String args[])
{
popArr();
long time=System.currentTimeMillis();
func();
System.out.println(System.currentTimeMillis() - time);
}
static void func()
{
int n=bigArray.length;
for (int i=0; i < 100000000; i++)
{
if (bigArray[generator.nextInt(n)] == -1)
{
System.out.println("this should not happen");
break;
}
}
}
static void popArr()
{
for (int i=0; i < bigArray.length; i++)
{
bigArray[i]=generator.nextInt(255);
}
}
}
Here are the results.
Byte=3065 ms
int=5500 ms
long=7422 ms
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Regarding array size and speed...
Sorry, please do not take it personally, but I am really curious to know why beginners in computer chess / computer programming try to _optimize_ the stuff they write before to build up a working engine ?voyagerOne wrote: What am I doing wrong here?
I have read many times of people that is worried by a possible 2% speed increment or something similar when still misses a working alpha-beta searcher.
Could you please elaborate on why you are trying to optimize your functions before to have a working engine ? And with working I mean that is able to play legal chess in matches.