1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

[cluster] fill sendbuffer better

use a counter to track available elements.

Some elo gain, on 4 ranks:

Score of old-r4-1t vs new-r4-1t: 422 - 508 - 1694  [0.484] 2624
Elo difference: -11.39 +/- 7.90
This commit is contained in:
Joost VandeVondele 2018-12-15 09:00:19 +01:00 committed by Stéphane Nicolet
parent e526c5aa52
commit ba1c639836
3 changed files with 7 additions and 4 deletions

View file

@ -176,16 +176,15 @@ void save(Thread* thread, TTEntry* tte,
{
std::lock_guard<Mutex> lk(thread->ttBuffer.mutex);
thread->ttBuffer.buffer.replace(KeyedTTEntry(k,*tte));
++thread->ttBuffer.counter;
}
// Communicate on main search thread
if (thread == Threads.main())
if (thread == Threads.main() && thread->ttBuffer.counter * Threads.size() > TTSendBufferSize)
{
static MPI_Request req = MPI_REQUEST_NULL;
static TTSendBuffer<TTSendBufferSize> send_buff = {};
int flag;
bool found;
TTEntry* replace_tte;
// Test communication status
MPI_Test(&req, &flag, MPI_STATUS_IGNORE);
@ -202,6 +201,8 @@ void save(Thread* thread, TTEntry* tte,
for (size_t i = irank * TTSendBufferSize ; i < (irank + 1) * TTSendBufferSize; ++i)
{
auto&& e = TTBuff[i];
bool found;
TTEntry* replace_tte;
replace_tte = TT.probe(e.first, found);
replace_tte->save(e.first, e.second.value(), e.second.bound(), e.second.depth(),
e.second.move(), e.second.eval());
@ -219,6 +220,7 @@ void save(Thread* thread, TTEntry* tte,
send_buff.replace(e);
// Reset thread's send buffer
th->ttBuffer.buffer = {};
th->ttBuffer.counter = 0;
}
// Start next communication

View file

@ -42,7 +42,7 @@ struct MoveInfo {
#ifdef USE_MPI
using KeyedTTEntry = std::pair<Key, TTEntry>;
constexpr std::size_t TTSendBufferSize = 16;
constexpr std::size_t TTSendBufferSize = 32;
template <std::size_t N> class TTSendBuffer : public std::array<KeyedTTEntry, N> {
struct Compare {

View file

@ -79,6 +79,7 @@ public:
struct {
Mutex mutex;
Cluster::TTSendBuffer<Cluster::TTSendBufferSize> buffer = {};
size_t counter = 0;
} ttBuffer;
#endif
};