Skip to content

Conversation

@Flawxd
Copy link

@Flawxd Flawxd commented Jan 6, 2026

Following #724

Modernizes the thrust/examples/word_count.cu example by replacing the functor struct is_word_start with an extended lambda
to align with modern C++ practices and to make it easier to read

Changes:

Replaced struct is_word_start with a host device lambda.

Replaced C-style array pointer arithmetic with std::begin() and std::end() for safer iterator access.

The code was verified using a T4 GPU and ran perfectly

@Flawxd Flawxd requested a review from a team as a code owner January 6, 2026 22:27
@Flawxd Flawxd requested a review from alliepiper January 6, 2026 22:27
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jan 6, 2026
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Jan 6, 2026

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.

@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Jan 6, 2026
@bernhardmgruber
Copy link
Contributor

/ok to test e89e7c2

Flawxd and others added 2 commits January 6, 2026 23:55
Co-authored-by: Bernhard Manfred Gruber <bernhardmgruber@gmail.com>
@github-actions

This comment has been minimized.

bernhardmgruber and others added 2 commits January 7, 2026 12:12
Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>
Co-authored-by: Michael Schellenberger Costa <miscco@nvidia.com>
@bernhardmgruber
Copy link
Contributor

/ok to test a104277

@bernhardmgruber
Copy link
Contributor

pre-commit.ci autofix

@bernhardmgruber
Copy link
Contributor

From the CI:

 /home/coder/cccl/thrust/examples/word_count.cu(31): error: __host__ or __device__ annotation on lambda requires --extended-lambda nvcc flag
      auto is_word_start = [] __attribute__((host)) __attribute__((device))(const char& left, const char& right) {
                                                                        ^

Please add a new file thrust/examples/word_count.cmake with content:

target_compile_options(
  ${example_target}
  PRIVATE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>: --extended-lambda>
)

@bernhardmgruber
Copy link
Contributor

The code was verified using a T4 GPU and ran perfectly

@Flawxd I wonder how you verfied this, because the example in the PR cannot be compiled without --extended-lambda. Please make sure you test compiling the example with our build system!

@Flawxd
Copy link
Author

Flawxd commented Jan 7, 2026

@Flawxd I wonder how you verfied this, because the example in the PR cannot be compiled without --extended-lambda. Please make sure you test compiling the example with our build system!

Yes, I did test it using --extend-lambda, it was an oversight from me to not include it in a cmake file, I'll push the new file

@bernhardmgruber
Copy link
Contributor

pre-commit.ci autofix

@bernhardmgruber
Copy link
Contributor

/ok to test 3f87a1d

@github-actions

This comment has been minimized.

@bernhardmgruber
Copy link
Contributor

Please also add this to the cmake file:

  # When clang >= 13 is used as host compiler, we get the following warning:
  #   nvcc_internal_extended_lambda_implementation:312:22: error: definition of implicit copy constructor for '__nv_hdl_wrapper_t<false, true, false, __nv_dl_tag<void (*)(), &TestAddressStabilityLambda, 2>, int (const int &)>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  #   312 | __nv_hdl_wrapper_t & operator=(const __nv_hdl_wrapper_t &in) = delete;
  #   |                      ^
  # Let's suppress it until NVBug 4980157 is resolved.
  target_compile_options(
    ${test_target}
    PRIVATE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:-Wno-deprecated-copy>
  )

we already have this fix in other places.

@Flawxd
Copy link
Author

Flawxd commented Jan 7, 2026

Hello, isnt the correct variable example_target instead of test_target ?
Also, from what I can see the warning only appears for clang >=13 so shouldnt we test and apply only after seeing that the version is greater than 12 ? so something like

target_compile_options(
  ${example_target}
  PRIVATE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>: --extended-lambda>
)

if (
  "Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID}"
  AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13
)
  # When clang >= 13 is used as host compiler, we get the following warning:
  #   nvcc_internal_extended_lambda_implementation:312:22: error: definition of implicit copy constructor for '__nv_hdl_wrapper_t<false, true, false, __nv_dl_tag<void (*)(), &TestAddressStabilityLambda, 2>, int (const int &)>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  #   312 | __nv_hdl_wrapper_t & operator=(const __nv_hdl_wrapper_t &in) = delete;
  #       |                      ^
  # Let's suppress it until NVBug 4980157 is resolved.
  target_compile_options(
    ${example_target}
    PRIVATE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>: -Wno-deprecated-copy>
  )
endif()

@bernhardmgruber
Copy link
Contributor

Hello, isnt the correct variable example_target instead of test_target

Correct. I copied this from a test.

Also, from what I can see the warning only appears for clang >=13 so shouldnt we test and apply only after seeing that the version is greater than 12 ?

Yes, but this may be trickier than it sounds. CMAKE_CXX_COMPILER_ID is CMake's C++ compiler and this could be a different compiler than the CMAKE_CUDA_HOST_COMPILER. We guard against this somewhere in CMake, but if you take the example CMake scripts out of context, they could be different. Recent versions of CMake allow better inspection of the host compiler, but then we need to handle different versions of CMake. It's just a lot easier to just disable the warning for nvcc.

@Flawxd
Copy link
Author

Flawxd commented Jan 7, 2026

Alright then, I'll do what you suggested with the correct variable

@bernhardmgruber
Copy link
Contributor

/ok to test 3fd0ed9

@github-actions

This comment has been minimized.

@bernhardmgruber
Copy link
Contributor

/ok to test e92d109

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

😬 CI Workflow Results

🟥 Finished in 2h 24m: Pass: 80%/51 | Total: 22h 43m | Max: 2h 23m | Hits: 91%/96087

See results here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants