Repository navigation
Prepend to tuples without a deduction guide, so device code can too - #10801
Conversation
tuple_prepend built its result with CTAD. A deduction guide is not a constexpr function, so clang-cuda leaves it host-only even though it treats the rest of libstdc++'s constexpr tuple machinery, std::apply and std::get included, as implicitly __host__ __device__. Device code that reaches the helper therefore fails to compile: thread_hierarchy::apply_partition takes that route, and with it every launch() that partitions a shape. Naming the type keeps the previous behavior, since CTAD deduced the prefix by value just as decay_t spells it here, and matches what libcudacxx already asks for next door.
|
/ok to test 6332d4d |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesThe PR updates Tuple construction
Suggested reviewers: Mergeability Score: ⚪ Minimal · up to This localized change makes tuple construction usable in device code without changing behavior, and no actionable merge-blocking risk remains after normal checks and review. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cudax/include/cuda/experimental/__stf/utility/core.cuh (1)
223-223: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse brace initialization for the explicit tuple construction to follow the project's uniform-initialization guideline; retain
P...so thestd::tuple<T, P...>contract remains unchanged.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 5f4fdb0e-18a0-45ee-b7c2-916d39fbc7bc
📒 Files selected for processing (1)
cudax/include/cuda/experimental/__stf/utility/core.cuh
Jacob asked why not make_tuple. It does compile in device code, but it decays what it is handed, so a tail holding int& or reference_wrapper<int> comes back holding int and int& respectively, quietly dropping the aliasing that the caller passed in. tuple_cat keeps every element type, which is what the documented return type std::tuple<T, P...> promises, and it drops the apply and the lambda along the way. Only the prefix still needs its type named, for the same reason as before.
|
/ok to test 037f318 |
This comment has been minimized.
This comment has been minimized.
⏱️ CCCL compile-time benchmark comparison: Public headers compile-time benchResult: 0 regression row(s), 2 improvement row(s) above threshold.
Artifacts: reports and traces Direct file processing
🟢 Direct file processing — Improvements
|
🥳 CI Workflow Results🟩 Finished in 1h 26m: Pass: 100%/63 | Total: 1d 06h | Max: 59m 45s | Hits: 11%/201713See results here. AI failure analysis1. RAPIDS build failure has no captured diagnostic · 1 jobExplanation: The rmm/ucxx/raft/cuvs/nvforest/cuml matrix failed in step 6, but no job log was collected, so the earliest failing library, command, and compiler diagnostic cannot be determined. The PR changes only `tuple_prepend`, making its new `std::tuple_cat` expression the primary suspect but not a confirmed cause. Root cause: Unknown because `job-94599094848.log` is absent. Evidence is needed to distinguish a compilation regression caused by `std::tuple_cat` from a RAPIDS dependency, checkout, container, or infrastructure failure. Sources: cudax/include/cuda/experimental/__stf/utility/core.cuh:221. Suggested next steps: Recover the step 6 log or reproduce the CUDA 13.3 matrix with `RAPIDS_LIBS='rmm ucxx raft cuvs nvforest cuml' .devcontainer/launch.sh -d -c 13.3 -H rapids-conda -- ./ci/rapids/rapids-entrypoint.sh /bin/bash -li -c 'uninstall-all -j -qqq && clean-all -j && build-all -j0 -v'`. Capture the first failing library and diagnostic before modifying code. Copy this prompt into a coding agentJobs: |
Drop the STF exclusion from the tidy build. STF compiles under clang-cuda since the August portability series (NVIDIA#10612, NVIDIA#10793, NVIDIA#10796, NVIDIA#10801, NVIDIA#10824), and its throw sites all go through _CCCL_THROW (NVIDIA#10826), so the exception checks can see them. This first run measures the remaining tidy backlog, including the test main() functions that clang-tidy 21 flags because it ignores CheckMain. Places stays excluded here; NVIDIA#11626 handles it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Drop the STF exclusion from the tidy build. STF compiles under clang-cuda since the August portability series (NVIDIA#10612, NVIDIA#10793, NVIDIA#10796, NVIDIA#10801, NVIDIA#10824), and its throw sites all go through _CCCL_THROW (NVIDIA#10826), so the exception checks can see them. The first run measured 1237 findings in 214 TUs; the follow-up commits on this branch work through them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…11642) * Run clang-tidy over CUDA STF Drop the STF exclusion from the tidy build. STF compiles under clang-cuda since the August portability series (#10612, #10793, #10796, #10801, #10824), and its throw sites all go through _CCCL_THROW (#10826), so the exception checks can see them. The first run measured 1237 findings in 214 TUs; the follow-up commits on this branch work through them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] clang-tidy batch 1: the mechanical findings, by script From the first tidy run over STF (1237 findings, 214 TUs), the categories that a script can apply from the reported location: misc-const-correctness 690 const at the declaration bugprone-narrowing-conversions 280 explicit static_cast of the operand (whole right-hand side for integral targets; the integer leaf inside a floating expression otherwise) cert-err34-c 92 atoi/atol/atoll/atof -> std::sto* clang-diagnostic-braced-scalar-init 25 {N} -> N modernize-deprecated-headers 10 <stdio.h> -> <cstdio> etc. plus four narrowing sites with dependent target types by hand. Also: the negative-compile TUs under test/stf/static_error_checks are marked NO_CLANG_TIDY (they fail to compile on purpose), and the bugprone-exception-escape findings in exception_policy.cuh are suppressed with a stated reason: clang-tidy's device pass compiles with exceptions disabled, which makes every function implicitly non-throwing, so the unit tests that throw on purpose and the ON_THROW(abort) runner in invoke_nothrow are flagged for the throw the policy exists to catch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] clang-tidy batch 2: the findings that needed reading The remaining ~110 findings from the first tidy run over STF, each by hand or by an exact per-site substitution: modernize-loop-convert 20 range-for over the array being filled performance-inefficient-vector-op 11 reserve() before the push loop misc-predictable-rand 8 std::random_device for filenames and coin flips; a seeded std::mt19937 where the unseeded rand() was deterministic performance-unnecessary-copy-init 6 a const& where the copy was incidental; suppressed with a reason where the copy is what the test exercises performance-faster-string-find 5 (already absent after batch 1) bugprone-branch-clone 5 merged where the arms were both runtime; suppressed with a reason where one arm is constexpr bugprone-integer-division 5 floating divisor modernize-redundant-void-arg 4 modernize-use-emplace 4 modernize-min-max-use-init-list 4 performance-noexcept-move 4 noexcept, conditional on the wrapped callable for the scope-guard results bugprone-unused-return-value 3 unique_ptr::release after ownership went to the host callback: suppressed google-global-names-in-headers 3 example headers: suppressed the rest ~15 one-liners: scoped_lock, = default, self-assignment guard, fseek for rewind, using for typedef, matching override visibility, and suppressions with a stated reason for the constrained forwarding constructor and the deliberately hash-named macros One line in libcu++ (__variant/visit.h): __as_variant returns its const& parameter by design; suppressed with a reason since the STF TUs are the only ones that instantiate that overload under tidy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] clang-tidy batch 2 follow-up: one reserve per push loop, suppressions on the line they cover Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] clang-tidy batch 1 corrections: three consts the check got wrong - exception_policy.cuh: the retry counter is decremented in the catch arm; tidy only saw the instantiation where that arm is dead. - source_location.cuh: the test binds the object to with_location<widget&> and mutates it through the reference. - memory.cuh: cudaFreeHost takes void*, so a const pointee makes the introspected cuda_try form uncallable. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] clang-tidy batch 1 corrections: no const on default-initialized objects, keep the captured test constant mutable A const object of class type needs a user-provided default constructor (GCC 15 rejects event_list, whose constructor is defaulted in-class), and const buys nothing on a default-initialized handle or context anyway: reverted at all eleven such sites. parallel_for_host.cu keeps its captured constant non-const on purpose; a const literal makes the explicit capture unused and Clang 14 warns. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] restore the consts the previous correction removed from pre-existing declarations The revert of const on default-initialized objects matched twelve lines that predate the batch (members of exception_sink::sink_base, stored source_locations, a dependencies pointer, a test fixture). Back to const. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] restore sink_base's member block verbatim from trunk The previous restore mis-paired two lines in this block. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] clang-tidy corrections: keep CTAD test objects non-const where decltype(var) is asserted Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] restore two as_expected test bindings that were const on trunk Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [libcu++] __as_variant: mark the parameter _CCCL_LIFETIMEBOUND instead of suppressing the check (review) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] clang-tidy batch 3: the 58 findings of the second run - bugprone-exception-escape (26): all reported at on_throw's operator<<, the noexcept runner, for its instantiations with test lambdas that throw. In clang-tidy's device pass _CCCL_TRY expands to no catch, so the check sees the callable's throw escape the runner. One NOLINT with the reason on the runner; the per-block suppressions in the tests, which addressed the wrong location, are removed. - The runner's callable binding is back to trunk's non-const reference (a mutable callable, re-invoked by retry, needs it) and suppressed with the existing comment as the reason. - const restored on default-initialized contexts/handles/hashtables (they compile; only event_list's defaulted constructor does not, suppressed). - CTAD tests assert the const type; remaining narrowing, string-find, reserve() and branch-clone sites fixed or suppressed with a reason. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] const only on the flagged default-initialized objects, not every same-named declaration in the file Batch 3 restored const by matching the statement text, which also hit the many other 'graph_ctx ctx;' / 'stream_ctx ctx;' / handle declarations in those files whose objects are mutated. Keep const on the flagged lines only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * [STF] tidy: the reference-propagation test mutates its variable on purpose (trunk merge follow-up) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Third step toward building STF with clang-cuda, so that
bugprone-exception-escapecan eventually run over STF (ci/build_tidy.shstill sets-Dcudax_ENABLE_CUDASTF=OFF). Follows #10793 (portability slips in the tests) and #10796 (launch()'s kernel arguments).reserved::tuple_prependbuilt its result with CTAD. That was the one piece of the helper device code could not use: a deduction guide is not a constexpr function, so clang-cuda keeps it host-only, while it treats the rest of libstdc++'s constexpr tuple machinery --std::apply,std::get,std::make_tuple,std::tuple_cat-- as implicitly__host__ __device__. Isolated, the diagnostic is exactly that:std::tuple_catavoids the guide, and it lets theapplyand the lambda go too, so the body is now one line and the helper is usable from device code. That makesthread_hierarchy::apply_partitioncompile, and with it everylaunch()that partitions a shape.Element types are preserved, which is what the documented return type
std::tuple<T, P...>promises.std::make_tuplewould also have fixed the build and read a little shorter, but it decays what it is handed: a tail holdingint&comes back holdingint, so writing through the result would quietly update a copy. Details in the review thread. Only the prefix has its type named, since that is where the guide was.Worth noting what this replaces: my first instinct was to convert
tuple_prepend,reserved::make_tuple, andmake_tuple_indexwisetocuda::std::tuple, which would have rippled throughstream_task,graph_task,task_dep, andparallel_for. None of that is needed -- the deduction guide was the only host-only element in the chain.Validation
launch_scan.cuis the only file in the tree that reachestuple_prependfrom device code, and it needs #10796 as well, so on top ofmainalone this change flips nothing in the sweep. With #10796 applied, a clang-cuda-fsyntax-onlysweep (clang 21, CTK 12,sm_75) over all 283 STF tests and examples goes from 33 failures to 24, with no regressions: the eight #10793 fixes, pluslaunch_scan.cufor this one. I verified separately that the explicit-type,make_tuple, andtuple_catspellings all instantiate from a__global__under clang-cuda, and that CTAD does not.tuple_prependis used by the stream, graph, host-launch, and launch paths, so nvcc 13.2 (C++17,sm_86) builds a representative spread of all four, and they run correctly on an RTX 3070:01-axpy,02-axpy-host_launch,01-axpy-parallel_for,launch_scan,graph/many, andstandalone-launches. The header unit tests forcore.cuh,context.cuh(which coversmake_tuple_indexwise) andthread_hierarchy.cuh(which coversapply_partition) build and pass.pre-commitpasses.What the remaining 24 are
The source fixes are done. Nothing left is mechanical:
algorithm.cuh, whose include instf.cuhis commented out, so they do not compile with nvcc either.static_error_checksxfail tests, which are supposed to fail to compile. Two fail on the wrong diagnostic under clang (a deleted copy constructor rather than the expectedstatic_assert), which the xfail regex would need to accommodate.parallel_for_2D.cu,parallel_for_host.cu,test2_parallel_for_context.cu, andfrozen_data_init.curunparallel_foronexec_place::host()with lambdas that call host-only code such asEXPECT.parallel_forpicks the host branch at run time, so the device branch is instantiated regardless, and clang compiles it. nvcc is spared because an unannotated lambda is host-only there, so__nv_is_extended_host_device_lambda_closure_typeis false and the device branch is discarded. Clang has no equivalent trait and, per its maintainers, treats every lambda as__host__ __device__-- "all lambdas in clang are extended lambdas in NVCC's terms" -- so STF cannot tell a host-only lambda from a device-capable one. Making the device branch's instantiation depend on the execution place being known at compile time would fix it; short of that, those four are a documented limitation. I would rather settle that in its own PR than smuggle it in here.