Skip to content

Commit

Permalink
Adjust value_evaluation_threshold to reduce GPU load
Browse files Browse the repository at this point in the history
  • Loading branch information
zakki committed Jun 17, 2017
1 parent 45b215d commit bbda30f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/UctSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ static int pw[PURE_BOARD_MAX + 1];
// ノード展開の閾値
static int expand_threshold = EXPAND_THRESHOLD_19;

static double value_evaluation_threshold = 0;

// ノードを展開しない
static bool no_expand = false;

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

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

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

if (eval_policy_queue.empty() && eval_value_queue.empty()) {
value_evaluation_threshold = max(0.0, value_evaluation_threshold - 0.01);
UNLOCK_EXPAND;
this_thread::sleep_for(chrono::milliseconds(1));
//cerr << "EMPTY QUEUE" << endl;
Expand Down

0 comments on commit bbda30f

Please sign in to comment.