Skip to content

modernize-use-integer-sign-comparison - #8449

Closed
Jacobfaib wants to merge 3 commits into
NVIDIA:mainfrom
Jacobfaib:jacobf/2026-04-15/modernize-use-integer-sign-comparison
Closed

Jacobfaib wants to merge 3 commits into
NVIDIA:mainfrom
Jacobfaib:jacobf/2026-04-15/modernize-use-integer-sign-comparison

Conversation

@Jacobfaib

Copy link
Copy Markdown
Contributor

Description

closes

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@Jacobfaib Jacobfaib self-assigned this Apr 15, 2026
@Jacobfaib
Jacobfaib requested review from a team as code owners April 15, 2026 15:50
@Jacobfaib
Jacobfaib requested a review from wmaxey April 15, 2026 15:50
@Jacobfaib
Jacobfaib requested a review from pauleonix April 15, 2026 15:50
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Apr 15, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Apr 15, 2026

@fbusato fbusato left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not in favor of that. This can change the performance. If we know that two values are positive (and within the range), we can compare int and unsigned

@github-project-automation github-project-automation Bot moved this from In Review to In Progress in CCCL Apr 15, 2026
@Jacobfaib

Copy link
Copy Markdown
Contributor Author

I'm not in favor of that. This can change the performance. If we know that two values are positive (and within the range), we can compare int and unsigned

I think in that case we should assert that at compile-time by using appropriate types. So storing strictly positive values in unsigned types etc

@Jacobfaib

Copy link
Copy Markdown
Contributor Author

Since most of these are in CUB-land, I would ask that @bernhardmgruber or other CUB maintainers please take a close look at this PR and let me know which values could be made unsigned. I see that a lot of CUB tuning parameters just use int (for example BlockRakingLayout::RAKING_THREADS) when these can be made unsigned.

@github-actions

This comment has been minimized.

T addend = temp_storage[HALF_WARP_THREADS + lane_id - offset];
// Update partial if addend is in range
if ((lane_id >= offset) && (static_cast<int>(lane_id) < valid_items))
if (::cuda::std::cmp_greater_equal(lane_id, offset) && ::cuda::std::cmp_less(lane_id, valid_items))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with @fbusato, we should be careful about changes in cub. lane_id will always be in range [0;31), we should be fine here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK I await decisions then on which values can have their types changed to unsigned, otherwise I will just // NOLINT everything in CUB.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 3h 16m: Pass: 100%/331 | Total: 8d 09h | Max: 1h 22m | Hits: 86%/409842

See results here.

@miscco miscco left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am also not in favor off those changes.

I believe those a generally a win in user code, but we have to also consider other constraints than user code.

  1. Does this affect runtime performance in a tight loop?
  2. Does this affect compile times? We are a template heavy library and using _Width <= __warp_size is much faster to compile than ::cuda::std::cmp_less_equal(_Width, __warp_size)
  3. Does this affect debug experience? An integer comparison is just an instruction, but now we have to traverse into a nontrivial function.

So if we can get away with a simple cast, because we know that it will not overflow it is generally

@bernhardmgruber

Copy link
Copy Markdown
Contributor

I would ask that @bernhardmgruber or other CUB maintainers please take a close look at this PR and let me know which values could be made unsigned.

I had a quick look and agree with @fbusato and @miscco that these changes are highly dangerous to affect performance in unpredictable ways. Any change to kernel code must be thoroughly benchmarked.

I would leave this clang-tidy check disabled for now.

@Jacobfaib

Copy link
Copy Markdown
Contributor Author

Tabling for CCCL 4.0

@Jacobfaib Jacobfaib closed this Apr 16, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in CCCL Apr 16, 2026
@Jacobfaib
Jacobfaib deleted the jacobf/2026-04-15/modernize-use-integer-sign-comparison branch April 16, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants