Skip to content

Commit

Permalink
Try another opt
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 26, 2023
1 parent b4068ff commit 91a999d
Showing 1 changed file with 25 additions and 42 deletions.
67 changes: 25 additions & 42 deletions src/Lynx.Benchmark/SkipLocalsInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ public ulong AttackGenerator_Original()
var PawnAttacks = SkipLocalsInit_AttackGenerator_Original.InitializePawnAttacks();
var KnightAttacks = SkipLocalsInit_AttackGenerator_Original.InitializeKnightAttacks();

var bishopOcuppancy = SkipLocalsInit_AttackGenerator_Original.InitializeBishopOccupancy();
var rookOcuppancy = SkipLocalsInit_AttackGenerator_Original.InitializeRookOccupancy();

(var _bishopOccupancyMasks, var _bishopAttacks) = SkipLocalsInit_AttackGenerator_Original.InitializeBishopMagicAttacks();
(var _rookOccupancyMasks, var _rookAttacks) = SkipLocalsInit_AttackGenerator_Original.InitializeRookMagicAttacks();

return KingAttacks[0] ^ PawnAttacks[0, 0] ^ KnightAttacks[0] ^ _bishopOccupancyMasks[0] ^ _rookOccupancyMasks[0] ^ _bishopAttacks[0, 0] ^ _rookAttacks[0, 0];
return KingAttacks[0] ^ PawnAttacks[0, 0] ^ KnightAttacks[0] ^ _bishopOccupancyMasks[0]
^ _rookOccupancyMasks[0] ^ _bishopAttacks[0, 0] ^ _rookAttacks[0, 0]
^ bishopOcuppancy[0] ^ rookOcuppancy[0];
}

[Benchmark]
Expand All @@ -30,10 +35,15 @@ public ulong AttackGenerator_SkipLocalsInit()
var PawnAttacks = SkipLocalsInit_AttackGenerator_SkipLocalsInit.InitializePawnAttacks();
var KnightAttacks = SkipLocalsInit_AttackGenerator_SkipLocalsInit.InitializeKnightAttacks();

var bishopOcuppancy = SkipLocalsInit_AttackGenerator_SkipLocalsInit.InitializeBishopOccupancy();
var rookOcuppancy = SkipLocalsInit_AttackGenerator_SkipLocalsInit.InitializeRookOccupancy();

(var _bishopOccupancyMasks, var _bishopAttacks) = SkipLocalsInit_AttackGenerator_SkipLocalsInit.InitializeBishopMagicAttacks();
(var _rookOccupancyMasks, var _rookAttacks) = SkipLocalsInit_AttackGenerator_SkipLocalsInit.InitializeRookMagicAttacks();

return KingAttacks[0] ^ PawnAttacks[0, 0] ^ KnightAttacks[0] ^ _bishopOccupancyMasks[0] ^ _rookOccupancyMasks[0] ^ _bishopAttacks[0, 0] ^ _rookAttacks[0, 0];
return KingAttacks[0] ^ PawnAttacks[0, 0] ^ KnightAttacks[0] ^ _bishopOccupancyMasks[0]
^ _rookOccupancyMasks[0] ^ _bishopAttacks[0, 0] ^ _rookAttacks[0, 0]
^ bishopOcuppancy[0] ^ rookOcuppancy[0];
}

private static class SkipLocalsInit_AttackGenerator_Original
Expand Down Expand Up @@ -789,7 +799,6 @@ private static class SkipLocalsInit_AttackGenerator_SkipLocalsInit
/// <summary>
/// BitBoard[isWhite, square]
/// </summary>
[SkipLocalsInit]
public static BitBoard[,] InitializePawnAttacks()
{
BitBoard[,] pawnAttacks = new BitBoard[2, 64];
Expand All @@ -803,63 +812,38 @@ private static class SkipLocalsInit_AttackGenerator_SkipLocalsInit
return pawnAttacks;
}

[SkipLocalsInit]
public static BitBoard[] InitializeKnightAttacks()
{
BitBoard[] knightAttacks = new BitBoard[64];

for (int square = 0; square < 64; ++square)
{
knightAttacks[square] = MaskKnightAttacks(square);
}

return knightAttacks;
return Enumerable.Range(0, 64)
.Select(MaskKnightAttacks)
.ToArray();
}

