Skip to content

Commit

Permalink
⚡ Use Bmi1.X64.TrailingZeroCount and Popcnt.X64.PopCount hardware…
Browse files Browse the repository at this point in the history
… intrinsics (#330)
  • Loading branch information
eduherminio committed Aug 12, 2023
1 parent 1d2ef77 commit 519d693
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Lynx/Model/BitBoard.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics.X86;

#pragma warning disable S4136

Expand Down Expand Up @@ -121,6 +122,11 @@ public static int GetLS1BIndex(this BitBoard board)
{
Utils.Assert(board != default);

if (Bmi1.X64.IsSupported)
{
return (int)Bmi1.X64.TrailingZeroCount(board);
}

return BitOperations.TrailingZeroCount(board);
}

Expand Down Expand Up @@ -149,6 +155,11 @@ public static void ResetLS1B(this ref BitBoard board)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CountBits(this BitBoard board)
{
if (Popcnt.X64.IsSupported)
{
return (int)Popcnt.X64.PopCount(board);
}

return BitOperations.PopCount(board);
}

Expand Down

2 comments on commit 519d693

@eduherminio
Copy link
Member Author

Choose a reason for hiding this comment

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

120+1, 256MB hash

Rank Name                          Elo     +/-   Games    Wins  Losses   Draws   Points   Score    Draw   White   Black
   0 Lynx 1186 - main               93      12    2570    1318     648     604   1620.0   63.0%   23.5%   64.7%   61.4%
   1 BBC 1.1                        30      37     286     129     104      53    155.5   54.4%   18.5%   53.5%   55.2%
   2 Cadabra 2.0.0                   5      36     286     115     111      60    145.0   50.7%   21.0%   55.2%   46.2%
   3 Zeta Dva 0310                  -1      36     286     114     115      57    142.5   49.8%   19.9%   52.1%   47.6%
   4 AdaChess 3.6                  -74      30     286      47     107     132    113.0   39.5%   46.2%   42.0%   37.1%
   5 MinimalChess 0.4.1            -81      36     284      75     140      69    109.5   38.6%   24.3%   41.9%   35.2%
   6 BBC 1.0                       -95      36     286      69     145      72    105.0   36.7%   25.2%   40.9%   32.5%
   7 Rustic 2                     -131      38     286      64     167      55     91.5   32.0%   19.2%   32.9%   31.1%
   8 Lynx 0.14.1                  -240      38     286      18     189      79     57.5   20.1%   27.6%   17.1%   23.1%
   9 Rustic 1.1                   -368      58     284      17     240      27     30.5   10.7%    9.5%   12.0%    9.5%

Ordo:

   # PLAYER                :  RATING  POINTS  PLAYED   (%)
   1 BBC 1.1               :  2132.0   155.5     286    54
   2 Cadabra 2.0.0         :  2072.0   145.0     286    51
   3 Lynx 1186 - main      :  2037.7  1623.0    2574    63
   4 BBC 1.0               :  1986.0   105.0     286    37
   5 AdaChess 3.6          :  1985.0   113.0     286    40
   6 MinimalChess 0.4.1    :  1927.0   110.5     286    39
   7 Zeta Dva 0310         :  1926.0   142.5     286    50
   8 Rustic 2              :  1852.0    91.5     286    32
   9 Lynx 0.14.1           :  1806.0    57.5     286    20
  10 Rustic 1.1            :  1697.0    30.5     286    11

White advantage = 13.63
Draw rate (equal opponents) = 50.00 %

@eduherminio
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated:

Rank Name                          Elo     +/-   Games    Wins  Losses   Draws   Points   Score    Draw   White   Black
   0 Lynx 1186 - main               94      11    2967    1534     749     684   1876.0   63.2%   23.1%   64.5%   61.9%
   1 BBC 1.1                        35      34     330     151     118      61    181.5   55.0%   18.5%   53.0%   57.0%
   2 Cadabra 2.0.0                  11      33     330     135     125      70    170.0   51.5%   21.2%   56.1%   47.0%
   3 Zeta Dva 0310                   1      34     330     132     131      67    165.5   50.2%   20.3%   50.9%   49.4%
   4 AdaChess 3.6                  -76      28     331      54     125     152    130.0   39.3%   45.9%   41.3%   37.3%
   5 MinimalChess 0.4.1            -84      34     328      88     166      74    125.0   38.1%   22.6%   41.2%   35.1%
   6 BBC 1.0                       -95      33     330      79     167      84    121.0   36.7%   25.5%   40.0%   33.3%
   7 Rustic 2                     -143      36     330      71     200      59    100.5   30.5%   17.9%   31.2%   29.7%
   8 Lynx 0.14.1                  -247      36     330      20     222      88     64.0   19.4%   26.7%   17.0%   21.8%
   9 Rustic 1.1                   -378      55     328      19     280      29     33.5   10.2%    8.8%   11.9%    8.5%
   # PLAYER                :  RATING  POINTS  PLAYED   (%)
   1 BBC 1.1               :  2132.0   181.5     330    55
   2 Cadabra 2.0.0         :  2072.0   170.0     330    52
   3 Lynx 1186 - main      :  2039.0  1876.0    2967    63
   4 BBC 1.0               :  1986.0   121.0     330    37
   5 AdaChess 3.6          :  1985.0   130.0     331    39
   6 MinimalChess 0.4.1    :  1927.0   125.0     328    38
   7 Zeta Dva 0310         :  1926.0   165.5     330    50
   8 Rustic 2              :  1852.0   100.5     330    30
   9 Lynx 0.14.1           :  1806.0    64.0     330    19
  10 Rustic 1.1            :  1697.0    33.5     328    10

White advantage = 10.87
Draw rate (equal opponents) = 50.00 %

Please sign in to comment.