Skip to content

Dropped duplicated math function from Thrust - #6188

Merged
bernhardmgruber merged 27 commits into
NVIDIA:mainfrom
viralbhadeshiya:FEA/6104
Oct 20, 2025
Merged

bernhardmgruber merged 27 commits into
NVIDIA:mainfrom
viralbhadeshiya:FEA/6104

Conversation

@viralbhadeshiya

@viralbhadeshiya viralbhadeshiya commented Oct 10, 2025 •

Copy link
Copy Markdown
Contributor

Description

closes #6104

  • Removed duplicated math function from Thrust
  • Moved all duplicated math function call from Thrust to cuda/std or cuda

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 Oct 10, 2025

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.

@github-project-automation github-project-automation Bot moved this to Todo in CCCL Oct 10, 2025
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Oct 10, 2025

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

#include <thrust/detail/integer_math.h>

from files where we no longer need it.

Comment thread thrust/thrust/detail/integer_math.h Resolved

@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 working on this issue. It is already looking great.

I found one incorrect replacement and some potential conversion issues

Comment thread thrust/thrust/mr/disjoint_pool.h Resolved
@github-project-automation github-project-automation Bot moved this from In Review to In Progress in CCCL Oct 11, 2025
@viralbhadeshiya

Copy link
Copy Markdown
Contributor Author

@bernhardmgruber @miscco all changes that you guys suggested is done, lmk if there are more Changes. :)

@miscco

miscco commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

@viralbhadeshiya This looks great 🎉

Thanks a lot for working on this.

I added a few minor changes:

  • dropped unused is_odd
  • improved is_negative
  • dropped two more includes

@miscco

miscco commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

/ok to test 07b811c

@github-actions

This comment has been minimized.

@miscco

miscco commented Oct 16, 2025

Copy link
Copy Markdown
Contributor

/ok to test 34fc385

@github-actions

This comment has been minimized.

@miscco

miscco commented Oct 17, 2025 •

Copy link
Copy Markdown
Contributor

@fbusato There is an issue with thrust::pool_options

I suspect there is a differing behavior for is_power_of_two could you please inevestigate why it differs?

@fbusato

fbusato commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

::cuda::is_power_of_two correctly evaluates 0 as non-power of two, while thrust::detail::is_power_of_2() misses the check x != 0.

This causes a different behavior in !::cuda::is_power_of_two(alignment), which is initialized to 0 by default.
https://github.com/NVIDIA/cccl/pull/6188/files#diff-d85bf89d70ec2f2a069c4c0ffeccd2722fe2a108a012566503392885900f40a1R115

@fbusato fbusato assigned viralbhadeshiya and unassigned fbusato Oct 17, 2025
@fbusato

fbusato commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

@viralbhadeshiya my suggestion is just to add the condition alignment != 0 && !::cuda::is_power_of_two(alignment)

@viralbhadeshiya

Copy link
Copy Markdown
Contributor Author

::cuda::is_power_of_two correctly evaluates 0 as non-power of two, while thrust::detail::is_power_of_2() misses the check x != 0.

This causes a different behavior in !::cuda::is_power_of_two(alignment), which is initialized to 0 by default. https://github.com/NVIDIA/cccl/pull/6188/files#diff-d85bf89d70ec2f2a069c4c0ffeccd2722fe2a108a012566503392885900f40a1R115

@fbusato would this similar changes also required in !::cuda::is_power_of_two(smallest_block_size) & !::cuda::is_power_of_two(largest_block_size)?

@fbusato

fbusato commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

yes, but I'm not sure that this edge case is evaluated in the test case. You can also run the test locally to make sure it works

@viralbhadeshiya

Copy link
Copy Markdown
Contributor Author

yes, but I'm not sure that this edge case is evaluated in the test case. You can also run the test locally to make sure it works

Okay made changes, unfortunately my remote server which had NVIDIA device is facing some issue so could not run tests. but changes are done.

@fbusato

fbusato commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

/ok to test 0ab0b72

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 4h 29m: Pass: 100%/118 | Total: 3d 10h | Max: 4h 28m | Hits: 90%/166971

