improve dim sort performance (#19379)
authorNatalia Gimelshein <ngimelshein@nvidia.com>
Fri, 19 Apr 2019 05:20:44 +0000 (22:20 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 19 Apr 2019 05:25:08 +0000 (22:25 -0700)
commitf0d98199fb1f20b8a22a645f50b5410d9392a864
tree72dfab403748d21045d66b7ee9a0b041252dd89f
parent941ccd6b35d21ce7d474be4f288ad84f27854467
improve dim sort performance (#19379)

Summary:
We are already using custom comparators for sorting (for a good reason), but are still making 2 sorting passes - global sort and stable sorting to bring values into their slices. Using a custom comparator to sort within a slice allows us to avoid second sorting pass and brings up to 50% perf improvement.
t-vi I know you are moving sort to ATen, and changing THC is discouraged, but #18350 seems dormant. I'm fine with #18350 landing first, and then I can put in these changes.
cc umanwizard for review.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19379

Differential Revision: D15011019

Pulled By: soumith

fbshipit-source-id: 48e5f5aef51789b166bb72c75b393707a9aed57c
aten/src/THC/THCTensorSort.cuh
aten/src/THC/generic/THCTensorSort.cu