contiguous_split.hpp
转到此文件的文档。
1 /*
2  * Copyright (c) 2023-2025, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://apache.ac.cn/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cudf/table/table.hpp>
20 #include <cudf/types.hpp>
21 #include <cudf/utilities/export.hpp>
23 
24 #include <memory>
25 #include <vector>
26 
27 namespace CUDF_EXPORT cudf {
28 
44  : metadata(std::make_unique<std::vector<uint8_t>>()),
45  gpu_data(std::make_unique<rmm::device_buffer>())
46  {
47  }
48 
55  packed_columns(std::unique_ptr<std::vector<uint8_t>>&& md,
56  std::unique_ptr<rmm::device_buffer>&& gd)
57  : metadata(std::move(md)), gpu_data(std::move(gd))
58  {
59  }
60 
61  std::unique_ptr<std::vector<uint8_t>> metadata;
62  std::unique_ptr<rmm::device_buffer> gpu_data;
63 };
64 
77 struct packed_table {
80 };
81 
122 std::vector<packed_table> contiguous_split(
123  cudf::table_view const& input,
124  std::vector<size_type> const& splits,
127 
128 namespace detail {
129 
135 struct contiguous_split_state;
136 } // namespace detail
137 
196  public
207  explicit chunked_pack(
208  cudf::table_view const& input,
209  std::size_t user_buffer_size,
212 
218 
224  [[nodiscard]] std::size_t get_total_contiguous_size() const;
225 
231  [[nodiscard]] bool has_next() const;
232 
246  [[nodiscard]] std::size_t next(cudf::device_span<uint8_t> const& user_buffer);
247 
253  [[nodiscard]] std::unique_ptr<std::vector<uint8_t>> build_metadata() const;
254 
274  [[nodiscard]] static std::unique_ptr<chunked_pack> create(
275  cudf::table_view const& input,
276  std::size_t user_buffer_size,
279 
280  private
281  // internal state of contiguous split
282  std::unique_ptr<detail::contiguous_split_state> state;
283 };
284 
301 
315 std::vector<uint8_t> pack_metadata(table_view const& table,
316  uint8_t const* contiguous_buffer,
317  size_t buffer_size);
318 
334 
352 table_view unpack(uint8_t const* metadata, uint8_t const* gpu_data);
353 
355 } // namespace CUDF_EXPORT cudf
使用用户提供的 user_buffer_size 大小的缓冲区执行输入 table_view 的分块“打包”操作...
std::size_t get_total_contiguous_size() const
获取连续打包的 table_view 的总大小。
std::size_t next(cudf::device_span< uint8_t > const &user_buffer)
将下一个块打包到 user_buffer 中。只要 has_next 返回 true,就应调用此函数。
~chunked_pack()
将实现为默认的析构函数。此处声明并带有定义是因为 contiguous_split...
chunked_pack(cudf::table_view const &input, std::size_t user_buffer_size, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref temp_mr=cudf::get_current_device_resource_ref())
构造一个 chunked_pack 类。
std::unique_ptr< std::vector< uint8_t > > build_metadata() const
构建所有已添加列的不透明元数据。
static std::unique_ptr< chunked_pack > create(cudf::table_view const &input, std::size_t user_buffer_size, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref temp_mr=cudf::get_current_device_resource_ref())
创建一个 chunked_pack 实例,用于执行 table_view "input" 的“打包”操作,其中用户提供...
bool has_next() const
检查是否有剩余块需要复制的函数。
一组大小相同的 cudf::column_view。
一组大小相同的 cudf::column。
定义: table.hpp:40
std::vector< packed_table > contiguous_split(cudf::table_view const &input, std::vector< size_type > const &splits, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
对 table_view 进行深度复制分割,将其分割成 packed_table 的向量,其中每个 packed_table 都...
packed_columns pack(cudf::table_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
将 table_view 深度复制到序列化的连续内存格式。
table_view unpack(uint8_t const *metadata, uint8_t const *gpu_data)
反序列化 cudf::pack 的结果。
std::vector< uint8_t > pack_metadata(table_view const &table, uint8_t const *contiguous_buffer, size_t buffer_size)
生成用于打包存储在连续缓冲区中的表的元数据。
rmm::cuda_stream_view const get_default_stream()
获取当前默认流。
rmm::device_async_resource_ref get_current_device_resource_ref()
获取当前设备内存资源引用。
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
cuDF 接口
定义: host_udf.hpp:37
具有简化功能集的 C++20 std::span 的设备版本。
定义: span.hpp:355
序列化格式的列数据。
packed_columns(std::unique_ptr< std::vector< uint8_t >> &&md, std::unique_ptr< rmm::device_buffer > &&gd)
构造一个新的打包列对象。
std::unique_ptr< std::vector< uint8_t > > metadata
主机侧元数据缓冲区。
std::unique_ptr< rmm::device_buffer > gpu_data
设备侧数据缓冲区。
cudf::contiguous_split 的结果。
packed_columns data
拥有的列数据。
cudf::table_view table
cudf::contiguous_split 的结果 table_view。
cudf::table 的类定义。
libcudf 的类型声明。