Skip to content

Commit

Permalink
IVF-PQ: tweak launch configuration (#1069)
Browse files Browse the repository at this point in the history
Add one more criterion for reducing the block size when selecting the optimal launch configuration. This fixes a few benchmark cases where the performance has been slightly worse compared to the reference implementation.

Authors:
  - Artem M. Chirkin (https://github.com/achirkin)

Approvers:
  - Tamas Bela Feher (https://github.com/tfeher)

URL: #1069
  • Loading branch information
achirkin authored Dec 8, 2022
1 parent 9c8b762 commit 7f87931
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cpp/include/raft/spatial/knn/detail/ivf_pq_search.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,13 @@ struct ivfpq_compute_similarity {
// If we don't have enough repeating probes (locality_hint < tmp.blocks_per_sm),
// the locality is not going to improve with increasing the number of blocks per SM.
// Hence, the only metric here is the occupancy.
select_it = tmp.occupancy > cur.occupancy;
bool improves_occupancy = tmp.occupancy > cur.occupancy;
// Otherwise, the performance still improves with a smaller block size,
// given there is enough work to do
bool improves_parallelism =
tmp.occupancy == cur.occupancy &&
7u * tmp.blocks_per_sm * dev_props.multiProcessorCount <= n_blocks;
select_it = improves_occupancy || improves_parallelism;
} else {
// If we don't use shared memory for the lookup table, increasing the number of blocks
// is very taxing on the global memory usage.
Expand Down

0 comments on commit 7f87931

Please sign in to comment.