Skip to content

Implement the new tuning API for DispatchHistogram - #8212

Merged
bernhardmgruber merged 14 commits into
NVIDIA:mainfrom
bernhardmgruber:tuning_hist
Mar 31, 2026
Merged

bernhardmgruber merged 14 commits into
NVIDIA:mainfrom
bernhardmgruber:tuning_hist

Conversation

@bernhardmgruber

@bernhardmgruber bernhardmgruber commented Mar 30, 2026 •

Copy link
Copy Markdown
Contributor
  • No SASS changes in cub.bench.histogram.even.base for SM75;90;100
  • No SASS changes in cub.bench.histogram.range.base for SM75;90;100
  • No SASS changes in cub.bench.histogram.multi.even.base for SM75;90;100
  • No SASS changes in cub.bench.histogram.multi.range.base for SM75;90;100

The histogram dispatcher is unfortunately carrying some technical dept. If this PR turns out to be too hard to review, I can try to push a refactoring and rebase on top, to make the rewrite here smaller. Please let me know.

Fixes: #7637
Fixes: #7475

@bernhardmgruber
bernhardmgruber requested review from a team as code owners March 30, 2026 09:27
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Mar 30, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Mar 30, 2026
@bernhardmgruber
bernhardmgruber marked this pull request as draft March 30, 2026 10:10
@copy-pr-bot

copy-pr-bot Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Review to In Progress in CCCL Mar 30, 2026
@github-actions

This comment has been minimized.

@bernhardmgruber
bernhardmgruber marked this pull request as ready for review March 30, 2026 12:39
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Mar 30, 2026

@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.

Mostly nits

}));
NV_IF_TARGET(
NV_PROVIDES_SM_90,
(if (::cuda::std::reduce(num_output_bins_wrapper.begin(), num_output_bins_wrapper.end())

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.

Technically this should be

Suggested change
(if (::cuda::std::reduce(num_output_bins_wrapper.begin(), num_output_bins_wrapper.end())
(if (::cuda::std::accumulate(num_output_bins_wrapper.begin(), num_output_bins_wrapper.end())

Because it is meant to be run serially

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.

Why? I just want to reduce a bunch of ints, so there is no need for that reduction to be performed left-to-right to preserve associativity.

bool is_even;

private:
[[nodiscard]] _CCCL_API constexpr int t_scale(int nominal_items_per_thread) const

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.

Can we have a better name?

@bernhardmgruber bernhardmgruber Mar 30, 2026 •

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.

The function was called t_scale in the old policy_hub and I frankly don't know what its meaning is. @gevtushenko moved it around in e3fba75, so the name seems to have been around for a while :S

[[nodiscard]] _CCCL_API constexpr auto operator()(::cuda::arch_id arch) const -> histogram_policy
{
auto policy = fallback_policy();
if (arch >= ::cuda::arch_id::sm_90)

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.

Nitpick: This goes contrary to the other policy selectors where we start with the newest policy and then move down.

Its also a bit confusing because the policy is not returned, so one has to look at the fields that are overwritten below.
Can we just keep the common order?

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, the state in this PR makes absolutely no sense. I wonder why it does not cause any SASS diffs then.

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, it should have worked, but it's very confusing. Fixed.


int histogram_init_grid_dims =
(max_num_output_bins + histogram_init_block_threads - 1) / histogram_init_block_threads;
constexpr int histogram_init_block_threads = 256;

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.

Question: Should this be something from the policy?

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.

Not at all, it's just a hardcoded parameter of the init kernel.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 55m: Pass: 100%/255 | Total: 8d 15h | Max: 1h 27m | Hits: 68%/160956

See results here.

@bernhardmgruber
bernhardmgruber merged commit e58d119 into NVIDIA:main Mar 31, 2026
272 of 273 checks passed
@bernhardmgruber
bernhardmgruber deleted the tuning_hist branch March 31, 2026 06:22
gonidelis pushed a commit to gonidelis/cccl that referenced this pull request Apr 8, 2026
jainishmehta pushed a commit to jainishmehta/cccl that referenced this pull request Apr 19, 2026
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.

Implement the new tuning API for DispatchHistogram Refactor cccl.c histogram to use new tuning API

3 participants