mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
Some more work on FullThreats::make_index
[Passed STC](https://tests.stockfishchess.org/tests/live_elo/691fc321acb6dbdf23d07e4b): ``` LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 215360 W: 55651 L: 55108 D: 104601 Ptnml(0-2): 520, 22399, 61290, 22960, 511 ``` This PR is on top of ces42's work so I'll rebase if that PR changes. Essentially, it comprises my adjustments to `make_index` that remained unmerged before threat inputs was finalized. The unsigned intermediate variables let us skip a bunch of useless sign extensions (because Square and Piece inherit from `int8_t`, and C/C++ semantics require narrow integers to be promoted to `int` before doing arithmetic on them). Additionally, by removing the special usage of `offsets[][64]` and `[65]` the indexing becomes more efficient. (This usage was a temporary hack from sscg anyway, so I think he'll like that it's gone.) Finally, the `sf_assume` condition was fixed so that it actually makes a difference to the compiler. The speedup is fairly nice locally (combining both ces42's and these changes): ``` Result of 100 runs ================== base (...kfish.master) = 1691982 +/- 1907 test (./stockfish ) = 1714349 +/- 1789 diff = +22367 +/- 2465 speedup = +0.0132 P(speedup > 0) = 1.0000 ``` closes https://github.com/official-stockfish/Stockfish/pull/6445 No functional change
This commit is contained in:
committed by
Disservin
parent
93f2d14d95
commit
f4244e13e4
+2
-6
@@ -295,18 +295,14 @@ struct DirtyPiece {
|
||||
struct DirtyThreat {
|
||||
DirtyThreat() { /* don't initialize data */ }
|
||||
DirtyThreat(Piece pc, Piece threatened_pc, Square pc_sq, Square threatened_sq, bool add) {
|
||||
data = (add << 28) | (pc << 20) | (threatened_pc << 16) | (threatened_sq << 8) | (pc_sq);
|
||||
data = (add << 31) | (pc << 20) | (threatened_pc << 16) | (threatened_sq << 8) | (pc_sq);
|
||||
}
|
||||
|
||||
Piece pc() const { return static_cast<Piece>(data >> 20 & 0xf); }
|
||||
Piece threatened_pc() const { return static_cast<Piece>(data >> 16 & 0xf); }
|
||||
Square threatened_sq() const { return static_cast<Square>(data >> 8 & 0xff); }
|
||||
Square pc_sq() const { return static_cast<Square>(data & 0xff); }
|
||||
bool add() const {
|
||||
uint32_t b = data >> 28;
|
||||
sf_assume(b == 0 || b == 1);
|
||||
return b;
|
||||
}
|
||||
bool add() const { return data >> 31; }
|
||||
|
||||
private:
|
||||
uint32_t data;
|
||||
|
||||
Reference in New Issue
Block a user