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

Ensure all of device bitmask is initialized in from_arrow #12668

Merged
Changes from 1 commit
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
17 changes: 11 additions & 6 deletions cpp/src/interop/from_arrow.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -104,16 +104,21 @@ struct dispatch_to_cudf_column {
if (array.null_bitmap_data() == nullptr) {
return std::make_unique<rmm::device_buffer>(0, stream, mr);
}
auto mask = std::make_unique<rmm::device_buffer>(
bitmask_allocation_size_bytes(static_cast<size_type>(array.null_bitmap()->size() * CHAR_BIT)),
stream,
mr);
auto null_bitmap_size = array.null_bitmap()->size();
auto allocation_size =
wence- marked this conversation as resolved.
Show resolved Hide resolved
bitmask_allocation_size_bytes(static_cast<size_type>(null_bitmap_size * CHAR_BIT));
auto mask = std::make_unique<rmm::device_buffer>(allocation_size, stream, mr);
auto mask_buffer = array.null_bitmap();
CUDF_CUDA_TRY(cudaMemcpyAsync(mask->data(),
reinterpret_cast<const uint8_t*>(mask_buffer->address()),
array.null_bitmap()->size(),
null_bitmap_size,
cudaMemcpyDefault,
stream.value()));
auto num_zeros = allocation_size - null_bitmap_size;
wence- marked this conversation as resolved.
Show resolved Hide resolved
if (num_zeros > 0) {
auto zero_after = static_cast<char*>(mask->data()) + null_bitmap_size;
wence- marked this conversation as resolved.
Show resolved Hide resolved
CUDF_CUDA_TRY(cudaMemsetAsync(zero_after, 0, num_zeros, stream.value()));
}
return mask;
}

Expand Down