Skip to content

Commit bec7c81

Browse files
Use radix sort when size is large enough so that one-group sorter wont be needed
1 parent da3fbcc commit bec7c81

File tree

1 file changed

+10
-6
lines changed
  • dpctl/tensor/libtensor/source/sorting

1 file changed

+10
-6
lines changed

dpctl/tensor/libtensor/source/sorting/topk.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,17 @@ sycl::event topk_caller(sycl::queue &exec_q,
112112
{
113113
if constexpr (use_radix_sort<argTy>::value) {
114114
using dpctl::tensor::kernels::topk_radix_impl;
115-
auto ascending = !largest;
116-
return topk_radix_impl<argTy, IndexTy>(
117-
exec_q, iter_nelems, axis_nelems, k, ascending, arg_cp, vals_cp,
118-
inds_cp, iter_arg_offset, iter_vals_offset, iter_inds_offset,
119-
axis_arg_offset, axis_vals_offset, axis_inds_offset, depends);
115+
const auto ascending = !largest;
116+
117+
if (axis_nelems > 16384) {
118+
return topk_radix_impl<argTy, IndexTy>(
119+
exec_q, iter_nelems, axis_nelems, k, ascending, arg_cp, vals_cp,
120+
inds_cp, iter_arg_offset, iter_vals_offset, iter_inds_offset,
121+
axis_arg_offset, axis_vals_offset, axis_inds_offset, depends);
122+
}
120123
}
121-
else {
124+
125+
{
122126
using dpctl::tensor::kernels::topk_merge_impl;
123127
if (largest) {
124128
using CompTy =

0 commit comments

Comments
 (0)