Repository navigation
Improve thrust::cuda_cub::replace functor handling - #5949
Merged
Merged
Conversation
thrust::cuda_cub::replace functors
thrust::cuda_cub::replace functorsthrust::cuda_cub::replace functor handling
fbusato
approved these changes
Sep 19, 2025
|
|
||
| THRUST_DEVICE_FUNCTION auto operator()() const -> T | ||
| template <typename... Args> | ||
| THRUST_DEVICE_FUNCTION auto operator()(Args&&...) const -> T |
Contributor
There was a problem hiding this comment.
Confused by THRUST_DEVICE_FUNCTION in CUB
Contributor
Author
There was a problem hiding this comment.
yeah, that makes no sense! :D Fixed.
|
|
||
| _CCCL_BEGIN_NAMESPACE_CUDA | ||
| template <typename T> | ||
| struct proclaims_copyable_arguments<CUB_NS_QUALIFIER::detail::__return_constant<T>> : ::cuda::std::true_type |
Contributor
There was a problem hiding this comment.
can we use cub::detail:: instead?
Contributor
Author
There was a problem hiding this comment.
I don't think so. If the user uses a wrapped namespace for cub, then __return_constant would live in user_defined_ns::cub::detail. Since we are completely outside this namespace, lookup would not find it.
Reuse functors which exist and proclaim they have copyable arguments when possible
bernhardmgruber
force-pushed
the
proclaim_replace
branch
from
September 19, 2025 20:49
69425e0 to
bf50f3c
Compare
This comment has been minimized.
This comment has been minimized.
miscco
approved these changes
Sep 22, 2025
miscco
approved these changes
Sep 22, 2025
bernhardmgruber
enabled auto-merge (squash)
September 22, 2025 07:46
Contributor
🥳 CI Workflow Results🟩 Finished in 3h 40m: Pass: 100%/185 | Total: 6d 09h | Max: 3h 31m | Hits: 61%/186335See results here. |
pciolkosz
pushed a commit
to pciolkosz/cccl
that referenced
this pull request
Sep 24, 2025
Reuse functors which exist and proclaim they have copyable arguments when possible Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>
Naraenda
pushed a commit
to ROCm/rocm-libraries
that referenced
this pull request
Oct 26, 2026
…eplace` functor handling (NVIDIA/cccl#5949) Upstream: NVIDIA/cccl@1ceac37 - Generic `detail/internal_functional.h`: added `new_value_if_f` (`_CCCL_DEVICE_API` spelled `THRUST_DEVICE`) and `proclaims_copyable_arguments` specializations for `predicate_to_integral`, `tuple_binary_predicate`, `new_value_if_f`; specializations placed in `_THRUST_LIBCXX_NAMESPACE_BEGIN/END` or `namespace internal` (fallback), matching `zip_function.h`; address_stability pulled in via `thrust/detail/libcxx_wrapper/__functional/address_stability.h` instead of the cuda include. - cuda `replace.h` merged cleanly: uses `thrust::detail::new_value_if_f` with `cuda_cub::transform`, dropping its local functor. - HIP counterpart: no change: performance-only (copyable-argument proclamation only feeds CUDA DeviceTransform); `system/hip/detail/replace.h` keeps `__replace::new_value_if_f`. cub `device_transform.cuh` change belongs to hipCUB. - test/ counterpart: none; testing/ counterpart: none (no upstream test changes). - 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
…ty in internal_functional Related upstream commit: 1ceac3731d5 Improve `thrust::cuda_cub::replace` functor handling (NVIDIA/cccl#5949) Related local port commit: 3adee1d libhipcxx is now mandatory, so internal_functional.h includes _THRUST_LIBCXX_INCLUDE(__functional/address_stability.h) directly (upstream <cuda/__functional/address_stability.h>) instead of the libcxx_wrapper header, and the proclaims_copyable_arguments specializations for predicate_to_integral, tuple_binary_predicate and new_value_if_f are only declared in the libcxx namespace (the `namespace internal` fallback is removed). 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
…d new_value_if_f Related upstream commit: 1ceac3731d5 Improve `thrust::cuda_cub::replace` functor handling (NVIDIA/cccl#5949) Related local port commit: 3d25701 The local port added the generic thrust::detail::new_value_if_f (with its proclaims_copyable_arguments specialization) to detail/internal_functional.h and moved system/cuda onto it, but left system/hip on its own copy as "no change: performance-only". Bring system/hip in line: - Drop hip's private __replace::new_value_if_f; replace_copy_if uses thrust::detail::new_value_if_f, as upstream's cuda backend does. - replace() uses thrust::detail::equal_to_value<T> instead of the `_1 == old_value` placeholder expression, as upstream. - __replace::constant_f is kept: upstream switched to CUB's detail::__return_constant, which has no rocThrust/libhipcxx equivalent. 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
…eplace` functor handling (NVIDIA/cccl#5949) Upstream: NVIDIA/cccl@1ceac37 - Generic `detail/internal_functional.h`: added `new_value_if_f` (`_CCCL_DEVICE_API` spelled `THRUST_DEVICE`) and `proclaims_copyable_arguments` specializations for `predicate_to_integral`, `tuple_binary_predicate`, `new_value_if_f`; specializations placed in `_THRUST_LIBCXX_NAMESPACE_BEGIN/END` or `namespace internal` (fallback), matching `zip_function.h`; address_stability pulled in via `thrust/detail/libcxx_wrapper/__functional/address_stability.h` instead of the cuda include. - cuda `replace.h` merged cleanly: uses `thrust::detail::new_value_if_f` with `cuda_cub::transform`, dropping its local functor. - HIP counterpart: no change: performance-only (copyable-argument proclamation only feeds CUDA DeviceTransform); `system/hip/detail/replace.h` keeps `__replace::new_value_if_f`. cub `device_transform.cuh` change belongs to hipCUB. - test/ counterpart: none; testing/ counterpart: none (no upstream test changes). - 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
…eplace` functor handling (NVIDIA/cccl#5949) Upstream: NVIDIA/cccl@1ceac37 - Generic `detail/internal_functional.h`: added `new_value_if_f` (`_CCCL_DEVICE_API` spelled `THRUST_DEVICE`) and `proclaims_copyable_arguments` specializations for `predicate_to_integral`, `tuple_binary_predicate`, `new_value_if_f`; specializations placed in `_THRUST_LIBCXX_NAMESPACE_BEGIN/END` or `namespace internal` (fallback), matching `zip_function.h`; address_stability pulled in via `thrust/detail/libcxx_wrapper/__functional/address_stability.h` instead of the cuda include. - cuda `replace.h` merged cleanly: uses `thrust::detail::new_value_if_f` with `cuda_cub::transform`, dropping its local functor. - HIP counterpart: no change: performance-only (copyable-argument proclamation only feeds CUDA DeviceTransform); `system/hip/detail/replace.h` keeps `__replace::new_value_if_f`. cub `device_transform.cuh` change belongs to hipCUB. - test/ counterpart: none; testing/ counterpart: none (no upstream test changes). - 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
…ty in internal_functional Related upstream commit: 1ceac3731d5 Improve `thrust::cuda_cub::replace` functor handling (NVIDIA/cccl#5949) Related local port commit: 3adee1d libhipcxx is now mandatory, so internal_functional.h includes _THRUST_LIBCXX_INCLUDE(__functional/address_stability.h) directly (upstream <cuda/__functional/address_stability.h>) instead of the libcxx_wrapper header, and the proclaims_copyable_arguments specializations for predicate_to_integral, tuple_binary_predicate and new_value_if_f are only declared in the libcxx namespace (the `namespace internal` fallback is removed). 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
…d new_value_if_f Related upstream commit: 1ceac3731d5 Improve `thrust::cuda_cub::replace` functor handling (NVIDIA/cccl#5949) Related local port commit: 3d25701 The local port added the generic thrust::detail::new_value_if_f (with its proclaims_copyable_arguments specialization) to detail/internal_functional.h and moved system/cuda onto it, but left system/hip on its own copy as "no change: performance-only". Bring system/hip in line: - Drop hip's private __replace::new_value_if_f; replace_copy_if uses thrust::detail::new_value_if_f, as upstream's cuda backend does. - replace() uses thrust::detail::equal_to_value<T> instead of the `_1 == old_value` placeholder expression, as upstream. - __replace::constant_f is kept: upstream switched to CUB's detail::__return_constant, which has no rocThrust/libhipcxx equivalent. 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
…eplace` functor handling (NVIDIA/cccl#5949) Upstream: NVIDIA/cccl@1ceac37 - Generic `detail/internal_functional.h`: added `new_value_if_f` (`_CCCL_DEVICE_API` spelled `THRUST_DEVICE`) and `proclaims_copyable_arguments` specializations for `predicate_to_integral`, `tuple_binary_predicate`, `new_value_if_f`; specializations placed in `_THRUST_LIBCXX_NAMESPACE_BEGIN/END` or `namespace internal` (fallback), matching `zip_function.h`; address_stability pulled in via `thrust/detail/libcxx_wrapper/__functional/address_stability.h` instead of the cuda include. - cuda `replace.h` merged cleanly: uses `thrust::detail::new_value_if_f` with `cuda_cub::transform`, dropping its local functor. - HIP counterpart: no change: performance-only (copyable-argument proclamation only feeds CUDA DeviceTransform); `system/hip/detail/replace.h` keeps `__replace::new_value_if_f`. cub `device_transform.cuh` change belongs to hipCUB. - test/ counterpart: none; testing/ counterpart: none (no upstream test changes). - 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
…eplace` functor handling (NVIDIA/cccl#5949) Upstream: NVIDIA/cccl@1ceac37 - Generic `detail/internal_functional.h`: added `new_value_if_f` (`_CCCL_DEVICE_API` spelled `THRUST_DEVICE`) and `proclaims_copyable_arguments` specializations for `predicate_to_integral`, `tuple_binary_predicate`, `new_value_if_f`; specializations placed in `_THRUST_LIBCXX_NAMESPACE_BEGIN/END` or `namespace internal` (fallback), matching `zip_function.h`; address_stability pulled in via `thrust/detail/libcxx_wrapper/__functional/address_stability.h` instead of the cuda include. - cuda `replace.h` merged cleanly: uses `thrust::detail::new_value_if_f` with `cuda_cub::transform`, dropping its local functor. - HIP counterpart: no change: performance-only (copyable-argument proclamation only feeds CUDA DeviceTransform); `system/hip/detail/replace.h` keeps `__replace::new_value_if_f`. cub `device_transform.cuh` change belongs to hipCUB. - test/ counterpart: none; testing/ counterpart: none (no upstream test changes). - 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
…ty in internal_functional Related upstream commit: 1ceac3731d5 Improve `thrust::cuda_cub::replace` functor handling (NVIDIA/cccl#5949) Related local port commit: 3adee1d libhipcxx is now mandatory, so internal_functional.h includes _THRUST_LIBCXX_INCLUDE(__functional/address_stability.h) directly (upstream <cuda/__functional/address_stability.h>) instead of the libcxx_wrapper header, and the proclaims_copyable_arguments specializations for predicate_to_integral, tuple_binary_predicate and new_value_if_f are only declared in the libcxx namespace (the `namespace internal` fallback is removed). 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
…d new_value_if_f Related upstream commit: 1ceac3731d5 Improve `thrust::cuda_cub::replace` functor handling (NVIDIA/cccl#5949) Related local port commit: 3d25701 The local port added the generic thrust::detail::new_value_if_f (with its proclaims_copyable_arguments specialization) to detail/internal_functional.h and moved system/cuda onto it, but left system/hip on its own copy as "no change: performance-only". Bring system/hip in line: - Drop hip's private __replace::new_value_if_f; replace_copy_if uses thrust::detail::new_value_if_f, as upstream's cuda backend does. - replace() uses thrust::detail::equal_to_value<T> instead of the `_1 == old_value` placeholder expression, as upstream. - __replace::constant_f is kept: upstream switched to CUB's detail::__return_constant, which has no rocThrust/libhipcxx equivalent. Not compiled, tests not run (per human) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reuse functors which exist and proclaim they have copyable arguments when possible.
This is a utility PR in the context of #5179.