Skip to content

Commit

Permalink
🦈 IMP: Switch to BS Thread Pool Library
Browse files Browse the repository at this point in the history
--- STC ---
ELO   | 0.96 +- 2.62 (95%)
SPRT  | 10.0+0.10s Threads=1 Hash=16MB
LLR   | 2.97 (-2.94, 2.94) [-3.00, 1.00]
GAMES | N: 34984 W: 9105 L: 9008 D: 16871

--- LTC ---
ELO   | 0.96 +- 2.52 (95%)
SPRT  | 60.0+0.60s Threads=1 Hash=256MB
LLR   | 3.02 (-2.94, 2.94) [-3.00, 1.00]
GAMES | N: 35464 W: 8669 L: 8571 D: 18224

Bench: 7025779
  • Loading branch information
TheBlackPlague authored Aug 17, 2023
1 parent 506b346 commit 0faabb5
Show file tree
Hide file tree
Showing 9 changed files with 919 additions and 75 deletions.
20 changes: 8 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,7 @@ endforeach()

include(${CPM_DOWNLOAD_LOCATION})

CPMAddPackage("gh:TheBlackPlague/MantaRay#6911ba4b35fed878ba31361ca33020073adf4543")
CPMAddPackage(
NAME thread-pool
GITHUB_REPOSITORY DeveloperPaul123/thread-pool
GIT_TAG 0.5.1
OPTIONS
"TP_BUILD_TESTS OFF"
"TP_BUILD_BENCHMARKS OFF"
"TP_BUILD_EXAMPLES OFF"
)
CPMAddPackage("gh:TheBlackPlague/MantaRay#4038386a746ae65881e7d1f02673e1805f729cc9")

include(BinaryResource.cmake)

Expand All @@ -94,7 +85,8 @@ file(GLOB StockDoryEngineType
"src/Engine/*.h")

file(GLOB StockDoryExternalType
"src/External/*.h")
"src/External/*.h"
"src/External/thread_pool.hpp")

file(GLOB StockDoryFrontendType
"src/Terminal/UI/*.h"
Expand All @@ -107,4 +99,8 @@ add_executable(StockDory src/Terminal/main.cpp

target_include_directories(StockDory PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")

target_link_libraries(StockDory MantaRay dp::thread-pool)
target_link_libraries(StockDory MantaRay)

if(NOT WIN32)
target_link_libraries(StockDory pthread)
endif()
4 changes: 2 additions & 2 deletions src/Backend/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#ifndef STOCKDORY_THREADPOOL_H
#define STOCKDORY_THREADPOOL_H

#include <thread_pool/thread_pool.h>
#include "../External/thread_pool.hpp"

namespace StockDory
{

dp::thread_pool<> ThreadPool;
BS::thread_pool ThreadPool;

} // StockDory

Expand Down
8 changes: 8 additions & 0 deletions src/Backend/TranspositionTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include <algorithm>
#include <execution>

#ifdef __x86_64__
#include <xmmintrin.h>
#endif

#include "Type/Zobrist.h"

Expand Down Expand Up @@ -57,7 +59,13 @@ namespace StockDory

inline void Prefetch(const ZobristHash hash) const
{
#ifdef __x86_64__
_mm_prefetch(reinterpret_cast<const char*>(&Internal[fastrange64(hash, Count)]), _MM_HINT_T0);
#else
#ifdef __aarch64__
__builtin_prefetch(reinterpret_cast<const char*>(&Internal[fastrange64(hash, Count)]), 0, 3);
#endif
#endif
}

[[nodiscard]]
Expand Down
12 changes: 7 additions & 5 deletions src/Backend/Type/BitBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ class BitBoardIterator
return static_cast<Square>(i);
}

inline std::vector<Square> Values()
template<size_t N>
inline uint8_t ToArray(std::array<Square, N>& array)
{
uint8_t count = Count(BB);
std::vector<Square> v (count);
const uint8_t count = Count(BB);

for (uint8_t i = 0; i < count; i++) v[i] = Value();
assert(N >= count);

return v;
for (uint8_t i = 0; i < count; i++) array[i] = Value();

return count;
}

};
Expand Down
4 changes: 0 additions & 4 deletions src/Engine/Time/TimeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ namespace StockDory
constexpr static uint8_t IncrementPartitionNumerator = 3;
constexpr static uint8_t IncrementPartitionDenominator = 4;

constexpr static uint8_t PieceCountBase = 32;
constexpr static uint8_t PieceCountNumerator = 3;
constexpr static uint8_t PieceCountDenominator = 5;

constexpr static uint64_t MoveInstantTime = 500;

constexpr static KillerTable DummyKTable;
Expand Down
Loading

0 comments on commit 0faabb5

Please sign in to comment.