Skip to content

Commit

Permalink
Add PQ Computation in cpu_timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Suryansh Gupta committed Jan 24, 2025
1 parent ce56e0c commit b7d1520
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ void PQFlashIndex<T, LabelT>::cached_beam_search(const T *query1, const uint64_t
if (beam_width > num_sector_per_nodes * defaults::MAX_N_SECTOR_READS)
throw ANNException("Beamwidth can not be higher than defaults::MAX_N_SECTOR_READS", -1, __FUNCSIG__, __FILE__,
__LINE__);
Timer query_timer;
Timer query_timer, io_timer, cpu_timer;
ScratchStoreManager<SSDThreadData<T>> manager(this->_thread_data);
auto data = manager.scratch_space();
IOContext &ctx = data->ctx;
Expand Down Expand Up @@ -1334,11 +1334,16 @@ void PQFlashIndex<T, LabelT>::cached_beam_search(const T *query1, const uint64_t
const uint64_t num_sectors_per_node =
_nnodes_per_sector > 0 ? 1 : DIV_ROUND_UP(_max_node_len, defaults::SECTOR_LEN);

cpu_timer.reset();
// query <-> PQ chunk centers distances
_pq_table.preprocess_query(query_rotated); // center the query and rotate if
// we have a rotation matrix
float *pq_dists = pq_query_scratch->aligned_pqtable_dist_scratch;
_pq_table.populate_chunk_distances(query_rotated, pq_dists);
if (stats != nullptr)
{
stats->cpu_us += (float)cpu_timer.elapsed();
}

// query <-> neighbor list
float *dist_scratch = pq_query_scratch->aligned_dist_scratch;
Expand All @@ -1350,7 +1355,6 @@ void PQFlashIndex<T, LabelT>::cached_beam_search(const T *query1, const uint64_t
diskann::aggregate_coords(ids, n_ids, this->data, this->_n_chunks, pq_coord_scratch);
diskann::pq_dist_lookup(pq_coord_scratch, n_ids, this->_n_chunks, pq_dists, dists_out);
};
Timer io_timer, cpu_timer;

tsl::robin_set<uint64_t> &visited = query_scratch->visited;
NeighborPriorityQueue &retset = query_scratch->retset;
Expand Down

0 comments on commit b7d1520

Please sign in to comment.