Skip to content

64-bit indexing for DeviceSegmentedReduce - #414

Merged
gevtushenko merged 21 commits into
NVIDIA:mainfrom
jecs:device-reduce-64bit
Sep 27, 2023
Merged

gevtushenko merged 21 commits into
NVIDIA:mainfrom
jecs:device-reduce-64bit

Conversation

@jecs

@jecs jecs commented Sep 7, 2023 •

Copy link
Copy Markdown
Contributor

Description

  • Added NumSegmentsT parameter to DeviceSegmentedReduce methods, so now num_segments can be of any integral type
  • Added OffsetT type resolution in a manner similar to DeviceReduce: set to std::common_type_t of BeginOffsetIterT::value_type and EndOffsetIterT::value_type. (see detail/choose_offset.cuh)
  • In a manner similar to DeviceReduce, we use static_cast to convert num_segments to OffsetT before dispatching
  • OffsetT type resolution uses std::common_type_t, std::void_t, and one inline constexpr variable (is_iterator_v).

Checklist

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

* Added NumSegmentsT parameter to methods, so now num_segments can be
  of any integral type
* Added OffsetT type resolution in a manner similar to DeviceReduce:
  set to std::common_type_t of BeginOffsetIterT::value_type and
  EndOffsetIterT::value_type. (see detail/choose_offset.cuh)
* In a manner similar to DeviceReduce, we use static_cast to convert
  num_segments to OffsetT before dispatching
* OffsetT type resolution uses std::common_type_t, std::void_t, and
  one inline constexpr variable (is_iterator_v).
@jecs
jecs requested review from a team as code owners September 7, 2023 18:03
@jecs
jecs requested review from elstehle and griwes and removed request for a team September 7, 2023 18:03
@copy-pr-bot

copy-pr-bot Bot commented Sep 7, 2023

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.

@jecs

jecs commented Sep 7, 2023 •

Copy link
Copy Markdown
Contributor Author

Hi, should I create an Issue and add it to the description? I originally submitted this PR to the old Cub repository.

@gevtushenko gevtushenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for the contribution! I've left a few comments, but before proceeding with the review, we'll need a test case that covers 64-bit problem sizes. Could you please add one? In order to keep moderate memory usage, you could try to rely on counting or constant iterators instead of actually allocating huge inputs.

Comment thread cub/cub/detail/choose_offset.cuh Resolved
Comment thread cub/cub/detail/choose_offset.cuh Resolved
@jecs

jecs commented Sep 8, 2023 •

Copy link
Copy Markdown
Contributor Author

Thank you for the contribution! I've left a few comments, but before proceeding with the review, we'll need a test case that covers 64-bit problem sizes. Could you please add one? In order to keep moderate memory usage, you could try to rely on counting or constant iterators instead of actually allocating huge inputs.

Thank you for the feedback! Yes, sure thing. I'll write a quick test using some kind of counter iterator- or constant iterator-based approach.

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

Thanks a lot for the contribution, I am so sorry about our support situation

Comment thread cub/cub/detail/choose_offset.cuh Resolved
Comment thread cub/cub/detail/choose_offset.cuh Resolved
Comment thread cub/cub/detail/choose_offset.cuh Resolved
Comment thread cub/cub/detail/choose_offset.cuh Resolved
Comment thread cub/cub/detail/choose_offset.cuh Resolved
Comment thread cub/cub/detail/choose_offset.cuh Resolved
Comment thread cub/cub/detail/choose_offset.cuh Resolved
Comment thread cub/cub/detail/choose_offset.cuh Resolved
* Removed NumSegmentsT portion
* Added catch2 test
* Modified previous test slightly to use correct type for
  num_segments
* Made type deduction SFINAE-friendly
@jecs

jecs commented Sep 11, 2023

Copy link
Copy Markdown
Contributor Author

@miscco @senior-zero Ready. (I hope.) I walked back 64-bit num_segments. I hope to submit that in a new Pull Request in the near future. For the test, I simply copied the previous test and modified it slightly.

@jecs
jecs requested a review from miscco September 12, 2023 20:56
@miscco

miscco commented Sep 13, 2023

Copy link
Copy Markdown
Contributor

/ok to test

@jecs

jecs commented Sep 13, 2023

Copy link
Copy Markdown
Contributor Author

Whoops! I deleted the offending lines and ran C++11 tests on my end. Everything seems to work now. Getting your code to be compliant with several standards is tricky business.

@jecs
jecs requested a review from gevtushenko September 13, 2023 13:43
@gevtushenko

Copy link
Copy Markdown
Collaborator

@jecs your repo seems to be protected. I've filed a PR with a few fixes: jecs#1 for your branch

@gevtushenko

Copy link
Copy Markdown
Collaborator

/ok to test

@jecs
jecs requested a review from gevtushenko September 20, 2023 18:49
@jecs

jecs commented Sep 21, 2023

Copy link
Copy Markdown
Contributor Author

@senior-zero I added you as a collaborator on my fork in case you'd like to make more changes.

@gevtushenko

Copy link
Copy Markdown
Collaborator

/ok to test

@gevtushenko
gevtushenko merged commit 94b358b into NVIDIA:main Sep 27, 2023
@jecs

jecs commented Sep 27, 2023 •

