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 stack-allocated span for search movegen #551

Merged
merged 7 commits into from
Jan 4, 2024
Merged

Conversation

eduherminio
Copy link
Member

@eduherminio eduherminio commented Dec 27, 2023

Elo   | -0.46 +- 4.01 (95%)
SPRT  | 8.0+0.08s Threads=1 Hash=32MB
LLR   | -2.27 (-2.25, 2.89) [0.00, 5.00]
Games | N: 17486 W: 5311 L: 5334 D: 6841
Penta | [662, 2010, 3404, 2023, 644]
https://openbench.lynx-chess.com/test/31/
Elo   | 4.11 +- 5.59 (95%)
SPRT  | 40.0+0.40s Threads=1 Hash=128MB
LLR   | 2.91 (-2.25, 2.89) [-5.00, 0.00]
Games | N: 8284 W: 2364 L: 2266 D: 3654
Penta | [236, 952, 1683, 1020, 251]
https://openbench.lynx-chess.com/test/33/
`BenchUCI` BDN benchmark: noticeable improvement

Before:

BenchmarkDotNet v0.13.11, Ubuntu 22.04.3 LTS (Jammy Jellyfish)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.5[310](https://github.com/lynx-chess/Lynx/actions/runs/7334435367/job/19971116018#step:7:311)3), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2

| Method             | Mean     | Error    | StdDev   | Allocated |
|------------------- |---------:|---------:|---------:|----------:|
| Bench_DefaultDepth | 540.0 ms | 11.21 ms | 33.07 ms | 329.53 MB |


BenchmarkDotNet v0.13.11, Windows 10 (10.0.20348.2159) (Hyper-V)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2

| Method             | Mean     | Error    | StdDev   | Median   | Gen0      | Gen1      | Gen2      | Allocated |
|------------------- |---------:|---------:|---------:|---------:|----------:|----------:|----------:|----------:|
| Bench_DefaultDepth | 442.3 ms | 10.02 ms | 28.76 ms | 453.8 ms | 5000.0000 | 1000.0000 | 1000.0000 | 329.54 MB |

BenchmarkDotNet v0.13.11, macOS Monterey 12.7.2 (21G1974) [Darwin 21.6.0]
Intel Xeon CPU E5-1650 v2 3.50GHz (Max: 3.34GHz), 1 CPU, 3 logical and 3 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX

| Method             | Mean     | Error    | StdDev   | Median   | Gen0       | Gen1      | Gen2      | Allocated |
|------------------- |---------:|---------:|---------:|---------:|-----------:|----------:|----------:|----------:|
| Bench_DefaultDepth | 704.5 ms | 25.91 ms | 73.08 ms | 669.5 ms | 13000.0000 | 2000.0000 | 1000.0000 | 329.57 MB |

After:
Significatively better in Windows, better in Linux, cannot really compare in macOS due to different machine specs

BenchmarkDotNet v0.13.11, Ubuntu 22.04.3 LTS (Jammy Jellyfish)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.5[310](https://github.com/lynx-chess/Lynx/actions/runs/7334455240/job/19971159680#step:7:311)3), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2

| Method             | Mean     | Error    | StdDev   | Allocated |
|------------------- |---------:|---------:|---------:|----------:|
| Bench_DefaultDepth | 519.8 ms | 11.03 ms | 32.19 ms | 313.33 MB |

BenchmarkDotNet v0.13.11, Windows 10 (10.0.20348.2159) (Hyper-V)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2

| Method             | Mean     | Error   | StdDev  | Gen0      | Gen1      | Gen2      | Allocated |
|------------------- |---------:|--------:|--------:|----------:|----------:|----------:|----------:|
| Bench_DefaultDepth | 375.1 ms | 4.23 ms | 3.30 ms | 4000.0000 | 1000.0000 | 1000.0000 | 313.34 MB |


BenchmarkDotNet v0.13.11, macOS Monterey 12.7.2 (21G1974) [Darwin 21.6.0]
Intel Core i7-8700B CPU 3.20GHz (Max: 3.19GHz) (Coffee Lake), 1 CPU, 4 logical and 4 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method             | Mean     | Error    | StdDev   | Gen0       | Gen1      | Gen2      | Allocated |
|------------------- |---------:|---------:|---------:|-----------:|----------:|----------:|----------:|
| Bench_DefaultDepth | 777.0 ms | 33.12 ms | 96.09 ms | 10000.0000 | 2000.0000 | 1000.0000 | 313.36 MB |
Perft: ~10% speedup

Before:

Run dotnet run -c Release --no-build "position fen r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1" "perft 5" "quit"
Lynx 1.1.0 by Eduardo Caceres
Depth:	5
Nodes:	193690690
Time:	10.05 s
nps:	19.266 Mnps

After:
+11.41% speed

Run dotnet run -c Release --no-build "position fen r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1" "perft 5" "quit"
Lynx 1.1.0 by Eduardo Caceres
Depth:	5
Nodes:	193690690
Time:	9.02 s
nps:	21.464 Mnps

@eduherminio eduherminio changed the title Use stack-allocated span for search movegen ⚡ Use stack-allocated span for search movegen Jan 3, 2024
@eduherminio eduherminio marked this pull request as ready for review January 3, 2024 14:51
@eduherminio eduherminio merged commit 34e4a2b into main Jan 4, 2024
21 checks passed
@eduherminio eduherminio deleted the movegen/span branch January 4, 2024 01:15
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.

1 participant