Repository navigation
Add implicit conversion from rmm::cuda_stream to cuda::stream_ref - #2326
Conversation
cuda_stream converts to cuda_stream_view, and cuda_stream_view converts to cuda::stream_ref, but C++ does not chain two user-defined implicit conversions. Add a direct operator cuda::stream_ref() to cuda_stream so it can be passed to CCCL APIs that accept cuda::stream_ref.
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes add an implicit conversion operator to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment Tip You can customize the high-level summary generated by CodeRabbit.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cpp/include/rmm/cuda_stream.hpp`:
- Around line 102-107: The header adds a second implicit conversion operator
(operator cuda::stream_ref() const noexcept) alongside operator
cuda_stream_view(), which could be perceived as a breaking change; update the
API docs and the inline comment for both operator cuda_stream_view() and
operator cuda::stream_ref() to state compatibility impact explicitly (confirming
that no functions in the codebase accept both types and therefore no overload
ambiguity exists), and, if this change is considered potentially breaking for
downstream users, add a deprecation/migration note and recommended migration
steps (or annotate the older operator with deprecation guidance) so callers know
which conversion to prefer; ensure the class-level and function-level comments
include the migration guidance and the exact symbols (operator cuda_stream_view
and operator cuda::stream_ref) so reviewers and users can find and act on them.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9f18eb2f-a6ec-47c9-a8a9-bb146a748b9f
📒 Files selected for processing (3)
cpp/include/rmm/cuda_stream.hppcpp/src/cuda_stream.cppcpp/tests/cuda_stream_tests.cpp
|
/merge |
This fixes an ambiguous stream constructor error. RMM added a new conversion from `rmm::cuda_stream` to `cuda::stream_ref` in rapidsai/rmm#2326, creating the ambiguity. ``` FAILED: CMakeFiles/cudf_identify_stream_usage_mode_cudf.dir/tests/utilities/identify_stream_usage.cpp.o /usr/bin/sccache /home/coder/.conda/envs/rapids/bin/x86_64-conda-linux-gnu-c++ -DCCCL_DISABLE_PDL -DCUB_DISABLE_NAMESPACE_MAGIC -DCUB_IGNORE_NAMESPACE_MAGIC_ERROR -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_DISABLE_ABI_NAMESPACE -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -DTHRUST_IGNORE_ABI_NAMESPACE_ERROR -Dcudf_identify_stream_usage_mode_cudf_EXPORTS -I/home/coder/cudf/cpp/include -I/home/coder/cudf/cpp/build/conda/cuda-13.1/release/_deps/cccl-src/lib/cmake/thrust/../../../thrust -I/home/coder/cudf/cpp/build/conda/cuda-13.1/release/_deps/cccl-src/lib/cmake/libcudacxx/../../../libcudacxx/include -I/home/coder/cudf/cpp/build/conda/cuda-13.1/release/_deps/cccl-src/lib/cmake/cub/../../../cub -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/coder/.conda/envs/rapids/include -I/home/coder/.conda/envs/rapids/targets/x86_64-linux/include -I/home/coder/.conda/envs/rapids/targets/x86_64-linux/include/cccl -O3 -DNDEBUG -std=gnu++20 -fPIC -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations -MD -MT CMakeFiles/cudf_identify_stream_usage_mode_cudf.dir/tests/utilities/identify_stream_usage.cpp.o -MF CMakeFiles/cudf_identify_stream_usage_mode_cudf.dir/tests/utilities/identify_stream_usage.cpp.o.d -o CMakeFiles/cudf_identify_stream_usage_mode_cudf.dir/tests/utilities/identify_stream_usage.cpp.o -c /home/coder/cudf/cpp/tests/utilities/identify_stream_usage.cpp /home/coder/cudf/cpp/tests/utilities/identify_stream_usage.cpp: In function 'const rmm::cuda_stream_view cudf::get_default_stream()': /home/coder/cudf/cpp/tests/utilities/identify_stream_usage.cpp:54:17: error: conversion from '<brace-enclosed initializer list>' to 'const rmm::cuda_stream_view' is ambiguous 54 | return {stream}; | ^ In file included from /home/coder/.conda/envs/rapids/include/rmm/device_buffer.hpp:8, from /home/coder/cudf/cpp/include/cudf/utilities/span.hpp:11, from /home/coder/cudf/cpp/include/cudf/detail/utilities/stream_pool.hpp:9, from /home/coder/cudf/cpp/tests/utilities/identify_stream_usage.cpp:6: /home/coder/.conda/envs/rapids/include/rmm/cuda_stream_view.hpp:55:3: note: candidate: 'rmm::cuda_stream_view::cuda_stream_view(cuda::__4::stream_ref)' 55 | cuda_stream_view(cuda::stream_ref stream) noexcept; | ^~~~~~~~~~~~~~~~ /home/coder/.conda/envs/rapids/include/rmm/cuda_stream_view.hpp:33:3: note: candidate: 'constexpr rmm::cuda_stream_view::cuda_stream_view(rmm::cuda_stream_view&&)' 33 | cuda_stream_view(cuda_stream_view&&) = default; ///< @default_move_constructor | ^~~~~~~~~~~~~~~~ /home/coder/.conda/envs/rapids/include/rmm/cuda_stream_view.hpp:32:3: note: candidate: 'constexpr rmm::cuda_stream_view::cuda_stream_view(const rmm::cuda_stream_view&)' 32 | cuda_stream_view(cuda_stream_view const&) = default; ///< @default_copy_constructor | ^~~~~~~~~~~~~~~~ ``` Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Nghia Truong (https://github.com/ttnghia) - David Wendt (https://github.com/davidwendt) - Shruti Shivakumar (https://github.com/shrshi) URL: #21881
Description
rmm::cuda_streamconverts tormm::cuda_stream_view, andrmm::cuda_stream_viewconverts tocuda::stream_ref, but C++ does not chain two user-defined implicit conversions.This PR adds a direct operator
cuda::stream_ref()tormm::cuda_streamso it can be passed to CCCL APIs that acceptcuda::stream_ref.This simplifies the ongoing migration to CCCL memory resources. Part of #2011.
Checklist