See results here.

@bernhardmgruber
bernhardmgruber merged commit 5303f65 into NVIDIA:main Oct 20, 2025
128 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Oct 20, 2025
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 26, 2026
…tion from Thrust (NVIDIA/cccl#6188)

Upstream: NVIDIA/cccl@5303f65

Partial: upstream deletes thrust/detail/integer_math.h and switches execute_with_allocator.h / mr/{pool,disjoint_pool,pool_options}.h to ::cuda::ceil_div / ceil_ilog2 / is_power_of_two. Kept integer_math.h and the thrust::detail helpers in generic headers for compatibility (those ::cuda:: cmath utilities are unavailable without libhipcxx; behaviour is identical). system/cuda: dropped the now-redundant integer_math.h include from scan.h/sort.h (is_negative still reaches scan.h via dispatch.h); cuda dispatch.h keeps including integer_math.h instead of defining its own is_negative, which would collide with integer_math.h's overloads. HIP: no change (hip dispatch.h still uses thrust::detail::is_negative from integer_math.h). test/: no counterpart. testing/: no counterpart. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
amd-jmahovsky added a commit to ROCm/rocm-libraries that referenced this pull request Oct 28, 2026
…function from Thrust (NVIDIA/cccl#6188)

Upstream: NVIDIA/cccl@5303f65

Completes the earlier partial port. libhipcxx is now mandatory (libcxx.h requires >= 3.4), so the
compatibility reason for keeping thrust::detail integer helpers no longer applies:
- delete thrust/detail/integer_math.h.
- execute_with_allocator.h: divide_ri -> _THRUST_LIBCXX::ceil_div.
- mr/{pool,disjoint_pool}.h: log2_ri -> _THRUST_LIBCXX::ceil_ilog2, is_power_of_2 -> _THRUST_LIBCXX::is_power_of_two.
- mr/pool_options.h: validate() uses is_power_of_two with the upstream explicit != 0 checks.
- system/cuda/detail/dispatch.h: take upstream (defines its own thrust::detail::is_negative).
- system/hip/detail/dispatch.h: same is_negative, spelled with _THRUST_STD/THRUST_HOST_DEVICE;
  hip scan.h/sort.h drop the integer_math.h include.
Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 29, 2026
…tion from Thrust (NVIDIA/cccl#6188)

Upstream: NVIDIA/cccl@5303f65

Partial: upstream deletes thrust/detail/integer_math.h and switches execute_with_allocator.h / mr/{pool,disjoint_pool,pool_options}.h to ::cuda::ceil_div / ceil_ilog2 / is_power_of_two. Kept integer_math.h and the thrust::detail helpers in generic headers for compatibility (those ::cuda:: cmath utilities are unavailable without libhipcxx; behaviour is identical). system/cuda: dropped the now-redundant integer_math.h include from scan.h/sort.h (is_negative still reaches scan.h via dispatch.h); cuda dispatch.h keeps including integer_math.h instead of defining its own is_negative, which would collide with integer_math.h's overloads. HIP: no change (hip dispatch.h still uses thrust::detail::is_negative from integer_math.h). test/: no counterpart. testing/: no counterpart. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 29, 2026
…tion from Thrust (NVIDIA/cccl#6188)

Upstream: NVIDIA/cccl@5303f65

Partial: upstream deletes thrust/detail/integer_math.h and switches execute_with_allocator.h / mr/{pool,disjoint_pool,pool_options}.h to ::cuda::ceil_div / ceil_ilog2 / is_power_of_two. Kept integer_math.h and the thrust::detail helpers in generic headers for compatibility (those ::cuda:: cmath utilities are unavailable without libhipcxx; behaviour is identical). system/cuda: dropped the now-redundant integer_math.h include from scan.h/sort.h (is_negative still reaches scan.h via dispatch.h); cuda dispatch.h keeps including integer_math.h instead of defining its own is_negative, which would collide with integer_math.h's overloads. HIP: no change (hip dispatch.h still uses thrust::detail::is_negative from integer_math.h). test/: no counterpart. testing/: no counterpart. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 29, 2026
…function from Thrust (NVIDIA/cccl#6188)

Upstream: NVIDIA/cccl@5303f65

Completes the earlier partial port. libhipcxx is now mandatory (libcxx.h requires >= 3.4), so the
compatibility reason for keeping thrust::detail integer helpers no longer applies:
- delete thrust/detail/integer_math.h.
- execute_with_allocator.h: divide_ri -> _THRUST_LIBCXX::ceil_div.
- mr/{pool,disjoint_pool}.h: log2_ri -> _THRUST_LIBCXX::ceil_ilog2, is_power_of_2 -> _THRUST_LIBCXX::is_power_of_two.
- mr/pool_options.h: validate() uses is_power_of_two with the upstream explicit != 0 checks.
- system/cuda/detail/dispatch.h: take upstream (defines its own thrust::detail::is_negative).
- system/hip/detail/dispatch.h: same is_negative, spelled with _THRUST_STD/THRUST_HOST_DEVICE;
  hip scan.h/sort.h drop the integer_math.h include.
Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 30, 2026
…tion from Thrust (NVIDIA/cccl#6188)

Upstream: NVIDIA/cccl@5303f65

Partial: upstream deletes thrust/detail/integer_math.h and switches execute_with_allocator.h / mr/{pool,disjoint_pool,pool_options}.h to ::cuda::ceil_div / ceil_ilog2 / is_power_of_two. Kept integer_math.h and the thrust::detail helpers in generic headers for compatibility (those ::cuda:: cmath utilities are unavailable without libhipcxx; behaviour is identical). system/cuda: dropped the now-redundant integer_math.h include from scan.h/sort.h (is_negative still reaches scan.h via dispatch.h); cuda dispatch.h keeps including integer_math.h instead of defining its own is_negative, which would collide with integer_math.h's overloads. HIP: no change (hip dispatch.h still uses thrust::detail::is_negative from integer_math.h). test/: no counterpart. testing/: no counterpart. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Beanavil pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 30, 2026
…tion from Thrust (NVIDIA/cccl#6188)

Upstream: NVIDIA/cccl@5303f65

Partial: upstream deletes thrust/detail/integer_math.h and switches execute_with_allocator.h / mr/{pool,disjoint_pool,pool_options}.h to ::cuda::ceil_div / ceil_ilog2 / is_power_of_two. Kept integer_math.h and the thrust::detail helpers in generic headers for compatibility (those ::cuda:: cmath utilities are unavailable without libhipcxx; behaviour is identical). system/cuda: dropped the now-redundant integer_math.h include from scan.h/sort.h (is_negative still reaches scan.h via dispatch.h); cuda dispatch.h keeps including integer_math.h instead of defining its own is_negative, which would collide with integer_math.h's overloads. HIP: no change (hip dispatch.h still uses thrust::detail::is_negative from integer_math.h). test/: no counterpart. testing/: no counterpart. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
amd-jmahovsky added a commit to ROCm/rocm-libraries that referenced this pull request Oct 30, 2026
…function from Thrust (NVIDIA/cccl#6188)

Upstream: NVIDIA/cccl@5303f65

Completes the earlier partial port. libhipcxx is now mandatory (libcxx.h requires >= 3.4), so the
compatibility reason for keeping thrust::detail integer helpers no longer applies:
- delete thrust/detail/integer_math.h.
- execute_with_allocator.h: divide_ri -> _THRUST_LIBCXX::ceil_div.
- mr/{pool,disjoint_pool}.h: log2_ri -> _THRUST_LIBCXX::ceil_ilog2, is_power_of_2 -> _THRUST_LIBCXX::is_power_of_two.
- mr/pool_options.h: validate() uses is_power_of_two with the upstream explicit != 0 checks.
- system/cuda/detail/dispatch.h: take upstream (defines its own thrust::detail::is_negative).
- system/hip/detail/dispatch.h: same is_negative, spelled with _THRUST_STD/THRUST_HOST_DEVICE;
  hip scan.h/sort.h drop the integer_math.h include.
Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.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.

[FEA]: Drop duplicated math functions from Thrust

4 participants