Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Fix DeviceHistogram::Even for mixed float/int levels and sample types. #487

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

alliepiper
Copy link
Collaborator

@alliepiper alliepiper commented May 19, 2022

The ScaleTransform utility precomputes the reciprocal of the "sample -> bin_idx" scaling factor for floating point types as an optimization.

Trouble is, the Init method checked whether LevelT is fp while BinSelect checked SampleT. This caused the optimization to be incorrectly applied when one of these types is fp but the other is not.

Fixed this bug and simplified the implementation of ScaleTransform using cuda::std::common_type to consistently apply the optimization when either LevelT or ScaleT are fp.

Fixes #479 and #489 and adds regression tests for both.

Breaking Changes:

@alliepiper alliepiper added type: bug: functional Does not work as intended. P1: should have Necessary, but not critical. labels May 19, 2022
@alliepiper alliepiper added this to the 2.0.0 milestone May 19, 2022
alliepiper added a commit to alliepiper/thrust that referenced this pull request May 19, 2022
@alliepiper
Copy link
Collaborator Author

gpuCI: NVIDIA/thrust#1697

@alliepiper alliepiper added the testing: gpuCI in progress Started gpuCI testing. label May 19, 2022
@alliepiper
Copy link
Collaborator Author

@Melirius This should fix your issue with DeviceHistogram. Let us know if you get a chance to test it out.

@Melirius
Copy link

It is nice, thanks for your work! However, it does not address another problem #489 that is rooted in the same code.

Copy link
Collaborator

@gevtushenko gevtushenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for starting the work on this! It seems that no one looked at the code for a while 😄
Regarding the PR, it seems to introduce some substantial changes. I'd like us to consider all implications before merging this PR. For instance, documentation doesn't say much about SampleT and LevelT. Unlike ConterT, LevelT isn't even required to be primitive. Let's gather requirements on these types, update documentation / assert these requirements and then have another review.

cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
@alliepiper alliepiper added the release: breaking change Include in "Breaking Changes" section of release notes. label Aug 5, 2022
alliepiper added a commit to alliepiper/thrust that referenced this pull request Aug 5, 2022
alliepiper added a commit to alliepiper/thrust that referenced this pull request Aug 5, 2022
@alliepiper alliepiper added testing: gpuCI in progress Started gpuCI testing. and removed testing: gpuCI passed Passed gpuCI testing. labels Aug 5, 2022
Copy link
Collaborator

@gevtushenko gevtushenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for documenting actual requirements! A few minor fixes below.

cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
cub/device/dispatch/dispatch_histogram.cuh Outdated Show resolved Hide resolved
alliepiper added a commit to alliepiper/thrust that referenced this pull request Aug 8, 2022
#include <cub/util_cpp_dialect.cuh>

#if CUB_CPP_DIALECT >= 2017 && __cpp_if_constexpr
# define CUB_IF_CONSTEXPR if constexpr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, we cannot pass -Wno-c++17-extensions to our build flags

Asking for a friend

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No -- Thrust/CUB are header only, so that would require our users to do the same.

alliepiper added a commit to alliepiper/thrust that referenced this pull request Aug 8, 2022
alliepiper added a commit to alliepiper/thrust that referenced this pull request Aug 9, 2022
alliepiper added a commit to alliepiper/thrust that referenced this pull request Aug 9, 2022
alliepiper added a commit to alliepiper/thrust that referenced this pull request Aug 9, 2022
@alliepiper alliepiper merged commit 5e990ba into NVIDIA:main Aug 10, 2022
@alliepiper alliepiper deleted the histogram_mixed_type/gh.479 branch August 10, 2022 20:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1: should have Necessary, but not critical. release: breaking change Include in "Breaking Changes" section of release notes. testing: gpuCI in progress Started gpuCI testing. type: bug: functional Does not work as intended.
Projects
None yet
4 participants