Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Use Unsafe.Add for PSQT() #1153

Merged
merged 1 commit into from
Nov 12, 2024
Merged

⚡ Use Unsafe.Add for PSQT() #1153

merged 1 commit into from
Nov 12, 2024

Conversation

eduherminio
Copy link
Member

@eduherminio eduherminio commented Nov 12, 2024

  • Use Unsafe.Add to properly avoid bound checks when querying PSQTs (if we're going unsafe, let's do it 'right' in the most performant way)
  • Add Assert to for manually verify bounds in debug mode

Part of planned https://github.com/lynx-chess/Backlog/issues/300, and was brought up again by @tannergooding in C# Discord while reviewing unsafe usage 😻

Test  | perft/psqt-unsafe-add
Elo   | 4.30 +- 4.08 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=32MB
LLR   | 2.95 (-2.25, 2.89) [-3.00, 1.00]
Games | 11646: +3304 -3160 =5182
Penta | [259, 1294, 2604, 1376, 290]
https://openbench.lynx-chess.com/test/935/

@eduherminio eduherminio marked this pull request as ready for review November 12, 2024 01:01
@eduherminio eduherminio merged commit e25b07c into main Nov 12, 2024
27 checks passed
@eduherminio eduherminio deleted the perft/psqt-unsafe-add branch November 12, 2024 01:09
Comment on lines 106 to 107
unsafe
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notably the unsafe { } is unnecessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants