Repository navigation
Unpack launch()'s kernel arguments with cuda::std::apply - #10796
Conversation
launch_kernel received a std::tuple and unpacked it with std::apply, which libstdc++ declares host-only. nvcc lets that slide because --expt-relaxed-constexpr admits host constexpr functions in device code; clang-cuda has no such escape hatch and rejects every launch() in the tree. Hand the kernel a cuda::std::tuple instead, built by a small helper at the two launch sites and named by the two occupancy queries, so the type the kernel is instantiated with still matches the one launched. data2inst keeps building a std::tuple: the helper is the boundary where host plumbing becomes a kernel argument.
|
/ok to test 9e1f736 |
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesKernel argument migration
Suggested reviewers: Mergeability Score: 🔵 Low · up to The change is localized and well validated, but merge should include owner follow-up to mark the host-only tuple helper explicitly and add its direct standard-library header dependencies. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cudax/include/cuda/experimental/__stf/internal/launch.cuh (1)
23-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winsuggestion: Add direct host tuple headers.
__make_kernel_argsnow names::std::tuple,::std::apply, and::std::forward, but these lines add only thecuda::stdtuple headers. Add direct<tuple>and<utility>includes solaunch.cuhdoes not depend on transitive STF includes.As per coding guidelines, “Include all headers needed by the symbols being used; do not rely on transitive includes.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 93120744-4813-43cc-ada6-2bc7f47c52e3
📒 Files selected for processing (1)
cudax/include/cuda/experimental/__stf/internal/launch.cuh
|
/ok to test b1f55be |
This comment has been minimized.
This comment has been minimized.
|
/ok to test 7f9f534 |
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 42m: Pass: 100%/63 | Total: 10h 01m | Max: 1h 01m | Hits: 98%/37556See results here. AI failure analysis1. CUDA 13.3 rejects RAFT kernel argument address conversion · 1 jobExplanation: While compiling cuML, NVCC rejects RAFT's conversion of kernel-parameter addresses to `void*` in `raft::detail::dispatch`. The same template defect appears across several TSNE and UMAP instantiations and stops the cuML build. Evidence: Build RAPIDS (optional) / rmm ucxx raft cuvs nvforest cuml, step 6 Root cause: The floating RAPIDS dependencies contain a RAFT kernel-launch implementation whose `std::addressof(params)` conversion is not accepted by NVCC 13.3 for qualified parameter types. The PR changes only the CUDA STF launch header and does not appear in the failing instantiation chain; a base-commit comparison or RAFT history is needed to identify the exact upstream regression. Sources: ci/rapids/cuda13.3-conda/devcontainer.json:17, ci/rapids/post-create-command.sh:141. Suggested next steps: Reproduce 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'`, then compare the base commit using the same RAPIDS revisions. If confirmed external, consume or pin a RAFT revision that uses a CUDA-13.3-safe kernel-argument pointer conversion. 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>
Second 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, which fixed portability slips in the tests; this one is in the library.launch_kerneltook astd::tupleby value and unpacked it withstd::apply. libstdc++ declaresstd::applyhost-only, so device code has no business calling it. nvcc lets it pass because--expt-relaxed-constexpradmits hostconstexprfunctions in device code; clang-cuda has no such escape hatch and rejects everyctx.launchin the tree.The kernel now receives a
cuda::std::tupleand unpacks it withcuda::std::apply. A smallreserved::__make_kernel_argshelper builds it at the two launch sites (launch_implandgraph_launch_impl) and is named by the two occupancy queries, so the instantiation whose occupancy is queried stays the one that gets launched.data2instkeeps producing astd::tuple: the helper is precisely the boundary where host plumbing turns into a kernel argument, so nothing else has to change.Validation
A clang-cuda
-fsyntax-onlysweep (clang 21, CTK 12,sm_75) over all 283 STF tests and examples goes from 50 failures to 33, with no regressions. The 17 that flip are everyctx.launchuser plus the standalonereserved::launch, across both the stream and graph backends.nvcc 13.2 still compiles the launch path (C++17,
sm_90), and four representative tests coveringlaunch_implandgraph_launch_implbuild and run correctly on an RTX 3070:01-axpy-launch,launch_sum,standalone-launches, andgraph/many.pre-commitpasses.What the remaining 33 are
Only five still need real work, so this is close to the end of the road for the source fixes:
<unistd.h>, unqualifiedmin).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 of them fail on the wrong diagnostic under clang (a deleted copy constructor rather than the expectedstatic_assert), which the xfail regex would need to accommodate.launch_scan.cureachescore.cuh'stuple_prependfrom device code throughthread_hierarchy::apply_partition, which needs the same treatment as this PR one level down;parallel_for_2D.cu,parallel_for_host.cu, andtest2_parallel_for_context.cucall a hostoperator()from host-device code; andfrozen_data_init.cudoes the same withoperator->*.