diff --git a/cpp/src/io/orc/writer_impl.cu b/cpp/src/io/orc/writer_impl.cu index 24ae91c0172..5a8744f8afd 100644 --- a/cpp/src/io/orc/writer_impl.cu +++ b/cpp/src/io/orc/writer_impl.cu @@ -1149,7 +1149,18 @@ cudf::detail::hostdevice_vector allocate_and_encode_blobs( // figure out the buffer size needed for protobuf format orc_init_statistics_buffersize( stats_merge_groups.device_ptr(), stat_chunks.data(), num_stat_blobs, stream); - auto max_blobs = stats_merge_groups.element(num_stat_blobs - 1, stream); + + // get stats_merge_groups[num_stat_blobs - 1] via a host pinned bounce buffer + auto const max_blobs = [&]() { + auto max_blobs_element = + cudf::detail::make_pinned_vector_async(1, stream); + cudf::detail::cuda_memcpy( + max_blobs_element, + cudf::device_span{stats_merge_groups.device_ptr(num_stat_blobs - 1), + 1}, + stream); + return max_blobs_element.front(); + }(); cudf::detail::hostdevice_vector blobs(max_blobs.start_chunk + max_blobs.num_chunks, stream); diff --git a/cpp/src/io/utilities/hostdevice_vector.hpp b/cpp/src/io/utilities/hostdevice_vector.hpp index 37a3cf2f3fc..61485c6f352 100644 --- a/cpp/src/io/utilities/hostdevice_vector.hpp +++ b/cpp/src/io/utilities/hostdevice_vector.hpp @@ -100,23 +100,6 @@ class hostdevice_vector { [[nodiscard]] T* d_end() { return device_ptr(size()); } [[nodiscard]] T const* d_end() const { return device_ptr(size()); } - /** - * @brief Returns the specified element from device memory - * - * @note This function incurs a device to host memcpy and should be used sparingly. - * @note This function synchronizes `stream`. - * - * @throws rmm::out_of_range exception if `element_index >= size()` - * - * @param element_index Index of the desired element - * @param stream The stream on which to perform the copy - * @return The value of the specified element - */ - [[nodiscard]] T element(std::size_t element_index, rmm::cuda_stream_view stream) const - { - return d_data.element(element_index, stream); - } - operator cudf::host_span() { return host_span{h_data}.subspan(0, size()); } operator cudf::host_span() const {