Skip to content

Add tuning policies to CUB API docs#9745

Merged
bernhardmgruber merged 7 commits into
NVIDIA:mainfrom
bernhardmgruber:tuning_policies_docs
Jul 13, 2026
Merged

Add tuning policies to CUB API docs#9745
bernhardmgruber merged 7 commits into
NVIDIA:mainfrom
bernhardmgruber:tuning_policies_docs

Conversation

@bernhardmgruber

Copy link
Copy Markdown
Contributor

Fixes part of: #9378

@bernhardmgruber bernhardmgruber requested review from a team as code owners July 8, 2026 09:48
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 8, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Improved host-side formatting for lookback delay tuning values, including stream output and std::format support when available.
  • Bug Fixes
    • Added [[nodiscard]] to equality/inequality results across many tuning policy comparisons.
  • Documentation
    • Updated Doxygen preprocessing macros and include/exclude patterns to improve API rendering.
  • Refactor
    • Moved shared lookback delay tuning definitions into a common header.
  • Chores
    • Standardized qualifier/specifier ordering for tuning policy comparison operator declarations.

Walkthrough

Moves lookback-delay types into common.cuh, reorders tuning-policy friend comparison declarations across CUB device dispatch headers, and updates Doxygen preprocessing settings in four documentation configs.

Changes

Lookback Delay API Relocation

Layer / File(s) Summary
Move lookback delay types to common.cuh
cub/cub/device/dispatch/tuning/common.cuh, cub/cub/detail/delay_constructor.cuh
LookbackDelayAlgorithm, detail::to_string, stream/formatter support, and LookbackDelayPolicy now live in common.cuh; delay_constructor.cuh includes that header instead of defining them locally.

Friend Operator Qualifier Reformatting

Layer / File(s) Summary
Reduce, scan, and merge operators
cub/cub/device/dispatch/tuning/tuning_reduce.cuh, cub/cub/device/dispatch/tuning/tuning_reduce_by_key.cuh, cub/cub/device/dispatch/tuning/tuning_scan.cuh, cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh, cub/cub/device/dispatch/tuning/tuning_merge.cuh, cub/cub/device/dispatch/tuning/tuning_merge_sort.cuh
Friend comparison declarations are reordered for reduce, reduce-by-key, scan, scan-by-key, merge, and merge-sort policies.
Radix and segmented sort operators
cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh, cub/cub/device/dispatch/tuning/tuning_segmented_radix_sort.cuh, cub/cub/device/dispatch/tuning/tuning_segmented_sort.cuh, cub/cub/device/dispatch/tuning/tuning_unique_by_key.cuh
[[nodiscard]] and qualifier ordering updates are applied to equality/inequality friend operators for radix and segmented sort policies.
Segmented reduce, scan, select, and topk operators
cub/cub/device/dispatch/tuning/tuning_segmented_reduce.cuh, cub/cub/device/dispatch/tuning/tuning_segmented_scan.cuh, cub/cub/device/dispatch/tuning/tuning_select_if.cuh, cub/cub/device/dispatch/tuning/tuning_three_way_partition.cuh, cub/cub/device/dispatch/tuning/tuning_topk.cuh, cub/cub/device/dispatch/tuning/tuning_batched_topk.cuh
Comparison declarations are updated across segmented reduce/scan, select-if, three-way partition, batched topk, and topk policies.
Adjacent difference, batch memcpy, find, for, histogram, RLE, transform operators
cub/cub/device/dispatch/tuning/tuning_adjacent_difference.cuh, cub/cub/device/dispatch/tuning/tuning_batch_memcpy.cuh, cub/cub/device/dispatch/tuning/tuning_find.cuh, cub/cub/device/dispatch/tuning/tuning_find_bound_sorted_values.cuh, cub/cub/device/dispatch/tuning/tuning_for.cuh, cub/cub/device/dispatch/tuning/tuning_histogram.cuh, cub/cub/device/dispatch/tuning/tuning_rle_encode.cuh, cub/cub/device/dispatch/tuning/tuning_rle_non_trivial_runs.cuh, cub/cub/device/dispatch/tuning/tuning_transform.cuh
Comparison declarations are reordered or annotated with [[nodiscard]] for several policy structs, and two DeviceTransform references are qualified.

Doxyfile Configuration Updates

Layer / File(s) Summary
Predefined macro and exclude pattern updates
docs/cub/Doxyfile, docs/cudax/Doxyfile, docs/libcudacxx/Doxyfile, docs/thrust/Doxyfile
_CCCL_HOSTED()=1 is added to PREDEFINED in all four configs, and docs/cub/Doxyfile narrows dispatch exclusions.

Suggested reviewers: oleksandr-pavlyk, NaderAlAwar, elstehle


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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 916f0b3b-12af-4578-abf3-6b3a5efaf8f4

