mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 17:19:36 +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:
parent
e526c5aa52
commit
ba1c639836
3 changed files with 7 additions and 4 deletions
|
@ -176,16 +176,15 @@ void save(Thread* thread, TTEntry* tte,
|
||||||
{
|
{
|
||||||
std::lock_guard<Mutex> lk(thread->ttBuffer.mutex);
|
std::lock_guard<Mutex> lk(thread->ttBuffer.mutex);
|
||||||
thread->ttBuffer.buffer.replace(KeyedTTEntry(k,*tte));
|
thread->ttBuffer.buffer.replace(KeyedTTEntry(k,*tte));
|
||||||
|
++thread->ttBuffer.counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Communicate on main search thread
|
// 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 MPI_Request req = MPI_REQUEST_NULL;
|
||||||
static TTSendBuffer<TTSendBufferSize> send_buff = {};
|
static TTSendBuffer<TTSendBufferSize> send_buff = {};
|
||||||
int flag;
|
int flag;
|
||||||
bool found;
|
|
||||||
TTEntry* replace_tte;
|
|
||||||
|
|
||||||
// Test communication status
|
// Test communication status
|
||||||
MPI_Test(&req, &flag, MPI_STATUS_IGNORE);
|
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)
|
for (size_t i = irank * TTSendBufferSize ; i < (irank + 1) * TTSendBufferSize; ++i)
|
||||||
{
|
{
|
||||||
auto&& e = TTBuff[i];
|
auto&& e = TTBuff[i];
|
||||||
|
bool found;
|
||||||
|
TTEntry* replace_tte;
|
||||||
replace_tte = TT.probe(e.first, found);
|
replace_tte = TT.probe(e.first, found);
|
||||||
replace_tte->save(e.first, e.second.value(), e.second.bound(), e.second.depth(),
|
replace_tte->save(e.first, e.second.value(), e.second.bound(), e.second.depth(),
|
||||||
e.second.move(), e.second.eval());
|
e.second.move(), e.second.eval());
|
||||||
|
@ -219,6 +220,7 @@ void save(Thread* thread, TTEntry* tte,
|
||||||
send_buff.replace(e);
|
send_buff.replace(e);
|
||||||
// Reset thread's send buffer
|
// Reset thread's send buffer
|
||||||
th->ttBuffer.buffer = {};
|
th->ttBuffer.buffer = {};
|
||||||
|
th->ttBuffer.counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start next communication
|
// Start next communication
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct MoveInfo {
|
||||||
#ifdef USE_MPI
|
#ifdef USE_MPI
|
||||||
using KeyedTTEntry = std::pair<Key, TTEntry>;
|
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> {
|
template <std::size_t N> class TTSendBuffer : public std::array<KeyedTTEntry, N> {
|
||||||
|
|
||||||
struct Compare {
|
struct Compare {
|
||||||
|
|
|
@ -79,6 +79,7 @@ public:
|
||||||
struct {
|
struct {
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
Cluster::TTSendBuffer<Cluster::TTSendBufferSize> buffer = {};
|
Cluster::TTSendBuffer<Cluster::TTSendBufferSize> buffer = {};
|
||||||
|
size_t counter = 0;
|
||||||
} ttBuffer;
|
} ttBuffer;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue