Skip to content

Cleanup includes in thrust - #6547

Merged
bernhardmgruber merged 1 commit into
NVIDIA:mainfrom
miscco:thrust_includes
Nov 8, 2025
Merged

bernhardmgruber merged 1 commit into
NVIDIA:mainfrom
miscco:thrust_includes

Conversation

@miscco

@miscco miscco commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

We only want to include what we need not the whole world

There are multiple cases where we only needed cuda::std::declval but included all of cuda::std::utility which is in the order of 100k LoC

@miscco
miscco requested a review from a team as a code owner November 7, 2025 11:59
@miscco
miscco requested a review from gevtushenko November 7, 2025 11:59
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Nov 7, 2025
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Nov 7, 2025
@github-actions

This comment has been minimized.

We only want to include what we need not the whole world

There are multiple cases where we only needed cuda::std::declval but included all of cuda::std::utility which is in the order of 100k LoC
@miscco
miscco requested a review from a team as a code owner November 7, 2025 16:51
@miscco
miscco requested a review from jrhemstad November 7, 2025 16:51
@github-actions

github-actions Bot commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 39m: Pass: 100%/72 | Total: 2d 02h | Max: 2h 33m | Hits: 83%/115552

See results here.

@bernhardmgruber
bernhardmgruber merged commit 4b10fd2 into NVIDIA:main Nov 8, 2025
85 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Nov 8, 2025
@alliepiper

Copy link
Copy Markdown
Contributor

This PR isn't playing nicely with #6546: https://github.com/NVIDIA/cccl/actions/runs/19197936275/job/54881673252

  FAILED: thrust/CMakeFiles/thrust.cpp.omp.cpp20.headers.base.dir/headers/thrust.cpp.omp.cpp20.headers.base/thrust/complex.h.cpp.o 
  /usr/bin/sccache /usr/bin/g++ -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -D_CCCL_NO_SYSTEM_HEADER -I/home/coder/cccl/lib/cmake/thrust/../../../thrust -I/home/coder/cccl/lib/cmake/libcudacxx/../../../libcudacxx/include -O3 -DNDEBUG -std=c++20 -fopenmp -Werror -Wall -Wextra -Wreorder -Winit-self -Woverloaded-virtual -Wcast-qual -Wpointer-arith -Wunused-local-typedefs -Wvla -Wno-gnu-line-marker -Wno-gnu-zero-variadic-macro-arguments -Wno-unused-function -Wno-noexcept-type -MD -MT thrust/CMakeFiles/thrust.cpp.omp.cpp20.headers.base.dir/headers/thrust.cpp.omp.cpp20.headers.base/thrust/complex.h.cpp.o -MF thrust/CMakeFiles/thrust.cpp.omp.cpp20.headers.base.dir/headers/thrust.cpp.omp.cpp20.headers.base/thrust/complex.h.cpp.o.d -o thrust/CMakeFiles/thrust.cpp.omp.cpp20.headers.base.dir/headers/thrust.cpp.omp.cpp20.headers.base/thrust/complex.h.cpp.o -c /home/coder/cccl/build/cuda13.0-gcc14/thrust-cpp20/thrust/headers/thrust.cpp.omp.cpp20.headers.base/thrust/complex.h.cpp
  In file included from /home/coder/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/complex/complex.inl:247,
                   from /home/coder/cccl/lib/cmake/thrust/../../../thrust/thrust/complex.h:855,
                   from /home/coder/cccl/build/cuda13.0-gcc14/thrust-cpp20/thrust/headers/thrust.cpp.omp.cpp20.headers.base/thrust/complex.h.cpp:62:
  /home/coder/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/complex/catrig.h: In function ‘thrust::complex<double> thrust::detail::complex::catanh(thrust::complex<double>)’:
  /home/coder/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/complex/catrig.h:692:42: error: ‘atanh’ is not a member of ‘cuda::std’
    692 |     return (complex<double>(::cuda::std::atanh(x), y));
        |                                          ^~~~~

@miscco
miscco deleted the thrust_includes branch November 10, 2025 07:21
@bernhardmgruber

bernhardmgruber commented Nov 10, 2025 •

Copy link
Copy Markdown
Contributor

@alliepiper I think this should be addressed by: #6563. Thx for pointing this out!

Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 26, 2026
…VIDIA/cccl#6547)

Upstream: NVIDIA/cccl@4b10fd2

HIP counterpart (system/hip): none needed; system/cuda include cleanup taken as upstream. Generic headers: took trait modernization (is_x_v, enable_if_t, add_lvalue_reference_t) and binary_search_less -> _THRUST_STD::less<> (added _THRUST_STD_INCLUDE(functional)); kept local include blocks instead of upstream's granular libcu++-internal includes (would break non-libhipcxx builds); kept ::internal::is_integral/::internal::If wrappers and dual less list in cuda sort.h. test/ counterpart: none. 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
…cludes

Related upstream commit: 4b10fd26255 Cleanup includes in thrust (NVIDIA/cccl#6547)
Related local port commit: ed71224

The port kept the ::internal::is_integral / ::internal::If wrappers, the
local umbrella include blocks and the dual less/greater list in cuda
sort.h because of non-libhipcxx builds. libhipcxx is now mandatory, so:
- ::internal::is_integral(_v) -> _THRUST_STD::is_integral(_v) in
  detail/type_traits.h, detail/vector_base.inl and counting_iterator.h
  (is_integral_v in distance_to, as upstream); the now-unused
  ::internal::is_integral/is_integral_v aliases are removed.
- ::internal::If -> _THRUST_STD::_If (as upstream) in counting_iterator.h,
  iterator_adaptor_base.h, iterator_category_to_traversal.h,
  generic/reduce_by_key.inl and hip/detail/reduce_by_key.h; the
  libcxx_wrapper conditional.h includes are replaced by
  _THRUST_STD_INCLUDE(__type_traits/conditional.h). (The wrapper file
  itself stays because the dead fallback branch of the construct_at
  wrapper still includes it.)
- counting_iterator.h and iterator_adaptor_base.h take the upstream
  granular __type_traits includes (drops the rocprim/type_traits.hpp
  fallback); minimum_system.h and iterator_category_to_traversal.h drop
  the type_traits includes as upstream.
- cuda sort.h: can_use_primitive_sort uses the upstream is_same_v list
  without the duplicated _THRUST_STD:: comparators (_THRUST_STD is
  ::cuda::std there).

thrust/detail/type_traits.h keeps its _THRUST_STD_INCLUDE(type_traits)
umbrella; switching it to upstream's granular list would require the
upstream include fixups in ~100 other headers.

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
…VIDIA/cccl#6547)

Upstream: NVIDIA/cccl@4b10fd2

HIP counterpart (system/hip): none needed; system/cuda include cleanup taken as upstream. Generic headers: took trait modernization (is_x_v, enable_if_t, add_lvalue_reference_t) and binary_search_less -> _THRUST_STD::less<> (added _THRUST_STD_INCLUDE(functional)); kept local include blocks instead of upstream's granular libcu++-internal includes (would break non-libhipcxx builds); kept ::internal::is_integral/::internal::If wrappers and dual less list in cuda sort.h. test/ counterpart: none. 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
…VIDIA/cccl#6547)

Upstream: NVIDIA/cccl@4b10fd2

HIP counterpart (system/hip): none needed; system/cuda include cleanup taken as upstream. Generic headers: took trait modernization (is_x_v, enable_if_t, add_lvalue_reference_t) and binary_search_less -> _THRUST_STD::less<> (added _THRUST_STD_INCLUDE(functional)); kept local include blocks instead of upstream's granular libcu++-internal includes (would break non-libhipcxx builds); kept ::internal::is_integral/::internal::If wrappers and dual less list in cuda sort.h. test/ counterpart: none. 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
…cludes

Related upstream commit: 4b10fd26255 Cleanup includes in thrust (NVIDIA/cccl#6547)
Related local port commit: ed71224

The port kept the ::internal::is_integral / ::internal::If wrappers, the
local umbrella include blocks and the dual less/greater list in cuda
sort.h because of non-libhipcxx builds. libhipcxx is now mandatory, so:
- ::internal::is_integral(_v) -> _THRUST_STD::is_integral(_v) in
  detail/type_traits.h, detail/vector_base.inl and counting_iterator.h
  (is_integral_v in distance_to, as upstream); the now-unused
  ::internal::is_integral/is_integral_v aliases are removed.
- ::internal::If -> _THRUST_STD::_If (as upstream) in counting_iterator.h,
  iterator_adaptor_base.h, iterator_category_to_traversal.h,
  generic/reduce_by_key.inl and hip/detail/reduce_by_key.h; the
  libcxx_wrapper conditional.h includes are replaced by
  _THRUST_STD_INCLUDE(__type_traits/conditional.h). (The wrapper file
  itself stays because the dead fallback branch of the construct_at
  wrapper still includes it.)
- counting_iterator.h and iterator_adaptor_base.h take the upstream
  granular __type_traits includes (drops the rocprim/type_traits.hpp
  fallback); minimum_system.h and iterator_category_to_traversal.h drop
  the type_traits includes as upstream.
- cuda sort.h: can_use_primitive_sort uses the upstream is_same_v list
  without the duplicated _THRUST_STD:: comparators (_THRUST_STD is
  ::cuda::std there).

thrust/detail/type_traits.h keeps its _THRUST_STD_INCLUDE(type_traits)
umbrella; switching it to upstream's granular list would require the
upstream include fixups in ~100 other headers.

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 29, 2026
… cleanup

Related upstream commit: 4b10fd26255 Cleanup includes in thrust (NVIDIA/cccl#6547)
Related local port commit: ee821be

Bring the include structure of thrust/ in line with upstream v3.2.1 now
that libhipcxx is mandatory:

- Apply the upstream granular libcu++ include regions to the files touched
  by #6547 (umbrella <cuda/std/X> headers replaced by __X/*.h headers).
- Remove the ::internal:: type-trait aliases from detail/type_traits.h and
  use _THRUST_STD:: directly, matching upstream.
- Drop dead !_THRUST_HAS_DEVICE_SYSTEM_STD fallback code (thrust::swap
  fallback, aligned_storage_size fallback, actor argument variant,
  raw_reference_cast apply branch, iter_swap/swap_ranges fallbacks).
- Replace umbrella includes in the hip backend with granular headers and
  add direct includes for libcu++ symbols used by hip backend files.

Local adaptations kept: thrust/detail/memory_wrapper.h, __host_stdlib/
stdexcept, hip hints in #if 0 blocks, THRUST_COMPILER(NVRTC),
_CCCL_CUDA_COMPILATION(), the [NON-CCCL PARITY] cstddef include in
type_traits.h, erfcinv includes, and the find.h tuple umbrella.

The libcxx_wrapper directory and tests are left for a separate effort.

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
…VIDIA/cccl#6547)

Upstream: NVIDIA/cccl@4b10fd2

HIP counterpart (system/hip): none needed; system/cuda include cleanup taken as upstream. Generic headers: took trait modernization (is_x_v, enable_if_t, add_lvalue_reference_t) and binary_search_less -> _THRUST_STD::less<> (added _THRUST_STD_INCLUDE(functional)); kept local include blocks instead of upstream's granular libcu++-internal includes (would break non-libhipcxx builds); kept ::internal::is_integral/::internal::If wrappers and dual less list in cuda sort.h. test/ counterpart: none. 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
…VIDIA/cccl#6547)

Upstream: NVIDIA/cccl@4b10fd2

HIP counterpart (system/hip): none needed; system/cuda include cleanup taken as upstream. Generic headers: took trait modernization (is_x_v, enable_if_t, add_lvalue_reference_t) and binary_search_less -> _THRUST_STD::less<> (added _THRUST_STD_INCLUDE(functional)); kept local include blocks instead of upstream's granular libcu++-internal includes (would break non-libhipcxx builds); kept ::internal::is_integral/::internal::If wrappers and dual less list in cuda sort.h. test/ counterpart: none. 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
…cludes

Related upstream commit: 4b10fd26255 Cleanup includes in thrust (NVIDIA/cccl#6547)
Related local port commit: ed71224

The port kept the ::internal::is_integral / ::internal::If wrappers, the
local umbrella include blocks and the dual less/greater list in cuda
sort.h because of non-libhipcxx builds. libhipcxx is now mandatory, so:
- ::internal::is_integral(_v) -> _THRUST_STD::is_integral(_v) in
  detail/type_traits.h, detail/vector_base.inl and counting_iterator.h
  (is_integral_v in distance_to, as upstream); the now-unused
  ::internal::is_integral/is_integral_v aliases are removed.
- ::internal::If -> _THRUST_STD::_If (as upstream) in counting_iterator.h,
  iterator_adaptor_base.h, iterator_category_to_traversal.h,
  generic/reduce_by_key.inl and hip/detail/reduce_by_key.h; the
  libcxx_wrapper conditional.h includes are replaced by
  _THRUST_STD_INCLUDE(__type_traits/conditional.h). (The wrapper file
  itself stays because the dead fallback branch of the construct_at
  wrapper still includes it.)
- counting_iterator.h and iterator_adaptor_base.h take the upstream
  granular __type_traits includes (drops the rocprim/type_traits.hpp
  fallback); minimum_system.h and iterator_category_to_traversal.h drop
  the type_traits includes as upstream.
- cuda sort.h: can_use_primitive_sort uses the upstream is_same_v list
  without the duplicated _THRUST_STD:: comparators (_THRUST_STD is
  ::cuda::std there).

thrust/detail/type_traits.h keeps its _THRUST_STD_INCLUDE(type_traits)
umbrella; switching it to upstream's granular list would require the
upstream include fixups in ~100 other headers.

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
… cleanup

Related upstream commit: 4b10fd26255 Cleanup includes in thrust (NVIDIA/cccl#6547)
Related local port commit: ee821be

Bring the include structure of thrust/ in line with upstream v3.2.1 now
that libhipcxx is mandatory:

- Apply the upstream granular libcu++ include regions to the files touched
  by #6547 (umbrella <cuda/std/X> headers replaced by __X/*.h headers).
- Remove the ::internal:: type-trait aliases from detail/type_traits.h and
  use _THRUST_STD:: directly, matching upstream.
- Drop dead !_THRUST_HAS_DEVICE_SYSTEM_STD fallback code (thrust::swap
  fallback, aligned_storage_size fallback, actor argument variant,
  raw_reference_cast apply branch, iter_swap/swap_ranges fallbacks).
- Replace umbrella includes in the hip backend with granular headers and
  add direct includes for libcu++ symbols used by hip backend files.

Local adaptations kept: thrust/detail/memory_wrapper.h, __host_stdlib/
stdexcept, hip hints in #if 0 blocks, THRUST_COMPILER(NVRTC),
_CCCL_CUDA_COMPILATION(), the [NON-CCCL PARITY] cstddef include in
type_traits.h, erfcinv includes, and the find.h tuple umbrella.

The libcxx_wrapper directory and tests are left for a separate effort.

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.

3 participants