Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculating neural network evaluation and tablebase probing duration then logging a message if duration > 1s #2060

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/mcts/search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,15 @@ int SearchWorker::PrefetchIntoCache(Node* node, int budget, bool is_odd_depth) {

// 4. Run NN computation.
// ~~~~~~~~~~~~~~~~~~~~~~
void SearchWorker::RunNNComputation() { computation_->ComputeBlocking(); }
void SearchWorker::RunNNComputation() {
auto start_time = std::chrono::high_resolution_clock::now();
computation_->ComputeBlocking();
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = end_time - start_time;
if (elapsed.count() > 1.0) {
std::cerr << "Warning: Computation took " << elapsed.count() << " seconds, which is longer than expected." << std::endl;
}
}

// 5. Retrieve NN computations (and terminal values) into nodes.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
9 changes: 7 additions & 2 deletions src/syzygy/syzygy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/

#include <atomic>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
Expand Down Expand Up @@ -1406,9 +1407,13 @@ class SyzygyTablebaseImpl {
}
idx = type != DTM ? encode_pawn_f(p, ei, be) : encode_pawn_r(p, ei, be);
}

auto start = std::chrono::high_resolution_clock::now();
uint8_t* w = decompress_pairs(ei->precomp, idx);

auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> duration = end - start;
if (duration.count() > 1) {
std::cout << "Tablebase probing duration: " << duration.count() << " seconds" << std::endl;
}
if (type == WDL) return static_cast<int>(w[0]) - 2;

int v = w[0] + ((w[1] & 0x0f) << 8);
Expand Down