Skip to content

Refactor device_adjacent_difference::dispatch to take a tuning - #9454

Merged
miscco merged 1 commit into
mainfrom
device_adjacent_difference_dispatch_env
Jun 25, 2026
Merged

miscco merged 1 commit into
mainfrom
device_adjacent_difference_dispatch_env

Conversation

@miscco

@miscco miscco commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

closes

Checklist

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

@copy-pr-bot

copy-pr-bot Bot commented Jun 15, 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.

@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 15, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Progress in CCCL Jun 15, 2026
@miscco
miscco marked this pull request as ready for review June 15, 2026 06:59
@miscco
miscco requested a review from a team as a code owner June 15, 2026 06:59
@miscco
miscco requested a review from davebayer June 15, 2026 06:59
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jun 15, 2026
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from 8ee512c to b93e092 Compare June 15, 2026 12:51
@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from b93e092 to c65dfe9 Compare June 15, 2026 12:51
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from c65dfe9 to c8cf909 Compare June 16, 2026 10:57
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from c8cf909 to 5686198 Compare June 17, 2026 10:53
@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from 5686198 to 65128a8 Compare June 17, 2026 10:53
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from 65128a8 to ddfe08f Compare June 22, 2026 09:50
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from ddfe08f to ca0ff3a Compare June 23, 2026 07:11
@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from ca0ff3a to 6912c92 Compare June 23, 2026 07:11
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from 6912c92 to 6b32612 Compare June 23, 2026 09:48
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from 6b32612 to eee5562 Compare June 24, 2026 07:45
@copy-pr-bot

copy-pr-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Base automatically changed from device_adjacent_difference_subtract_right_env to main June 24, 2026 13:30
@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch 2 times, most recently from e0e65f6 to 30bfef7 Compare June 24, 2026 13:31
@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ecacd12e-b9de-487f-a56d-cf1be42e3f2e

📥 Commits

Reviewing files that changed from the base of the PR and between 6a4cacd and b356fbf.

📒 Files selected for processing (2)
  • cub/cub/device/device_adjacent_difference.cuh
  • cub/cub/device/dispatch/dispatch_adjacent_difference.cuh
🚧 Files skipped from review as they are similar to previous changes (2)
  • cub/cub/device/device_adjacent_difference.cuh
  • cub/cub/device/dispatch/dispatch_adjacent_difference.cuh

Note: CodeRabbit is enabled on this repository as a convenience for maintainers
and contributors. Use your best judgment when considering its review comments and
suggestions — a suggested change may be inadequate, unnecessary, or safe to ignore.
Contributors are not expected to address every comment. Human reviews are what
ultimately matter for merging.

Summary

  • Refactored device_adjacent_difference::dispatch usage so the adjacent-difference dispatch is driven by a tuning execution environment (tuning_env) passed through detail::dispatch_with_env, instead of relying on an explicit PolicySelector/precomputed policy selection path at the call site.
  • Updated DeviceAdjacentDifference adjacent-difference call sites (SubtractLeft* / SubtractRight*, including both temp-storage and env-aware in-place/copy overloads) to forward tuning_env into detail::adjacent_difference::dispatch via detail::dispatch_with_env.
  • Changed detail::adjacent_difference::dispatch to take NumItemsT num_items plus optional TuningEnvT tuning_env (defaulting to env<>) and to derive/validate policy_selector from tuning_env internally (with a new static_assert under concepts).
  • Moved/normalized internal input_t/offset_t handling and sizing/launch parameter computations (using typed offset_t and ceil_div(static_cast<offset_t>(num_items), tile_size)) into detail::adjacent_difference::dispatch, and updated the zero-items early-exit accordingly.
  • Removed cub/detail/choose_offset.cuh include from cub/cub/device/device_adjacent_difference.cuh (offset selection is now handled within the dispatch implementation).

Files changed

  • cub/cub/device/device_adjacent_difference.cuh
  • cub/cub/device/dispatch/dispatch_adjacent_difference.cuh

Walkthrough

DeviceAdjacentDifference now forwards all Subtract* paths through dispatch_with_env. detail::adjacent_difference::dispatch accepts TuningEnvT, derives policy_selector_t from the execution environment, normalizes input_t and offset_t, and updates the adjacent-difference kernel launches and zero-items check.

Changes

Adjacent Difference Dispatch Refactor

Layer / File(s) Summary
dispatch signature, policy selection, and kernel wiring
cub/cub/device/dispatch/dispatch_adjacent_difference.cuh
Adds cuda/std/__execution/env.h and cub/detail/choose_offset.cuh. Reworks detail::adjacent_difference::dispatch to remove the explicit PolicySelector parameter and its requires clause; introduces NumItemsT/TuningEnvT, derives policy_selector_t via __query_or, computes offset_t/input_t aliases, adds early exit when static_cast<offset_t>(num_items) == offset_t{}, updates DeviceAdjacentDifferenceInitKernel and DeviceAdjacentDifferenceDifferenceKernel instantiations, and adjusts the deprecated DispatchAdjacentDifference::Invoke path.
Subtract public API routing to dispatch_with_env*
cub/cub/device/device_adjacent_difference.cuh
All eight Subtract* overloads (SubtractLeftCopy, SubtractLeft, SubtractRightCopy, SubtractRight and their environment-based variants) replace dispatch_with_env_and_tuning with dispatch_with_env, removing local choose_offset_t/policy-selector logic and forwarding tuning_env directly to adjacent_difference::dispatch.

Possibly related PRs

  • NVIDIA/cccl#9418: Modifies the same DeviceAdjacentDifference dispatch call sites for SubtractLeft* to use execution-environment-based dispatch, overlapping with this PR’s env/tuning routing changes.
  • NVIDIA/cccl#9419: Touches the SubtractRight* adjacent-difference dispatch paths with the same environment-based routing pattern.

Suggested reviewers

  • elstehle
  • bernhardmgruber

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cub/cub/device/device_adjacent_difference.cuh (1)

16-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: remove this include after moving it to the dispatch header.

choose_offset_t is no longer used directly in this public API wrapper; keeping this include also hides the missing direct include in dispatch_adjacent_difference.cuh.

-#include <cub/detail/choose_offset.cuh>

As per coding guidelines, “Unneeded headers must be removed.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: dd659ec0-a629-44ab-9824-e63b1c8d22bd

📥 Commits

Reviewing files that changed from the base of the PR and between f871292 and 30bfef7.

📒 Files selected for processing (2)
  • cub/cub/device/device_adjacent_difference.cuh
  • cub/cub/device/dispatch/dispatch_adjacent_difference.cuh

@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from 30bfef7 to 6a4cacd Compare June 25, 2026 08:23
We previously passed the policy selector directly into the dispatch function.

However, the dispatch function is a much better place to figure that out.
@miscco
miscco force-pushed the device_adjacent_difference_dispatch_env branch from 6a4cacd to b356fbf Compare June 25, 2026 10:56
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 16m: Pass: 100%/287 | Total: 4d 10h | Max: 1h 26m | Hits: 63%/335412

See results here.

@miscco
miscco merged commit 70dba90 into main Jun 25, 2026
607 of 610 checks passed
@miscco
miscco deleted the device_adjacent_difference_dispatch_env branch June 25, 2026 14:03
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jun 25, 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.

2 participants