Original Slider Lookup - by Hardware Synthesis

Discussion of chess software programming and technical issues.

Moderator: Ras

R. Tomasi
Posts: 307
Joined: Wed Sep 01, 2021 4:08 pm
Location: Germany
Full name: Roland Tomasi

Re: Original Slider Lookup - by Hardware Synthesis

Post by R. Tomasi »

Btw, espresso is truly interesting. I'll be honest and say that I do not really see the use-case, since - as you pointed out yourself - PEXT or magic bitboards are faster. What might be interesting to do, is to use the concept of espresso and do that completely within template logic, instead of having a program that generates C code. It should be possible to do, since template meta-programming is turing-complete. I just get nightmares when I think about the work that it probably needs to implement that :shock:
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Original Slider Lookup - by Hardware Synthesis

Post by dangi12012 »

R. Tomasi wrote: Fri Sep 24, 2021 12:39 am Btw, espresso is truly interesting. I'll be honest and say that I do not really see the use-case
The use case is every Truth Table tree where you dont know the optimal solution. Its easy for sliders as we already know what operations solve it in a good amount of time. But this software can solve any Truth table - of very hard functions which you maybe not even have thought of yet. In a space of 64 bits and above which is insane if you are used to solve tools that cant do more than 14 bits.

You can define the truth table for 16 bit multiplication and it will tell you the least amount of AND / OR / NOT operations that can do that. For multiplication the CPU Manufactureres did exactly that and the gates for that are hardwired in your CPU.
Chess problems are not solved in harwdware but the fastest operation you can do on your computer is AND/OR/NOT with 64 bits at once.

The last release was version 2.3 dated 1988 and now you can download a windows compatible version here:
https://github.com/Gigantua/Espresso


Dont try to understand the source code it would take years.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
klx
Posts: 179
Joined: Tue Jun 15, 2021 8:11 pm
Full name: Emanuel Torres

Re: Original Slider Lookup - by Hardware Synthesis

Post by klx »

dangi12012 wrote: Thu Sep 23, 2021 11:55 pm Boom you just saved 1 add instruction where the wiki told you "do it like that"
Are you joking with us or really this obtuse? You come here full of arrogance, claiming "novel" ideas which have been used by the industry for over a decade, saying things like you can execute 16 instructions per clock cycle, and it takes us real experts 20 seconds to optimize your code by 15% (yeah I benchmarked it).

Look, I say this with only good intentions: Forget about chess programming. Go back to what you did before. The two years you spent on this is not wasted time. Sure, the code can be flushed down the toilet, but consider this a learning opportunity.

Best of luck.

/Emanuel
[Moderation warning] This signature violated the rule against commercial exhortations.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Original Slider Lookup - by Hardware Synthesis

Post by dangi12012 »

klx wrote: Fri Sep 24, 2021 4:52 pm Are you joking with us or really this obtuse?
I think forum moderators should remove trolls from their online forums. I looked at your posts and 99% of your comments are very negative. Not only here. So you are on my ignore list. And btw. you joined this forum 1 year after me so I dont know what you are saying.


Anyways Espresso Heuristic Minimizer MSVC compatible can be downloaded:
https://github.com/Gigantua/Espresso
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
R. Tomasi
Posts: 307
Joined: Wed Sep 01, 2021 4:08 pm
Location: Germany
Full name: Roland Tomasi

Re: Original Slider Lookup - by Hardware Synthesis

Post by R. Tomasi »

dangi12012 wrote: Fri Sep 24, 2021 4:22 pm The use case is every Truth Table tree where you dont know the optimal solution. Its easy for sliders as we already know what operations solve it in a good amount of time. But this software can solve any Truth table - of very hard functions which you maybe not even have thought of yet. In a space of 64 bits and above which is insane if you are used to solve tools that cant do more than 14 bits.

You can define the truth table for 16 bit multiplication and it will tell you the least amount of AND / OR / NOT operations that can do that. For multiplication the CPU Manufactureres did exactly that and the gates for that are hardwired in your CPU.
Chess problems are not solved in harwdware but the fastest operation you can do on your computer is AND/OR/NOT with 64 bits at once.
Yes, I get that. That's certainly useful when designing hardware. But the use-case for chess-programming isn't clear to me. The 16bit multiplication example exactly falls into that category: why on earth would I want to implement a 16bit multiplaction with only basic logic operations, when I have a processor that can do it in hardware anyway? I simply fail to see what I gain from doing so. It's the exact reason why magic bitboards are faster than using espresso...