Copy link
Copy Markdown
Contributor Author

@senior-zero @miscco Thank you both so much for your excellent feedback and for guiding me through the process! I learned a lot from this experience. It's my first time submitting a pull request to a public project like this. And thank you for teaching me about the "forbidden fruit" hidden within ::detail and also for taking the wheel towards the end.

@gevtushenko

Copy link
Copy Markdown
Collaborator

@jecs thank you for the contribution!

@jecs
jecs deleted the device-reduce-64bit branch September 28, 2023 15:57
@elstehle elstehle mentioned this pull request Feb 21, 2024
23 of 25 tasks
gonidelis added a commit to gonidelis/cccl that referenced this pull request Mar 25, 2026
  - Retain offset_t/SegmentSizeT comments across all fixed-size env overloads
  - Retain PR NVIDIA#414 breaking-change comments in ArgMin/ArgMax env overloads
  - Refactor fixed-size ArgMin/ArgMax into shared private helpers
    (fixed_size_arg_min_dispatch, fixed_size_arg_max_dispatch) to reduce
    duplication between env and non-env overloads
gonidelis added a commit to gonidelis/cccl that referenced this pull request Mar 26, 2026
  - Retain offset_t/SegmentSizeT comments across all fixed-size env overloads
  - Retain PR NVIDIA#414 breaking-change comments in ArgMin/ArgMax env overloads
  - Refactor fixed-size ArgMin/ArgMax into shared private helpers
    (fixed_size_arg_min_dispatch, fixed_size_arg_max_dispatch) to reduce
    duplication between env and non-env overloads
gonidelis added a commit to gonidelis/cccl that referenced this pull request Apr 8, 2026
  - Retain offset_t/SegmentSizeT comments across all fixed-size env overloads
  - Retain PR NVIDIA#414 breaking-change comments in ArgMin/ArgMax env overloads
  - Refactor fixed-size ArgMin/ArgMax into shared private helpers
    (fixed_size_arg_min_dispatch, fixed_size_arg_max_dispatch) to reduce
    duplication between env and non-env overloads
bernhardmgruber pushed a commit to gonidelis/cccl that referenced this pull request Apr 9, 2026
  - Retain offset_t/SegmentSizeT comments across all fixed-size env overloads
  - Retain PR NVIDIA#414 breaking-change comments in ArgMin/ArgMax env overloads
  - Refactor fixed-size ArgMin/ArgMax into shared private helpers
    (fixed_size_arg_min_dispatch, fixed_size_arg_max_dispatch) to reduce
    duplication between env and non-env overloads
gonidelis added a commit to gonidelis/cccl that referenced this pull request Apr 13, 2026
  - Retain offset_t/SegmentSizeT comments across all fixed-size env overloads
  - Retain PR NVIDIA#414 breaking-change comments in ArgMin/ArgMax env overloads
  - Refactor fixed-size ArgMin/ArgMax into shared private helpers
    (fixed_size_arg_min_dispatch, fixed_size_arg_max_dispatch) to reduce
    duplication between env and non-env overloads
gonidelis added a commit that referenced this pull request Apr 14, 2026
* Add fixed-size segment env overloads for DeviceSegmentedReduce

* Fix critical issues plus<> specilization

* feedback address

  - Retain offset_t/SegmentSizeT comments across all fixed-size env overloads
  - Retain PR #414 breaking-change comments in ArgMin/ArgMax env overloads
  - Refactor fixed-size ArgMin/ArgMax into shared private helpers
    (fixed_size_arg_min_dispatch, fixed_size_arg_max_dispatch) to reduce
    duplication between env and non-env overloads

* Refactor

* More refactoring

* Refactor: unify fixed-size ArgMin/ArgMax dispatch into a single function

* Make using offset_t = int explicit

* Substitute cudaStream_t with cuda::stream and use always stream.sync() but outside of the literalinclude guards

* Guard Sum with sfinae

* Sfinae operator<<(os,...) for cuda::std::pairs

* Do not specialize std::plus<>

---------

Co-authored-by: Bernhard Manfred Gruber <bernhardmgruber@gmail.com>
jainishmehta pushed a commit to jainishmehta/cccl that referenced this pull request Apr 19, 2026
…A#8097)

* Add fixed-size segment env overloads for DeviceSegmentedReduce

* Fix critical issues plus<> specilization

* feedback address

  - Retain offset_t/SegmentSizeT comments across all fixed-size env overloads
  - Retain PR NVIDIA#414 breaking-change comments in ArgMin/ArgMax env overloads
  - Refactor fixed-size ArgMin/ArgMax into shared private helpers
    (fixed_size_arg_min_dispatch, fixed_size_arg_max_dispatch) to reduce
    duplication between env and non-env overloads

* Refactor

* More refactoring

* Refactor: unify fixed-size ArgMin/ArgMax dispatch into a single function

* Make using offset_t = int explicit

* Substitute cudaStream_t with cuda::stream and use always stream.sync() but outside of the literalinclude guards

* Guard Sum with sfinae

* Sfinae operator<<(os,...) for cuda::std::pairs

* Do not specialize std::plus<>

---------

Co-authored-by: Bernhard Manfred Gruber <bernhardmgruber@gmail.com>
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