Skip to content

Commit bbda30f

Browse files
committed
Adjust value_evaluation_threshold to reduce GPU load
1 parent 45b215d commit bbda30f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/UctSearch.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ static int pw[PURE_BOARD_MAX + 1];
9595
// ノード展開の閾値
9696
static int expand_threshold = EXPAND_THRESHOLD_19;
9797

98+
static double value_evaluation_threshold = 0;
99+
98100
// ノードを展開しない
99101
static bool no_expand = false;
100102

@@ -744,7 +746,7 @@ UctSearchGenmove( game_info_t *game, int color )
744746
if (use_nn && GetDebugMessageMode()) {
745747
cerr << "Eval NN Policy : " << setw(7) << (eval_count_policy + eval_policy_queue.size()) << endl;
746748
cerr << "Eval NN Value : " << setw(7) << (eval_count_value + eval_value_queue.size()) << endl;
747-
cerr << "Eval NN : " << setw(7) << eval_count_policy << "/" << eval_count_value << endl;
749+
cerr << "Eval NN : " << setw(7) << eval_count_policy << "/" << eval_count_value << "/" << value_evaluation_threshold << endl;
748750
cerr << "Count Captured : " << setw(7) << count << endl;
749751
cerr << "Score : " << setw(7) << score << endl;
750752
//PrintOwnerNN(S_BLACK, owner_nn);
@@ -1427,6 +1429,7 @@ ParallelUctSearch( thread_arg_t *arg )
14271429
LOCK_EXPAND;
14281430
while (eval_value_queue.size() > value_batch_size * 3 || eval_policy_queue.size() > policy_batch_size * 3) {
14291431
std::atomic_fetch_add(&queue_full, 1);
1432+
value_evaluation_threshold = min(0.5, value_evaluation_threshold + 0.01);
14301433
UNLOCK_EXPAND;
14311434
this_thread::sleep_for(chrono::milliseconds(10));
14321435
if (queue_full % 1000 == 0)
@@ -1584,6 +1587,7 @@ UctSearch(game_info_t *game, int color, mt19937_64 *mt, LGR& lgrf, LGRContext& l
15841587

15851588
bool expected = false;
15861589
if (use_nn
1590+
&& n >= expand_threshold * value_evaluation_threshold
15871591
&& atomic_compare_exchange_strong(&uct_child[next_index].eval_value, &expected, true)) {
15881592

15891593
uct_node_t *root = &uct_node[current_root];
@@ -2510,6 +2514,7 @@ void EvalNode() {
25102514
}
25112515

25122516
if (eval_policy_queue.empty() && eval_value_queue.empty()) {
2517+
value_evaluation_threshold = max(0.0, value_evaluation_threshold - 0.01);
25132518
UNLOCK_EXPAND;
25142519
this_thread::sleep_for(chrono::milliseconds(1));
25152520
//cerr << "EMPTY QUEUE" << endl;

0 commit comments

Comments
 (0)