And how on earth can truth table functions be "very hard functions"? It's pure boolean logic, not anything involving recursion or higher math...
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Original Slider Lookup - by Hardware Synthesis

Post by dangi12012 »

R. Tomasi wrote: Fri Sep 24, 2021 6:24 pm Yes, I get that. That's certainly useful when designing hardware. But the use-case for chess-programming isn't clear to me. .
Its very clear. Any Binary mapping with dont cares - this tool can solve. If you want to implement chess in any fpga -> this tool is in your synthesizer. For x64 it can produce code.

For example De Bruijn Multiplication is a mapping from one set of value to another set of values. This tool is perfect for that and the result will be in terms of AND / OR / NOT. Which is generally faster than multiply but you need to benchmark.

For example why do we rotate whole boards to use this trick? https://www.chessprogramming.org/Subtra ... king_Piece
Only the 12 bits inside the blocking mask need to be oriented correctly. Hashing is one solution. A Binary Transform function (which this tool can generate) another solution. Solution 2 needs no array lookup.

This would generate a function which uses a minimal algorightm per square with and / or / not + occ^(occ-2slider). So no lookup and no comparisons. Just a few binary instructions - and certainly no slower mulitply etc.

The use cases are endless i dont understand how you dont see any usages here!
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
R. Tomasi
Posts: 307
Joined: Wed Sep 01, 2021 4:08 pm
Location: Germany
Full name: Roland Tomasi

Re: Original Slider Lookup - by Hardware Synthesis

Post by R. Tomasi »

dangi12012 wrote: Sat Sep 25, 2021 12:36 pm The use cases are endless i dont understand how you dont see any usages here!
Because the code it generates is only using basic logic operations. That's like going to war with archers only when you have attack helicopters at your disposal. Yes, the code is optimal in the sense that it will generate the best code with only those basic logic operations. But that will be slower than custom designed solutions in almost any use-case, since those will rely on the full arsenal of instructions that is available.

Edit: btw, putting stuff in bold always feels like you're shouting at the reader (similar to writing captial letters only). It makes my ears ring reading your posts - just a friendly advice.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Original Slider Lookup - by Hardware Synthesis

Post by dangi12012 »

I just stumbled to a perfect problem for it:
Generate the slider distance of two set bits in a bitboard.


So if pos would look like that:
oooooooo
oooXoooo
oooooooo
oooooooo
oooooooo
oooooooX
(Can someone tell me how I can post images of chessboards? I saw that many times. )

So normal code would first have to check if two bits are aligned like a rook or bishop and then the answer becomes:
_tzcnt(X) - tzcnt(PopLSB(X)) which would need 10 instructions at least in total.

Espresso logic heuristic minimizer would just need all valid inputs and the binary answer for that. For example 000 if they touch and 111 if they not aligned and the right distance elsewhere. The output will be the minimum term for each bit in the output.

Any function that takes bits as an input and produces bits as an output can be solved almost optimally with this tool! Chess just happens to be a 64bit or less input table.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
BrokenKeyboard
Posts: 24
Joined: Tue Mar 16, 2021 11:11 pm
Full name: Het Satasiya

Re: Original Slider Lookup - by Hardware Synthesis

Post by BrokenKeyboard »

You can use the "fen" button in the toolbar the same way you use the "code" button. and then you just copypaste the relevant fen into the blank.
klx
Posts: 179
Joined: Tue Jun 15, 2021 8:11 pm
Full name: Emanuel Torres

Re: Original Slider Lookup - by Hardware Synthesis

Post by klx »

dangi12012 wrote: Thu Sep 30, 2021 6:32 pm _tzcnt(X) - tzcnt(PopLSB(X))

Code: Select all

1. tzcnt(PopLSB(X)) => lzcnt(X)
2. lookuptable[tzcnt(X)][lzcnt(X)]
[Moderation warning] This signature violated the rule against commercial exhortations.