Skip to content

Add env overloads for DeviceSegmentedRadixSort - #7999

Merged
gonidelis merged 7 commits into
NVIDIA:mainfrom
gonidelis:seg-radix-sort-env
Mar 25, 2026
Merged

gonidelis merged 7 commits into
NVIDIA:mainfrom
gonidelis:seg-radix-sort-env

Conversation

@gonidelis

Copy link
Copy Markdown
Member

fixes #7549

No deterministic guarantees. It's sorting, if it's not deterministic it's just wrong.

@gonidelis
gonidelis requested a review from a team as a code owner March 12, 2026 02:47
@gonidelis
gonidelis requested a review from pauleonix March 12, 2026 02:47
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Mar 12, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Mar 12, 2026
@gonidelis
gonidelis force-pushed the seg-radix-sort-env branch from 2c8d80a to 55ca027 Compare March 12, 2026 04:13
@github-actions

This comment has been minimized.

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

Important: we are missing the DoubleBuffer overloads

@gonidelis

Copy link
Copy Markdown
Member Author

Important: we are missing the DoubleBuffer overloads

@NaderAlAwar will be added in subsequent pr for economy of reviewing effort per pr

@github-actions

This comment has been minimized.

@pauleonix

pauleonix commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

No deterministic guarantees. It's sorting, if it's not deterministic it's just wrong.

Only because our radix-sort is stable by design. Unstable sort could be non-deterministic 😉

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

Still some nits

//! yield a corresponding performance improvement.
//! - Note, the size of any segment may not exceed ``INT_MAX``. Please consider using ``DeviceSegmentedSort`` instead,
//! if the size of at least one of your segments could exceed ``INT_MAX``.
//!

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.

Maybe we should have a @env like the @devicestorage on the old APIs to avoid the repetition. Even if it needs multiple like @env-with-guarantees.

@bernhardmgruber bernhardmgruber Mar 20, 2026 •

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 considered suggesting the same! No need to do it in this PR though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this has already been suggested on a friday review meeting and it in my todo list. i will open an issue

//! - An optional bit subrange ``[begin_bit, end_bit)`` of differentiating key
//! bits can be specified. This can reduce overall sorting overhead and
//! yield a corresponding performance improvement.
//! - Note, the size of any segment may not exceed ``INT_MAX``. Please consider using ``DeviceSegmentedSort`` instead,

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.

Missing

  //! - Let ``in`` be one of ``{d_keys_in, d_values_in}`` and `out` be any of
  //!   ``{d_keys_out, d_values_out}``. The range ``[out, out + num_items)`` shall
  //!   not overlap ``[in, in + num_items)``,
  //!   ``[d_begin_offsets, d_begin_offsets + num_segments)`` nor
  //!   ``[d_end_offsets, d_end_offsets + num_segments)`` in any way.

and

  //! - Segments are not required to be contiguous. For all index values ``i``
  //!   outside the specified segments ``d_keys_in[i]``, ``d_values_in[i]``,
  //!   ``d_keys_out[i]``, ``d_values_out[i]`` will not be accessed nor modified.

Maybe also

  //! - @devicestorageNP For sorting using only ``O(P)`` temporary storage, see
  //!   the sorting interface using DoubleBuffer wrappers below.

}

//! @rst
//! Overview

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.

This "title" is new in comparison to the existing docs. If it stays, it looks like it should be underlined (rendered as a sub-title)

Suggested change
//! Overview
//! Overview
//! +++++++++++++++++++++++++++++++++++++++++++++

Same for Snippet below (which is not new but has this underline in existing docs)

//! - An optional bit subrange ``[begin_bit, end_bit)`` of differentiating key
//! bits can be specified. This can reduce overall sorting overhead and
//! yield a corresponding performance improvement.
//! - Note, the size of any segment may not exceed ``INT_MAX``. Please consider using ``DeviceSegmentedSort`` instead,

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.

Missing entries again.

REQUIRE(keys_out == expected_keys);
}

TEST_CASE("DeviceSegmentedRadixSort::SortPairs uses custom stream", "[segmented_radix_sort][device]")

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.

Should this be tested for all overloads?

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

Please apply the remaining feedback from other reviewers. Otherwise LGTM

@gonidelis
gonidelis force-pushed the seg-radix-sort-env branch from c577169 to a2838b4 Compare March 25, 2026 08:18
@gonidelis
gonidelis enabled auto-merge (squash) March 25, 2026 08:20
@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 11m: Pass: 100%/249 | Total: 3d 19h | Max: 53m 01s | Hits: 94%/157462

See results here.

@gonidelis
gonidelis merged commit e7c8268 into NVIDIA:main Mar 25, 2026
265 of 266 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Mar 25, 2026
jainishmehta pushed a commit to jainishmehta/cccl that referenced this pull request Apr 19, 2026
* Add env overloads for DeviceSegmentedRadixSort

* Simplify literalinclude paths

* Fix docs

* Remove _CCCL_FORCEINLINE

* fix docs

* Fix static_casts and types in api test

* Add uses custom stream for all algorithms
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.

Add env-based API for cub::DeviceSegmentedRadixSort

4 participants