Require cudaMemcpyDefault policy - #23605
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 (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change replaces explicit CUDA memcpy direction kinds with ChangesCUDA memcpy direction normalization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 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: 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/io/io_test_utils.hpp`:
- Around line 62-64: Update device_read to replace the raw cudaMemcpyAsync call
with cudf::detail::memcpy_async and wrap the result in CUDF_CUDA_TRY; also wrap
cudaStreamSynchronize(stream.value()) with CUDF_CUDA_TRY so both CUDA operations
propagate errors.
🪄 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: afd14363-619d-4ca3-9d6d-1262d1bcc40b
📒 Files selected for processing (11)
.pre-commit-config.yamlcpp/include/cudf_test/tdigest_utilities.hppcpp/src/io/utilities/data_sink.cppcpp/src/strings/utilities.cucpp/tests/io/cudftable_test.cppcpp/tests/io/io_test_utils.hppcpp/tests/io/json/json_quote_normalization_test.cppjava/src/main/native/src/jni_writer_data_sink.hppjava/src/main/native/src/multi_host_buffer_source.cpppython/pylibcudf/pylibcudf/contiguous_split.pyxskills/accelerated-computing-cudf/evals/files/cudf-native-stream-handoff-boundary/code/threaded_handoff.cu
| cudaMemcpyAsync( | ||
| out_data.data(), data_.data() + offset, size, cudaMemcpyHostToDevice, stream.value()); | ||
| out_data.data(), data_.data() + offset, size, cudaMemcpyDefault, stream.value()); | ||
| cudaStreamSynchronize(stream.value()); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- target file context ---'
sed -n '1,110p' cpp/tests/io/io_test_utils.hpp
printf '%s\n' '--- CUDA error macros and related usage ---'
rg -n --glob '*.{h,hpp,cpp,cu,cuh}' 'CUDF_CUDA_TRY_NO_THROW|CUDF_CUDA_TRY|cudaMemcpyAsync|cudaStreamSynchronize' cpp | head -200Repository: rapidsai/cudf
Length of output: 21884
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- CUDA error macro definition ---'
sed -n '260,315p' cpp/include/cudf/utilities/error.hpp
printf '%s\n' '--- memcpy helper declaration and implementation ---'
sed -n '1,90p' cpp/include/cudf/detail/utilities/cuda_memcpy.hpp
sed -n '1,75p' cpp/src/utilities/cuda_memcpy.cu
printf '%s\n' '--- includes used by comparable test helpers ---'
sed -n '35,70p' cpp/tests/copying/concatenate_tests.cpp
sed -n '75,105p' cpp/tests/io/comp/comp_test.cpp
sed -n '95,125p' cpp/benchmarks/io/cuio_common.cpp
printf '%s\n' '--- direct includes in target or nearby test utilities ---'
rg -n '^`#include` .*error.hpp|^`#include` .*cuda_memcpy.hpp|^`#include` .*cuda_runtime' cpp/tests/io cpp/tests/copying/concatenate_tests.cppRepository: rapidsai/cudf
Length of output: 13712
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
import re
target = Path("cpp/tests/io/io_test_utils.hpp").read_text()
error_h = Path("cpp/include/cudf/utilities/error.hpp").read_text()
memcpy_h = Path("cpp/include/cudf/detail/utilities/cuda_memcpy.hpp").read_text()
device_read = re.search(
r'std::unique_ptr<cudf::io::datasource::buffer> device_read\(.*?\n \}',
target,
re.S,
)
assert device_read, "device_read definition not found"
body = device_read.group(0)
calls = {
"cudaMemcpyAsync": len(re.findall(r'\bcudaMemcpyAsync\s*\(', body)),
"cudaStreamSynchronize": len(re.findall(r'\bcudaStreamSynchronize\s*\(', body)),
}
wrapped = {
name: bool(re.search(rf'CUDF_CUDA_TRY\s*\(\s*{name}\s*\(', body))
for name in calls
}
macro = re.search(
r'`#define` CUDF_CUDA_TRY\(call\).*?cudaSuccess != status',
error_h,
re.S,
)
helper = re.search(
r'\[\[nodiscard\]\]\s+cudaError_t\s+memcpy_async\(.*?\);',
memcpy_h,
re.S,
)
print("device_read calls:", calls)
print("device_read calls wrapped:", wrapped)
print("CUDF_CUDA_TRY checks cudaSuccess:", bool(macro))
print("detail::memcpy_async returns cudaError_t:", bool(helper))
PYRepository: rapidsai/cudf
Length of output: 393
Handle CUDA errors in device_read.
Use cudf::detail::memcpy_async for the copy and wrap its result with CUDF_CUDA_TRY. Wrap cudaStreamSynchronize with CUDF_CUDA_TRY as well.
🤖 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/io/io_test_utils.hpp` around lines 62 - 64, Update device_read to
replace the raw cudaMemcpyAsync call with cudf::detail::memcpy_async and wrap
the result in CUDF_CUDA_TRY; also wrap cudaStreamSynchronize(stream.value())
with CUDF_CUDA_TRY so both CUDA operations propagate errors.
Source: Coding guidelines
Description
This PR requires the use of
cudaMemcpyDefaultinstead of explicit host/device policies. This ensures that copies do not fail: we only care about memory accessibility, not memory residency. We must support cases where the source is device-accessible but resident on the host, such as host pinned memory.Checklist