Skip to content

Commit 3a6db6c

Browse files
authored
chore: polish ArrowDeviceArray (#8023)
## Changes - Generate Arrow C Device ABI bindings from a vendored Arrow reference header - Fixed VarBin/Utf8 Arrow export layout by reporting the correct `n_buffers = 3` - Fixed Bool export to ensure buffers are resident on the CUDA device - Fixed struct child `ArrowArray` lifetime/release handling - Replaced unsupported-export panics with recoverable errors - Added schema normalization so exported schemas match the physical Arrow Device layout (`Utf8View`/`BinaryView` → `Utf8`/`Binary`) ## Notes This PR is scoped to Arrow Device array export. The intent is to build cuDF support in a follow up on top of this. --------- Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
1 parent aeb5436 commit 3a6db6c

13 files changed

Lines changed: 786 additions & 353 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ jobs:
270270
run: |
271271
git ls-files vortex-cuda vortex-cxx vortex-duckdb vortex-ffi \
272272
| grep -E '\.(cpp|hpp|cu|cuh|h)$' \
273+
| grep -v 'arrow/reference/arrow_c_device\.h$' \
273274
| grep -v 'kernels/src/bit_unpack_.*\.cu$' \
274275
| grep -v 'kernels/src/bit_unpack_.*_lanes\.cuh$' \
275276
| xargs clang-format --dry-run --Werror --style=file

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

REUSE.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ path = ["vortex-cuda/kernels/src/bit_unpack_*"]
4646
precedence = "override"
4747
SPDX-FileCopyrightText = "Copyright the Vortex contributors"
4848
SPDX-License-Identifier = "Apache-2.0"
49+
50+
[[annotations]]
51+
path = "vortex-cuda/src/arrow/reference/arrow_c_device.h"
52+
SPDX-FileCopyrightText = "2016-2025 Copyright The Apache Software Foundation"
53+
SPDX-License-Identifier = "Apache-2.0"

vortex-cuda/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ unstable_encodings = ["vortex/unstable_encodings"]
2424

2525
[dependencies]
2626
arc-swap = { workspace = true }
27+
arrow-schema = { workspace = true, features = ["ffi"] }
2728
async-trait = { workspace = true }
2829
bytes = { workspace = true }
2930
cudarc = { workspace = true, features = ["f16"] }

vortex-cuda/build.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fn main() {
5656
generate_unpack::<u64>(&kernels_src, 16).expect("Failed to generate unpack for u64");
5757

5858
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR not set"));
59+
generate_arrow_device_array_bindings(Path::new(&manifest_dir), &out_dir);
5960
generate_dynamic_dispatch_bindings(&kernels_src, &out_dir);
6061
generate_patches_bindings(&kernels_src, &out_dir);
6162

@@ -196,6 +197,30 @@ fn nvcc_compile_ptx(
196197
Ok(())
197198
}
198199

200+
/// Generate bindings for the vendored Arrow C Device ABI header.
201+
fn generate_arrow_device_array_bindings(manifest_dir: &Path, out_dir: &Path) {
202+
let header = manifest_dir.join("src/arrow/reference/arrow_c_device.h");
203+
println!("cargo:rerun-if-changed={}", header.display());
204+
205+
let bindings = bindgen::Builder::default()
206+
.header(header.to_string_lossy())
207+
.allowlist_type("ArrowArray")
208+
.allowlist_type("ArrowDeviceArray")
209+
.allowlist_type("ArrowDeviceType")
210+
.allowlist_var("ARROW_DEVICE_.*")
211+
// ArrowArray/ArrowDeviceArray own producer state through release/private_data.
212+
// Shallow copies must use Arrow C move semantics, not Rust Copy/Clone.
213+
.derive_copy(false)
214+
.derive_debug(true)
215+
.layout_tests(false)
216+
.generate()
217+
.expect("Failed to generate Arrow C Device bindings");
218+
219+
bindings
220+
.write_to_file(out_dir.join("arrow_c_abi.rs"))
221+
.expect("Failed to write arrow_c_abi.rs");
222+
}
223+
199224
/// Generate bindings for the dynamic dispatch shared header.
200225
fn generate_dynamic_dispatch_bindings(kernels_src: &Path, out_dir: &Path) {
201226
let header = kernels_src.join("dynamic_dispatch.h");

vortex-cuda/kernels/src/varbinview_compute_offsets.cu

Lines changed: 0 additions & 30 deletions
This file was deleted.

vortex-cuda/kernels/src/varbinview_copy_strings.cu

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)