Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ORC reader when using device_read_async while the destination device buffers are not ready #17074

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cpp/src/io/orc/reader_impl_chunking.cu
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,22 @@ void reader_impl::load_next_stripe_data(read_mode mode)
auto const [read_begin, read_end] =
merge_selected_ranges(_file_itm_data.stripe_data_read_ranges, load_stripe_range);

bool stream_synchronized{false};

for (auto read_idx = read_begin; read_idx < read_end; ++read_idx) {
auto const& read_info = _file_itm_data.data_read_info[read_idx];
auto const source_ptr = _metadata.per_file_metadata[read_info.source_idx].source;
auto const dst_base = static_cast<uint8_t*>(
lvl_stripe_data[read_info.level][read_info.stripe_idx - stripe_start].data());

if (source_ptr->is_device_read_preferred(read_info.length)) {
// `device_read_async` may not use _stream at all.
// Instead, it may use some other stream(s) to sync the H->D memcpy.
// As such, we need to make sure the device buffers in `lvl_stripe_data` are ready first.
if (!stream_synchronized) {
_stream.synchronize();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be just sync before the loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that works, but would that be inefficient if we don't have any device read? We will sync after the loop if here is only host read.

stream_synchronized = true;
}
device_read_tasks.push_back(
std::pair(source_ptr->device_read_async(
read_info.offset, read_info.length, dst_base + read_info.dst_pos, _stream),
Expand Down
Loading