📥 Commits

Reviewing files that changed from the base of the PR and between ff80b87 and d5b2830.

📒 Files selected for processing (31)
  • cub/cub/detail/delay_constructor.cuh
  • cub/cub/device/dispatch/tuning/common.cuh
  • cub/cub/device/dispatch/tuning/tuning_adjacent_difference.cuh
  • cub/cub/device/dispatch/tuning/tuning_batch_memcpy.cuh
  • cub/cub/device/dispatch/tuning/tuning_batched_topk.cuh
  • cub/cub/device/dispatch/tuning/tuning_find.cuh
  • cub/cub/device/dispatch/tuning/tuning_find_bound_sorted_values.cuh
  • cub/cub/device/dispatch/tuning/tuning_for.cuh
  • cub/cub/device/dispatch/tuning/tuning_histogram.cuh
  • cub/cub/device/dispatch/tuning/tuning_merge.cuh
  • cub/cub/device/dispatch/tuning/tuning_merge_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_reduce.cuh
  • cub/cub/device/dispatch/tuning/tuning_reduce_by_key.cuh
  • cub/cub/device/dispatch/tuning/tuning_rle_encode.cuh
  • cub/cub/device/dispatch/tuning/tuning_rle_non_trivial_runs.cuh
  • cub/cub/device/dispatch/tuning/tuning_scan.cuh
  • cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh
  • cub/cub/device/dispatch/tuning/tuning_segmented_radix_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_segmented_reduce.cuh
  • cub/cub/device/dispatch/tuning/tuning_segmented_scan.cuh
  • cub/cub/device/dispatch/tuning/tuning_segmented_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_select_if.cuh
  • cub/cub/device/dispatch/tuning/tuning_three_way_partition.cuh
  • cub/cub/device/dispatch/tuning/tuning_topk.cuh
  • cub/cub/device/dispatch/tuning/tuning_transform.cuh
  • cub/cub/device/dispatch/tuning/tuning_unique_by_key.cuh
  • docs/cub/Doxyfile
  • docs/cudax/Doxyfile
  • docs/libcudacxx/Doxyfile
  • docs/thrust/Doxyfile

Comment thread cub/cub/device/dispatch/tuning/common.cuh
Comment thread cub/cub/device/dispatch/tuning/common.cuh
Comment thread cub/cub/device/dispatch/tuning/common.cuh
Comment thread cub/cub/device/dispatch/tuning/common.cuh Outdated
Comment thread cub/cub/device/dispatch/tuning/common.cuh
Comment thread cub/cub/device/dispatch/tuning/common.cuh
Comment on lines +263 to +265
LookbackDelayAlgorithm kind; //!< The algorithm used for delaying during decoupled lookback
unsigned int delay; //!< The delay in nanoseconds
unsigned int l2_write_latency; //!< The write latency of the L2 cache in nanoseconds

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.

Important: should provide default values for these, otherwise

LookbackDelayPolicy pol;

produces garbage.

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 is that a problem? And what are good default values?

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.

If there are no good defaults, then we should declare a constructor to force the user to populate everything.

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.

This will suppress designated initializers, which are a major help when defining those kind of structs.

Still, I don't see the problem of having uninitialized members upon construction. It's erroneous behavior to use that and will also fail during constant evaluation, if you forget to set a value.

Comment thread cub/cub/device/dispatch/tuning/tuning_transform.cuh
//! The delay algorithm used by decoupled lookback
enum class LookbackDelayAlgorithm
{
no_delay,

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.

Important: should document what these enum values represent exactly. For example, what does exponential_back_jitter mean? How big is the delay for fixed_delay?

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.

exponential_back_jitter is one of the algorithm for handling the delay of lookback-based algorithms. I have no idea what it does.

How big is the delay for fixed_delay?

The value specified in LookbackDelayPolicy::delay

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 34m: Pass: 100%/287 | Total: 12d 10h | Max: 2h 33m | Hits: 15%/1163679

See results here.

BlockStoreAlgorithm store_algorithm; //!< The @ref BlockStoreAlgorithm used for storing items to global memory

[[nodiscard]] _CCCL_HOST_DEVICE_API constexpr friend bool
[[nodiscard]] _CCCL_HOST_DEVICE_API friend constexpr bool

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.

Note: These changes are needed for Breathe to avoid a parsing issue.

@bernhardmgruber bernhardmgruber enabled auto-merge (squash) July 13, 2026 07:11
@bernhardmgruber bernhardmgruber merged commit 6992cf8 into NVIDIA:main Jul 13, 2026
307 of 308 checks passed
@bernhardmgruber bernhardmgruber deleted the tuning_policies_docs branch July 13, 2026 07:24
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.

3 participants