Repository navigation
Refactor cuda::std::rot* - #4488
Merged
Merged
Conversation
Contributor
miscco
approved these changes
Apr 17, 2025
Contributor
|
/ok to test d4a5889 |
Contributor
ðĐ CI finished in 2h 12m: Pass: 100%/174 | Total: 3d 12h | Avg: 29m 00s | Max: 1h 25m | Hits: 76%/271185
|
| Project | |
|---|---|
| CCCL Infrastructure | |
| +/- | libcu++ |
| CUB | |
| Thrust | |
| CUDA Experimental | |
| stdpar | |
| python | |
| CCCL C Parallel Library | |
| Catch2Helper |
Modifications in project or dependencies?
| Project | |
|---|---|
| CCCL Infrastructure | |
| +/- | libcu++ |
| +/- | CUB |
| +/- | Thrust |
| +/- | CUDA Experimental |
| +/- | stdpar |
| +/- | python |
| +/- | CCCL C Parallel Library |
| +/- | Catch2Helper |
ðâ Runner counts (total jobs: 174)
| # | Runner |
|---|---|
| 123 | linux-amd64-cpu16 |
| 15 | windows-amd64-cpu16 |
| 12 | linux-arm64-cpu16 |
| 10 | linux-amd64-gpu-rtx2080-latest-1 |
| 6 | linux-amd64-gpu-rtxa6000-latest-1 |
| 5 | linux-amd64-gpu-h100-latest-1 |
| 3 | linux-amd64-gpu-rtx4090-latest-1 |
fbusato
reviewed
Apr 17, 2025
| _CCCL_ASSERT(__cnt != numeric_limits<int>::min(), "__cnt overflow"); | ||
| return _CUDA_VSTD::__rotl(__t, -__cnt); | ||
| // todo: replace with cuda::__neg when available | ||
| __cnt = static_cast<int>((~static_cast<unsigned>(__cnt) + 1) % numeric_limits<_Tp>::digits); |
Contributor
There was a problem hiding this comment.
not sure if I'm understanding this change correctly. INT_MIN is undefined behavior and we could use an assertion here. Using the negation with INT_MIN , the result will be 2 which is weird.
Contributor
Author
There was a problem hiding this comment.
Actually, it is not an undefined behaviour :) The standard describes those functions as (example for rotl:
- In the following descriptions, let
Ndenotenumeric_limits<T>â::âdigits
template<class T> constexpr T rotl(T x, int s) noexcept;
- Let
rbes % N - Returns: If
ris0,x; ifris positive,(x << r) | (x >> (N - r)); ifris negative,rotr(x, -r)
The fact that they define the temporary r makes all of the operations well defined.
Note that -r is passed to rotr, not -s.
Contributor
There was a problem hiding this comment.
I didn't check the standard to be honest ð
it seems that for __cnt < 0 we are applying modulo twice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a minor refactor
cuda::std::rot*functions and improves the handling of a corner case when therotation_count == INT_MIN.