[SkipLocalsInit]
public static BitBoard[] InitializeKingAttacks()
{
BitBoard[] kingAttacks = new BitBoard[64];

for (int square = 0; square < 64; ++square)
{
kingAttacks[square] = MaskKingAttacks(square);
}

return kingAttacks;
return Enumerable.Range(0, 64)
.Select(MaskKingAttacks)
.ToArray();
}

[SkipLocalsInit]
public static BitBoard[] InitializeBishopOccupancy()
¡ public static BitBoard[] InitializeBishopOccupancy()

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (ubuntu-latest, LongRunning)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (ubuntu-latest, LongRunning)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (ubuntu-latest, LongRunning)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (ubuntu-latest, LongRunning)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (ubuntu-latest, Perft)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (ubuntu-latest, Perft)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (ubuntu-latest, Perft)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (ubuntu-latest, Perft)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, ubuntu-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, ubuntu-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, ubuntu-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, ubuntu-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / winning-at-chess (ubuntu-latest, WinningAtChess_FixedTime)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / winning-at-chess (ubuntu-latest, WinningAtChess_FixedTime)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / winning-at-chess (ubuntu-latest, WinningAtChess_FixedTime)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / winning-at-chess (ubuntu-latest, WinningAtChess_FixedTime)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, ubuntu-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, ubuntu-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, ubuntu-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, ubuntu-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-latest, LongRunning)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-latest, LongRunning)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-latest, LongRunning)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-latest, LongRunning)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (windows-latest, LongRunning)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (windows-latest, LongRunning)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (windows-latest, LongRunning)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (windows-latest, LongRunning)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (ubuntu-latest, Configuration)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (ubuntu-latest, Configuration)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (ubuntu-latest, Configuration)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (ubuntu-latest, Configuration)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (ubuntu-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (ubuntu-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (ubuntu-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (ubuntu-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (windows-latest, Perft)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (windows-latest, Perft)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (windows-latest, Perft)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (windows-latest, Perft)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (windows-latest, Configuration)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (windows-latest, Configuration)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (windows-latest, Configuration)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (windows-latest, Configuration)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, windows-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, windows-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, windows-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, windows-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, windows-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, windows-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, windows-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, windows-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-latest, Configuration)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-latest, Configuration)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-latest, Configuration)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-latest, Configuration)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (macOS-latest, Perft)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (macOS-latest, Perft)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (macOS-latest, Perft)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / perft-tests (macOS-latest, Perft)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (macOS-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (macOS-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (macOS-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (macOS-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (windows-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (windows-latest)

Invalid token '¡' in class, record, struct, or interface member declaration

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (windows-latest)

Unexpected character '¡'

Check failure on line 829 in src/Lynx.Benchmark/SkipLocalsInit.cs

View workflow job for this annotation

GitHub Actions / benchmark (windows-latest)

Invalid token '¡' in class, record, struct, or interface member declaration
{
BitBoard[] bishopAttacks = new BitBoard[64];

for (int square = 0; square < 64; ++square)
{
bishopAttacks[square] = MaskBishopOccupancy(square);
}

return bishopAttacks;
return Enumerable.Range(0, 64)
.Select(MaskBishopOccupancy)
.ToArray();
}

[SkipLocalsInit]
public static BitBoard[] InitializeRookOccupancy()
{
BitBoard[] rookAttacks = new BitBoard[64];

for (int square = 0; square < 64; ++square)
{
rookAttacks[square] = MaskRookOccupancy(square);
}

return rookAttacks;
return Enumerable.Range(0, 64)
.Select(MaskRookOccupancy)
.ToArray();
}

/// <summary>
/// Returns bishop occupancy masks and attacks
/// </summary>
/// <returns>(BitBoard[64], BitBoard[64, 512])</returns>
[SkipLocalsInit]
public static (BitBoard[] BishopOccupancyMasks, BitBoard[,] BishopAttacks) InitializeBishopMagicAttacks()
{
BitBoard[] occupancyMasks = new BitBoard[64];
Expand Down Expand Up @@ -890,7 +874,6 @@ public static (BitBoard[] BishopOccupancyMasks, BitBoard[,] BishopAttacks) Initi
/// Returns rook occupancy masks and attacks
/// </summary>
/// <returns>(BitBoard[64], BitBoard[64, 512])</returns>
[SkipLocalsInit]
public static (BitBoard[] RookOccupancyMasks, BitBoard[,] RookAttacks) InitializeRookMagicAttacks()
{
BitBoard[] occupancyMasks = new BitBoard[64];
Expand Down

0 comments on commit 91a999d

Please sign in to comment.