Use cuda::std::bit_cast in stats minmax instead of hand-rolled helper - #3095
Conversation
The minmax encode/decode helpers used a local memcpy-based bit_cast with a TODO to switch to the standard facility once libcu++ provided it. libcu++ now ships cuda::std::bit_cast (cuda/std/bit), so use it directly and drop the custom helper. Verified: STATS_TEST builds clean; all 56 minmax tests pass.
|
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
WalkthroughThe min/max statistics header replaces its local bit-cast helper with ChangesMin/max bit-cast migration
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cpp/include/raft/stats/detail/minmax.cuh (1)
12-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winInclude
<cstdint>explicitly forstd::int64_t.Line 41 now directly uses
std::int64_t, but this public header does not include<cstdint>. The current build may succeed through transitive CUDA includes; consumers should not depend on that.Proposed fix
`#include` <cuda/std/bit> +#include <cstdint> `#include` <limits>Also applies to: 41-41
🤖 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/raft/stats/detail/minmax.cuh` around lines 12 - 19, Explicitly include the standard <cstdint> header in the minmax header before its direct use of std::int64_t, alongside the existing includes. Do not rely on transitive CUDA or other includes.
🤖 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.
Nitpick comments:
In `@cpp/include/raft/stats/detail/minmax.cuh`:
- Around line 12-19: Explicitly include the standard <cstdint> header in the
minmax header before its direct use of std::int64_t, alongside the existing
includes. Do not rely on transitive CUDA or other includes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 11602e27-6bf0-419d-bc7d-bdca7dc92010
📒 Files selected for processing (1)
cpp/include/raft/stats/detail/minmax.cuh
The header uses std::int64_t directly but relied on transitive CUDA includes for it. Include <cstdint> explicitly so consumers don't depend on that. Addresses CodeRabbit review feedback on PR NVIDIA#3095.
divyegala
left a comment
There was a problem hiding this comment.
Thanks for the cleanup!
|
/ok to test 4ca058f |
|
/merge |
Description
raft::stats::detail(instats/detail/minmax.cuh) carried a local,memcpy-basedbit_casthelper with aTODOto switch to the standard facility "once we adoptC++20 or libcu++ adds it." libcu++ now ships
cuda::std::bit_cast(<cuda/std/bit>),which works in host and device code, so this PR uses it directly and removes the
hand-rolled helper.
Changes
bit_casttemplate and itsTODO.#include <cuda/std/bit>.cuda::std::bit_castat the fourencode/decodecall sites.No functional or numerical behavior change —
cuda::std::bit_castis a drop-inreplacement for the previous
memcpy-based reinterpretation (same size/trivially-copyable requirements), now sourced from libcu++.
Testing
No new tests are required; this is a non-functional refactor covered by the existing
suite. Verified locally:
STATS_TESTbuilds clean.MinMaxTestscases pass (28MinMaxTestF+ 28MinMaxTestD).