Implement a kernel dispatcher raft::launch_kernel - #3104
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe pull request adds a typed RAFT CUDA kernel-launch utility with source-location error reporting. It migrates production and test CUDA launches to the utility, adds launcher tests, wires the test target, and documents the API. ChangesKernel launch migration
Estimated code review effort: 4 (Complex) | ~60 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cpp/include/raft/common/detail/scatter.cuh`:
- Around line 40-41: Guard every listed zero-size launch before calling
raft::launch_kernel to prevent invalid CUDA configurations: scatter.cuh
dispatch, sparse/convert/detail/dense.cuh when nrows == 0, sparse/detail/csr.cuh
when N == 0 and for batch_size == 0, both sparse/linalg/detail/add.cuh launches
when m == 0, all three sparse/linalg/detail/degree.cuh launches when nnz == 0,
svds_sign_correction.cuh when k == 0, matrix_wrappers.hpp when n == 0, and both
contingencyMatrix.cuh launches when nSamples == 0. Preserve any required
empty-output initialization and reject or otherwise explicitly handle zero batch
sizes.
In `@cpp/include/raft/sparse/solver/detail/lanczos.cuh`:
- Around line 162-165: Update the kernel launch for kernel_triangular_populate
so raft::launch_kernel receives numBlocks as the grid argument and blockSize as
the block-size argument. Preserve the existing kernel arguments and launch
configuration otherwise.
In `@cpp/include/raft/stats/detail/mutual_info_score.cuh`:
- Around line 154-161: Make synchronization an explicit opt-in in
kernel_launcher::dispatch while keeping its default asynchronous. Update the
launches in cpp/include/raft/stats/detail/mutual_info_score.cuh:154-161,
neighborhood_recall.cuh:103-110, rand_index.cuh:143-149, scores.cuh:167-172, and
silhouette_score.cuh:250-257 to retain asynchronous submission; likewise
preserve asynchronous submission for both batch kernels in
trustworthiness_score.cuh:184-197. Ensure the scores launch remains asynchronous
before queued copies.
In `@cpp/include/raft/util/cache.cuh`:
- Around line 257-266: Add an early return for n == 0 in the function containing
the get_cache_idx launch, before calling raft::launch_kernel. Match the existing
empty-input behavior in AssignCacheIdx, while preserving the current launch path
for positive n.
In `@cpp/include/raft/util/kernel_launch.hpp`:
- Around line 186-204: Add Doxygen comments for both public launch_kernel
overloads, distinguishing the resources and rmm::cuda_stream_view parameters.
Document stream ordering, the shared_mem_bytes dynamic shared-memory argument,
kernel-launch error behavior, and automatic source-location capture without
changing implementation behavior.
- Around line 151-154: Update dispatch in the kernel-launch path to validate
grid and block dimensions before calling cudaLaunchKernel, rejecting zero
blocks/threads and other invalid launch dimensions. At callers where empty input
is valid, especially the map flow producing blocks == 0, return before invoking
dispatch; preserve normal launches for positive valid dimensions.
In `@cpp/tests/core/interruptible.cu`:
- Around line 112-120: Update kernel_launcher::dispatch so debug builds perform
only nonblocking launch-error checking instead of calling cudaStreamSynchronize,
preserving asynchronous stream ordering. Keep the explicit
interruptible::synchronize calls in the test and retain synchronization behavior
only at call sites that require GPU completion.
In `@cpp/tests/linalg/gemm_layout.cu`:
- Around line 87-96: Replace default-stream launches with resource-owned
streams: in cpp/tests/linalg/gemm_layout.cu:87-96, pass handle to
raft::launch_kernel; in cpp/tests/linalg/sqrt.cu:31, pass the setup resource
stream into naiveSqrtElem and launch on it; in cpp/tests/core/span.cu:77-90,
create or pass raft::resources and use its configured stream; and in
cpp/tests/core/span.cu:189, launch TestModifyKernel on that same resource-owned
stream. Preserve asynchronous ordering and avoid raw default-stream usage.
In `@cpp/tests/util/kernel_launch.cu`:
- Around line 38-39: Update kernel_launcher::dispatch so successful launches
remain asynchronous in debug builds by replacing post-launch stream
synchronization with cudaPeekAtLastError() for launch validation. Preserve
explicit completion synchronization at call sites such as
resource::sync_stream(res), and avoid default-stream launches.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f759c166-44b2-4491-b30d-550046691f4b
📒 Files selected for processing (106)
cpp/include/raft/common/detail/scatter.cuhcpp/include/raft/core/bitset.cuhcpp/include/raft/core/detail/copy.hppcpp/include/raft/label/detail/classlabels.cuhcpp/include/raft/label/detail/merge_labels.cuhcpp/include/raft/linalg/detail/add.cuhcpp/include/raft/linalg/detail/coalesced_reduction-inl.cuhcpp/include/raft/linalg/detail/map.cuhcpp/include/raft/linalg/detail/map_then_reduce.cuhcpp/include/raft/linalg/detail/normalize.cuhcpp/include/raft/linalg/detail/reduce_cols_by_key.cuhcpp/include/raft/linalg/detail/reduce_rows_by_key.cuhcpp/include/raft/linalg/detail/strided_reduction.cuhcpp/include/raft/linalg/detail/subtract.cuhcpp/include/raft/linalg/detail/transpose.cuhcpp/include/raft/matrix/detail/columnWiseSort.cuhcpp/include/raft/matrix/detail/gather.cuhcpp/include/raft/matrix/detail/linewise_op.cuhcpp/include/raft/matrix/detail/math.cuhcpp/include/raft/matrix/detail/matrix.cuhcpp/include/raft/matrix/detail/select_radix.cuhcpp/include/raft/matrix/detail/select_warpsort.cuhcpp/include/raft/matrix/detail/shift.cuhcpp/include/raft/random/detail/make_blobs.cuhcpp/include/raft/random/detail/make_regression.cuhcpp/include/raft/random/detail/multi_variable_gaussian.cuhcpp/include/raft/random/detail/permute.cuhcpp/include/raft/random/detail/rmat_rectangular_generator.cuhcpp/include/raft/random/detail/rng_impl.cuhcpp/include/raft/random/detail/rng_impl_deprecated.cuhcpp/include/raft/solver/detail/lap_functions.cuhcpp/include/raft/sparse/convert/detail/adj_to_csr.cuhcpp/include/raft/sparse/convert/detail/bitmap_to_csr.cuhcpp/include/raft/sparse/convert/detail/bitset_to_csr.cuhcpp/include/raft/sparse/convert/detail/coo.cuhcpp/include/raft/sparse/convert/detail/dense.cuhcpp/include/raft/sparse/detail/csr.cuhcpp/include/raft/sparse/detail/utils.hcpp/include/raft/sparse/linalg/detail/add.cuhcpp/include/raft/sparse/linalg/detail/degree.cuhcpp/include/raft/sparse/linalg/detail/laplacian.cuhcpp/include/raft/sparse/linalg/detail/norm.cuhcpp/include/raft/sparse/linalg/detail/symmetrize.cuhcpp/include/raft/sparse/linalg/detail/utils.cuhcpp/include/raft/sparse/op/detail/filter.cuhcpp/include/raft/sparse/op/detail/reduce.cuhcpp/include/raft/sparse/op/detail/row_op.cuhcpp/include/raft/sparse/solver/detail/lanczos.cuhcpp/include/raft/sparse/solver/detail/mst_solver_inl.cuhcpp/include/raft/sparse/solver/detail/svds_sign_correction.cuhcpp/include/raft/spectral/detail/matrix_wrappers.hppcpp/include/raft/stats/detail/batched/silhouette_score.cuhcpp/include/raft/stats/detail/contingencyMatrix.cuhcpp/include/raft/stats/detail/dispersion.cuhcpp/include/raft/stats/detail/histogram.cuhcpp/include/raft/stats/detail/meanvar.cuhcpp/include/raft/stats/detail/minmax.cuhcpp/include/raft/stats/detail/mutual_info_score.cuhcpp/include/raft/stats/detail/neighborhood_recall.cuhcpp/include/raft/stats/detail/rand_index.cuhcpp/include/raft/stats/detail/scores.cuhcpp/include/raft/stats/detail/silhouette_score.cuhcpp/include/raft/stats/detail/trustworthiness_score.cuhcpp/include/raft/util/cache.cuhcpp/include/raft/util/detail/scatter.cuhcpp/include/raft/util/kernel_launch.hppcpp/tests/CMakeLists.txtcpp/tests/core/interruptible.cucpp/tests/core/math_device.cucpp/tests/core/operators_device.cucpp/tests/core/span.cucpp/tests/linalg/add.cuhcpp/tests/linalg/axpy.cucpp/tests/linalg/binary_op.cuhcpp/tests/linalg/divide.cucpp/tests/linalg/dot.cucpp/tests/linalg/eltwise.cucpp/tests/linalg/gemm_layout.cucpp/tests/linalg/gemv.cucpp/tests/linalg/map_then_reduce.cucpp/tests/linalg/matrix_vector_op.cuhcpp/tests/linalg/mean_squared_error.cucpp/tests/linalg/norm.cucpp/tests/linalg/power.cucpp/tests/linalg/reduce.cuhcpp/tests/linalg/reduce_rows_by_key.cucpp/tests/linalg/sqrt.cucpp/tests/linalg/subtract.cucpp/tests/linalg/unary_op.cuhcpp/tests/matrix/math.cucpp/tests/random/make_blobs.cucpp/tests/random/multi_variable_gaussian.cucpp/tests/random/rmat_rectangular_generator.cucpp/tests/random/rng.cucpp/tests/random/rng_int.cucpp/tests/random/rng_pcg_host_api.cucpp/tests/sparse/convert_csr.cucpp/tests/sparse/spmm.cucpp/tests/sparse/symmetrize.cucpp/tests/stats/histogram.cucpp/tests/stats/minmax.cucpp/tests/util/bitonic_sort.cucpp/tests/util/device_atomics.cucpp/tests/util/integer_utils.cucpp/tests/util/kernel_launch.cucpp/tests/util/reduction.cu
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/source/cpp_api/utils.rst`:
- Around line 23-26: Add the repository-standard RAPIDS copyright header at the
beginning of the documentation file before the “Kernel Launch” section,
preserving the existing content and formatting after the header.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: d2e3ffe6-db05-4354-9998-98cfe21f86e4
📒 Files selected for processing (2)
cpp/include/raft/util/kernel_launch.hppdocs/source/cpp_api/utils.rst
🚧 Files skipped from review as they are similar to previous changes (1)
- cpp/include/raft/util/kernel_launch.hpp
| * @param[in] location call site to blame for launch errors; leave at its default | ||
| * @return a launcher to invoke with the kernel and its arguments | ||
| */ | ||
| inline kernel_launcher launch_kernel( |
There was a problem hiding this comment.
While I like the idea of using a temporary to enforce that we can uniquely identify the launch of each kernel source, I am a bit unconvinced by the UX/syntax of raft::launch_kernel(config)(kernel, args).
I get what you were going for and replicating the triple chevron launcher as close as possible, it's just the dual brackets that are tripping me up.
How would you instead feel about separating config from the launch itself and emulate the cuda runtime API?
raft::kernel_config config{...};
raft::kernel_launcher(config, kernel, args);
There was a problem hiding this comment.
I agree, I have the same feeling about the current syntax. But no, replicating the triple chevron is rather accidental :)
The main goal I am trying to achieve here is to pass std::source_location location = std::source_location::current() as close as possible to the kernel call site, so that the generated file, function, and line numbers point to the correct place in the error message.
An obvious solution of passing this along the kernel parameters is not possible, because both the default argument and the parameter pack must appear at the end of the argument list. Hence we resort to various ways to pass the location via struct constructors nearby.
In the current code, I create such a struct kernel_launcher and force its operator to work on rvalue ref types only. So you cannot construct kernel_launcher in one place and then use it to run the kernel somewhere else. I could also slightly modify it to allow something like this raft::launch_kernel{...config...}(kernel, args) (curly braces instead of parens). But I opted out of it, because there's no way to enforce the users to consistently use the braces syntax over the parens syntax (so it would lead to even more confusion).
In your code snippet, the problem is that the std::source_location refers to the line where the config is declared rather than where the kernel is called. However, we can restrict that too, and also enhance it further relying on implicit conversion. I'll update the code in the next commit, so we can compare the two approaches
There was a problem hiding this comment.
I like this approach a lot!
Fix accidentally swapped block size and grid size arguments. #3104 (comment) Authors: - Artem M. Chirkin (https://github.com/achirkin) Approvers: - Divye Gala (https://github.com/divyegala) - Anupam (https://github.com/aamijar) URL: #3109
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cpp/tests/util/kernel_launch.cu`:
- Around line 55-66: Extend the launchability tests near launchable_as_named
with a kernel accepting const int* and invoke it using an int* argument through
the converting launch path. Validate the kernel’s output so the test covers both
kernel-argument conversion and successful execution, using the existing launch
and assertion utilities.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: fc044910-642e-4b29-9d9a-49ade9ad84dc
📒 Files selected for processing (105)
cpp/include/raft/common/detail/scatter.cuhcpp/include/raft/core/bitset.cuhcpp/include/raft/core/detail/copy.hppcpp/include/raft/label/detail/classlabels.cuhcpp/include/raft/label/detail/merge_labels.cuhcpp/include/raft/linalg/detail/add.cuhcpp/include/raft/linalg/detail/coalesced_reduction-inl.cuhcpp/include/raft/linalg/detail/map.cuhcpp/include/raft/linalg/detail/map_then_reduce.cuhcpp/include/raft/linalg/detail/normalize.cuhcpp/include/raft/linalg/detail/reduce_cols_by_key.cuhcpp/include/raft/linalg/detail/reduce_rows_by_key.cuhcpp/include/raft/linalg/detail/strided_reduction.cuhcpp/include/raft/linalg/detail/subtract.cuhcpp/include/raft/linalg/detail/transpose.cuhcpp/include/raft/matrix/detail/columnWiseSort.cuhcpp/include/raft/matrix/detail/gather.cuhcpp/include/raft/matrix/detail/linewise_op.cuhcpp/include/raft/matrix/detail/math.cuhcpp/include/raft/matrix/detail/matrix.cuhcpp/include/raft/matrix/detail/select_radix.cuhcpp/include/raft/matrix/detail/select_warpsort.cuhcpp/include/raft/matrix/detail/shift.cuhcpp/include/raft/random/detail/make_blobs.cuhcpp/include/raft/random/detail/make_regression.cuhcpp/include/raft/random/detail/multi_variable_gaussian.cuhcpp/include/raft/random/detail/permute.cuhcpp/include/raft/random/detail/rmat_rectangular_generator.cuhcpp/include/raft/random/detail/rng_impl.cuhcpp/include/raft/random/detail/rng_impl_deprecated.cuhcpp/include/raft/solver/detail/lap_functions.cuhcpp/include/raft/sparse/convert/detail/adj_to_csr.cuhcpp/include/raft/sparse/convert/detail/bitmap_to_csr.cuhcpp/include/raft/sparse/convert/detail/bitset_to_csr.cuhcpp/include/raft/sparse/convert/detail/coo.cuhcpp/include/raft/sparse/convert/detail/dense.cuhcpp/include/raft/sparse/detail/csr.cuhcpp/include/raft/sparse/detail/utils.hcpp/include/raft/sparse/linalg/detail/add.cuhcpp/include/raft/sparse/linalg/detail/degree.cuhcpp/include/raft/sparse/linalg/detail/laplacian.cuhcpp/include/raft/sparse/linalg/detail/norm.cuhcpp/include/raft/sparse/linalg/detail/symmetrize.cuhcpp/include/raft/sparse/linalg/detail/utils.cuhcpp/include/raft/sparse/op/detail/filter.cuhcpp/include/raft/sparse/op/detail/reduce.cuhcpp/include/raft/sparse/op/detail/row_op.cuhcpp/include/raft/sparse/solver/detail/lanczos.cuhcpp/include/raft/sparse/solver/detail/mst_solver_inl.cuhcpp/include/raft/sparse/solver/detail/svds_sign_correction.cuhcpp/include/raft/spectral/detail/matrix_wrappers.hppcpp/include/raft/stats/detail/batched/silhouette_score.cuhcpp/include/raft/stats/detail/contingencyMatrix.cuhcpp/include/raft/stats/detail/dispersion.cuhcpp/include/raft/stats/detail/histogram.cuhcpp/include/raft/stats/detail/meanvar.cuhcpp/include/raft/stats/detail/minmax.cuhcpp/include/raft/stats/detail/mutual_info_score.cuhcpp/include/raft/stats/detail/neighborhood_recall.cuhcpp/include/raft/stats/detail/rand_index.cuhcpp/include/raft/stats/detail/scores.cuhcpp/include/raft/stats/detail/silhouette_score.cuhcpp/include/raft/stats/detail/trustworthiness_score.cuhcpp/include/raft/util/cache.cuhcpp/include/raft/util/detail/scatter.cuhcpp/include/raft/util/kernel_launch.hppcpp/tests/core/interruptible.cucpp/tests/core/math_device.cucpp/tests/core/operators_device.cucpp/tests/core/span.cucpp/tests/linalg/add.cuhcpp/tests/linalg/axpy.cucpp/tests/linalg/binary_op.cuhcpp/tests/linalg/divide.cucpp/tests/linalg/dot.cucpp/tests/linalg/eltwise.cucpp/tests/linalg/gemm_layout.cucpp/tests/linalg/gemv.cucpp/tests/linalg/map_then_reduce.cucpp/tests/linalg/matrix_vector_op.cuhcpp/tests/linalg/mean_squared_error.cucpp/tests/linalg/norm.cucpp/tests/linalg/power.cucpp/tests/linalg/reduce.cuhcpp/tests/linalg/reduce_rows_by_key.cucpp/tests/linalg/sqrt.cucpp/tests/linalg/subtract.cucpp/tests/linalg/unary_op.cuhcpp/tests/matrix/math.cucpp/tests/random/make_blobs.cucpp/tests/random/multi_variable_gaussian.cucpp/tests/random/rmat_rectangular_generator.cucpp/tests/random/rng.cucpp/tests/random/rng_int.cucpp/tests/random/rng_pcg_host_api.cucpp/tests/sparse/convert_csr.cucpp/tests/sparse/spmm.cucpp/tests/sparse/symmetrize.cucpp/tests/stats/histogram.cucpp/tests/stats/minmax.cucpp/tests/util/bitonic_sort.cucpp/tests/util/device_atomics.cucpp/tests/util/integer_utils.cucpp/tests/util/kernel_launch.cucpp/tests/util/reduction.cu
🚧 Files skipped from review as they are similar to previous changes (102)
- cpp/tests/linalg/norm.cu
- cpp/include/raft/stats/detail/silhouette_score.cuh
- cpp/include/raft/stats/detail/rand_index.cuh
- cpp/tests/core/operators_device.cu
- cpp/include/raft/stats/detail/neighborhood_recall.cuh
- cpp/include/raft/stats/detail/mutual_info_score.cuh
- cpp/tests/core/math_device.cu
- cpp/include/raft/sparse/detail/utils.h
- cpp/tests/linalg/mean_squared_error.cu
- cpp/tests/linalg/unary_op.cuh
- cpp/include/raft/sparse/convert/detail/coo.cuh
- cpp/tests/util/reduction.cu
- cpp/tests/core/interruptible.cu
- cpp/include/raft/label/detail/classlabels.cuh
- cpp/include/raft/random/detail/rng_impl_deprecated.cuh
- cpp/include/raft/linalg/detail/map_then_reduce.cuh
- cpp/tests/sparse/convert_csr.cu
- cpp/include/raft/util/detail/scatter.cuh
- cpp/tests/linalg/map_then_reduce.cu
- cpp/include/raft/linalg/detail/strided_reduction.cuh
- cpp/include/raft/sparse/convert/detail/bitset_to_csr.cuh
- cpp/include/raft/linalg/detail/transpose.cuh
- cpp/include/raft/matrix/detail/gather.cuh
- cpp/tests/util/integer_utils.cu
- cpp/tests/linalg/subtract.cu
- cpp/include/raft/linalg/detail/normalize.cuh
- cpp/tests/linalg/gemm_layout.cu
- cpp/tests/util/bitonic_sort.cu
- cpp/include/raft/random/detail/rng_impl.cuh
- cpp/tests/linalg/axpy.cu
- cpp/include/raft/core/detail/copy.hpp
- cpp/include/raft/random/detail/rmat_rectangular_generator.cuh
- cpp/include/raft/stats/detail/trustworthiness_score.cuh
- cpp/include/raft/matrix/detail/select_radix.cuh
- cpp/include/raft/linalg/detail/reduce_cols_by_key.cuh
- cpp/include/raft/spectral/detail/matrix_wrappers.hpp
- cpp/tests/random/multi_variable_gaussian.cu
- cpp/include/raft/random/detail/make_blobs.cuh
- cpp/tests/linalg/matrix_vector_op.cuh
- cpp/include/raft/matrix/detail/matrix.cuh
- cpp/include/raft/stats/detail/contingencyMatrix.cuh
- cpp/tests/random/rng.cu
- cpp/tests/random/make_blobs.cu
- cpp/include/raft/common/detail/scatter.cuh
- cpp/tests/sparse/spmm.cu
- cpp/include/raft/linalg/detail/coalesced_reduction-inl.cuh
- cpp/tests/core/span.cu
- cpp/tests/linalg/binary_op.cuh
- cpp/include/raft/sparse/linalg/detail/add.cuh
- cpp/include/raft/linalg/detail/map.cuh
- cpp/include/raft/sparse/convert/detail/bitmap_to_csr.cuh
- cpp/include/raft/linalg/detail/add.cuh
- cpp/include/raft/stats/detail/batched/silhouette_score.cuh
- cpp/tests/stats/minmax.cu
- cpp/include/raft/matrix/detail/math.cuh
- cpp/include/raft/sparse/linalg/detail/norm.cuh
- cpp/tests/linalg/dot.cu
- cpp/tests/sparse/symmetrize.cu
- cpp/tests/linalg/add.cuh
- cpp/include/raft/stats/detail/histogram.cuh
- cpp/tests/stats/histogram.cu
- cpp/include/raft/random/detail/multi_variable_gaussian.cuh
- cpp/include/raft/sparse/op/detail/reduce.cuh
- cpp/include/raft/linalg/detail/subtract.cuh
- cpp/include/raft/sparse/solver/detail/lanczos.cuh
- cpp/tests/linalg/power.cu
- cpp/tests/linalg/gemv.cu
- cpp/tests/linalg/divide.cu
- cpp/include/raft/sparse/solver/detail/mst_solver_inl.cuh
- cpp/tests/random/rng_pcg_host_api.cu
- cpp/include/raft/linalg/detail/reduce_rows_by_key.cuh
- cpp/include/raft/sparse/linalg/detail/laplacian.cuh
- cpp/include/raft/random/detail/permute.cuh
- cpp/include/raft/sparse/convert/detail/dense.cuh
- cpp/include/raft/matrix/detail/shift.cuh
- cpp/include/raft/matrix/detail/linewise_op.cuh
- cpp/include/raft/core/bitset.cuh
- cpp/include/raft/sparse/solver/detail/svds_sign_correction.cuh
- cpp/tests/linalg/eltwise.cu
- cpp/include/raft/label/detail/merge_labels.cuh
- cpp/tests/util/device_atomics.cu
- cpp/include/raft/sparse/linalg/detail/utils.cuh
- cpp/include/raft/random/detail/make_regression.cuh
- cpp/tests/random/rng_int.cu
- cpp/include/raft/sparse/op/detail/filter.cuh
- cpp/tests/linalg/reduce.cuh
- cpp/tests/linalg/reduce_rows_by_key.cu
- cpp/include/raft/sparse/linalg/detail/degree.cuh
- cpp/include/raft/sparse/detail/csr.cuh
- cpp/tests/random/rmat_rectangular_generator.cu
- cpp/include/raft/stats/detail/minmax.cuh
- cpp/include/raft/sparse/linalg/detail/symmetrize.cuh
- cpp/include/raft/stats/detail/dispersion.cuh
- cpp/include/raft/sparse/convert/detail/adj_to_csr.cuh
- cpp/tests/matrix/math.cu
- cpp/include/raft/stats/detail/scores.cuh
- cpp/include/raft/util/cache.cuh
- cpp/include/raft/stats/detail/meanvar.cuh
- cpp/include/raft/solver/detail/lap_functions.cuh
- cpp/include/raft/sparse/op/detail/row_op.cuh
- cpp/tests/linalg/sqrt.cu
- cpp/include/raft/matrix/detail/columnWiseSort.cuh
| // Only a prvalue built inside the launch expression may be launched, so that the reported location | ||
| // is always the one of the launch. Everything else must fail to compile. | ||
| static_assert(launchable_as_named<raft::resources&>, | ||
| "resources must convert to a launch_on prvalue"); | ||
| static_assert(launchable_as_named<rmm::cuda_stream_view>, | ||
| "a stream view must convert to a launch_on prvalue"); | ||
| static_assert(launchable_as_named<cudaStream_t>, | ||
| "a raw stream handle must convert to a launch_on prvalue"); | ||
| static_assert(!launchable_as_named<raft::launch_on>, "a stored launch_on must not be launchable"); | ||
| static_assert(!launchable_as_named<raft::launch_on&>, "an lvalue launch_on must not be launchable"); | ||
| static_assert(!launchable_when_moved<raft::launch_on>, | ||
| "a moved-from launch_on must not be launchable"); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add kernel-argument conversion coverage.
The tests cover conversion to launch_on, but they do not cover conversion from a launch argument to a kernel parameter. Add a kernel that accepts const int*, launch it with int*, and validate its output. This exercises the converting overload.
As per path instructions, “tests should validate launchability/type conversion.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@cpp/tests/util/kernel_launch.cu` around lines 55 - 66, Extend the
launchability tests near launchable_as_named with a kernel accepting const int*
and invoke it using an int* argument through the converting launch path.
Validate the kernel’s output so the test covers both kernel-argument conversion
and successful execution, using the existing launch and assertion utilities.
Source: Path instructions
divyegala
left a comment
There was a problem hiding this comment.
Thank you, PR looks great!
|
/merge |
Upstream refactored the previous MST solver's kernel launches in mst_solver_inl.cuh; that file is rewritten on this branch, so the branch version is kept. SPDX headers updated to the new style.
Implement an extendable kernel dispatcher:
The first argument in this function is a
raft::launch_onstructure that is implicitly cast fromraft::resourceshandle orrmm::cuda_stream_vieworcudaStream_t. It injectsstd::source_location::current()to provide precise error reporting without CPP macros. Under the hood, it always dispatches the kernels using the most genericcudaLaunchKernelExC.By modifying
raft::launch_onand the dispatch logic, in future we can modify the behavior of the dispatcher without touching the call sites:cudaStreamSynchronizee.g. as a form of debugging without recompiling the program.