Refactor host_span to use cuda::std::span internally and remove span_base#23072
Conversation
|
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
WalkthroughThis PR refactors Changeshost_span Internal Storage Refactor
null_mask.cuh Forward Declarations
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cpp/include/cudf/utilities/span.hpp (1)
114-127: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winHIGH: Preserve allocator device-accessibility in container constructors.
_is_device_accessiblenow stays at the defaultfalsefor container-backed spans, so pinned host vectors lose the flag that copy-engine paths rely on.Proposed fix
private: using span_type = cuda::std::span<T, Extent>; ///< The underlying span type + + template <typename C> + static constexpr bool container_is_device_accessible(C const& in) + { + if constexpr (requires { in.get_allocator().is_device_accessible(); }) { + return in.get_allocator().is_device_accessible(); + } else { + return false; + } + } public: @@ - constexpr host_span(C& in) : _span{thrust::raw_pointer_cast(in.data()), in.size()} + constexpr host_span(C& in) + : _span{thrust::raw_pointer_cast(in.data()), in.size()}, + _is_device_accessible{container_is_device_accessible(in)} { } @@ - constexpr host_span(C const& in) : _span{thrust::raw_pointer_cast(in.data()), in.size()} + constexpr host_span(C const& in) + : _span{thrust::raw_pointer_cast(in.data()), in.size()}, + _is_device_accessible{container_is_device_accessible(in)} { }🤖 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/include/cudf/utilities/span.hpp` around lines 114 - 127, The container-backed host_span constructors are not preserving allocator device-accessibility, so spans built from device-accessible host containers lose the flag that copy-engine paths depend on. Update the host_span(C&) and host_span(C const&) constructors to derive and store _is_device_accessible from the source container’s allocator/device-accessibility trait, consistent with the existing span state. Use the host_span template constructors and the container-support checks already present to locate the fix.
🤖 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/cudf/utilities/span.hpp`:
- Around line 233-246: The host_span subview helpers first() and last() are
dropping the device-accessibility state, so pinned-memory slices lose the
_is_device_accessible flag while subspan() preserves it. Update host_span::first
and host_span::last to construct the returned host_span with the same
accessibility metadata as the source span, using the existing host_span
constructors/fields around _span and _is_device_accessible so these views stay
device-accessible.
---
Outside diff comments:
In `@cpp/include/cudf/utilities/span.hpp`:
- Around line 114-127: The container-backed host_span constructors are not
preserving allocator device-accessibility, so spans built from device-accessible
host containers lose the flag that copy-engine paths depend on. Update the
host_span(C&) and host_span(C const&) constructors to derive and store
_is_device_accessible from the source container’s allocator/device-accessibility
trait, consistent with the existing span state. Use the host_span template
constructors and the container-support checks already present to locate the fix.
🪄 Autofix (Beta)
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: 114a1e0b-01ec-4f62-b605-abc2e21827e6
📒 Files selected for processing (2)
cpp/include/cudf/detail/null_mask.cuhcpp/include/cudf/utilities/span.hpp
|
Re: the outside-diff comment on the container constructors ( The container constructors defaulted cudf/cpp/include/cudf/detail/utilities/host_vector.hpp Lines 217 to 227 in 93ac913 The generic |
|
/merge |
Description
Contributes to #20539.
This PR refactors
cudf::host_spanto be backed bycuda::std::spaninternally instead of the customcudf::detail::span_base, and removesspan_baseentirely now that it has no other users. The custom logic needed for copy-engine optimizations is retained:host_spanstill tracksis_device_accessibleand still constructs from cudf-supported host containers.Not in this PR: removing the custom
device_spanalias and droppingcudf::dynamic_extent.Checklist