Skip to content

Commit

Permalink
Extend comments on synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
tfeher committed Nov 2, 2023
1 parent 52670f7 commit c310095
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cpp/bench/ann/src/common/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ void bench_search(::benchmark::State& state,
// All other threads will wait for the first thread to initialize the algo.
std::unique_lock lk(init_mutex);
cond_var.wait(lk, [] { return current_algo_props.get() != nullptr; });
// gbench ensures that all threads are synchronized at the start of the benchmark loop.
// We are accessing shared variables (like current_algo, current_algo_probs) before the
// benchmark loop, therefore the synchronization here is necessary.
}
const auto algo_property = *current_algo_props;

Expand All @@ -268,8 +271,6 @@ void bench_search(::benchmark::State& state,
{
nvtx_case nvtx{state.name()};

// gbench ensures that all threads are synchronized at the start of the benchmark loop.

// TODO: Have the odd threads load the queries backwards just to rule out caching.
ANN<T>* algo = dynamic_cast<ANN<T>*>(current_algo.get());
for (auto _ : state) {
Expand Down

0 comments on commit c310095

Please sign in to comment.