Fathom icon indicating copy to clipboard operation
Fathom copied to clipboard

Optimized FEN-parsing a bit: +/- 50% faster.

Open ghost opened this issue 9 years ago • 6 comments

Tested by invoking it 100 million on a test-FEN ("1nbqkbnr/1Bpppppp/r7/p7/6P1/8/PPPPPP1P/RNBQK1NR b KQk - 10 1") and then comparing the value of white/black/kings/etc with those of the original code.

ghost avatar Dec 02 '15 12:12 ghost

Hi, I am wondering what is the use case or motivation behind this optimization? I did not consider there was any need to optimize the parse FEN function.

basil00 avatar Dec 03 '15 12:12 basil00

I made the code into a library which I call from my chess-program. I give it the position as a fen-string because I'm not using bitboards.

On Thu, Dec 3, 2015 at 1:16 PM, basil00 [email protected] wrote:

Hi, I am wondering what is the use case or motivation behind this optimization? I did not consider there was any need to optimize the parse FEN function.

— Reply to this email directly or view it on GitHub https://github.com/basil00/Fathom/pull/1#issuecomment-161618003.

www.vanheusden.com www.slimwinnen.nl | www.smartwinning.info

ghost avatar Dec 03 '15 12:12 ghost

Generating and then (re)parsing FEN strings sounds very inefficient! Would it not be better to generate the bitboards directly? It probably should not be that hard to do.

basil00 avatar Dec 03 '15 12:12 basil00

I would have to look into that.

But as your program already accepted a fen-string on the command-line, I also for that reason found a fen-string to most logical for a library.

I did not submit the changes for the library, can do if you like.

On Thu, Dec 3, 2015 at 1:21 PM, basil00 [email protected] wrote:

Generating and then (re)parsing FEN strings sounds very inefficient! Would it not be better to generate the bitboards directly? It probably should not be that hard to do.

— Reply to this email directly or view it on GitHub https://github.com/basil00/Fathom/pull/1#issuecomment-161618937.

www.vanheusden.com www.slimwinnen.nl | www.smartwinning.info

ghost avatar Dec 03 '15 12:12 ghost

Hi,

Please merge https://github.com/flok99/Fathom/commit/1015eceaa54658e45f0e7b8bb5eee86ba9a726bc

It allows you to compile it on non-x64.

On Thu, Dec 3, 2015 at 1:16 PM, basil00 [email protected] wrote:

Hi, I am wondering what is the use case or motivation behind this optimization? I did not consider there was any need to optimize the parse FEN function.

— Reply to this email directly or view it on GitHub https://github.com/basil00/Fathom/pull/1#issuecomment-161618003.

www.vanheusden.com www.slimwinnen.nl | www.smartwinning.info

ghost avatar Dec 30 '15 14:12 ghost

Using gcc extensions instead of x86 assembly is an improvement. But ideally we should make the code also portable to other compilers, e.g. msvc. I need to investigate the best way to do this.

basil00 avatar Jan 02 '16 10:01 basil00