Skip to content
Open
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@ jobs:
--no-fail-fast \
--target x86_64-unknown-linux-gnu \
--verbose
- name: Build cudf-test library
run: cargo +nightly build --locked -p vortex-cudf-test --target x86_64-unknown-linux-gnu
- name: Download and run cudf-test-harness
run: |
curl -fsSL https://github.com/vortex-data/cudf-test-harness/releases/latest/download/cudf-test-harness-x86_64.tar.gz | tar -xz
cd cudf-test-harness-x86_64
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I basically try to never cd in shell scripts, considering the current pwd as state. obs not super important, naturally keep as is if you like.

./cudf-test-harness check $GITHUB_WORKSPACE/target/x86_64-unknown-linux-gnu/debug/libvortex_cudf_test.so
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we leave a comment here to briefly hint at what is happening here with the test harness and why it lives in a separate repo?


rust-test-other:
name: "Rust tests (${{ matrix.os }})"
Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ members = [
"vortex-datafusion",
"vortex-duckdb",
"vortex-cuda",
"vortex-cuda/cub",
"vortex-cuda/cudf-test",
"vortex-cuda/macros",
"vortex-cuda/nvcomp",
"vortex-cuda/cub",
"vortex-cxx",
"vortex-ffi",
"fuzz",
Expand Down
2 changes: 2 additions & 0 deletions vortex-cuda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ _test-harness = []

[dependencies]
arc-swap = { workspace = true }
arrow-data = { workspace = true, features = ["ffi"] }
arrow-schema = { workspace = true, features = ["ffi"] }
async-trait = { workspace = true }
cudarc = { workspace = true, features = ["f16"] }
fastlanes = { workspace = true }
Expand Down
30 changes: 30 additions & 0 deletions vortex-cuda/cudf-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors

[package]
name = "vortex-cudf-test"
authors.workspace = true
description = "Test for cuDF integration"
edition = { workspace = true }
homepage = { workspace = true }
categories = { workspace = true }
include = { workspace = true }
keywords = { workspace = true }
license = { workspace = true }
publish = false
readme = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
version = { workspace = true }

[lib]
crate-type = ["cdylib"]

[lints]
workspace = true

[dependencies]
arrow-schema = { workspace = true, features = ["ffi"] }
futures = { workspace = true, features = ["executor"] }
vortex = { workspace = true }
vortex-cuda = { workspace = true, features = ["_test-harness"] }
90 changes: 90 additions & 0 deletions vortex-cuda/cudf-test/src/lib.rs
Copy link
Contributor

Choose a reason for hiding this comment

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

put this inn vortex-test-e2e-cuda?

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! This file is a simple C-compatible API that is called from the cudf-test-harness at CI time.
//!
//! The flow is
//!
//! * test harness calls `dlopen` in this library
//! * invokes the `export_array` function to get back the device array
//! * pass the arrays to `cudf`'s `from_arrow_device_column`
//! * run some operations on the loaded column view
//! * call `array->release()` to drop the data allocated from the Rust side

#![allow(clippy::unwrap_used, clippy::expect_used)]

use std::sync::LazyLock;

use arrow_schema::ffi::FFI_ArrowSchema;
use futures::executor::block_on;
use vortex::array::Array;
use vortex::array::IntoArray;
use vortex::array::arrays::DecimalArray;
use vortex::array::arrays::PrimitiveArray;
use vortex::array::arrays::StructArray;
use vortex::array::arrays::VarBinViewArray;
use vortex::array::session::ArraySession;
use vortex::array::validity::Validity;
use vortex::dtype::DecimalDType;
use vortex::dtype::FieldNames;
use vortex::expr::session::ExprSession;
use vortex::io::session::RuntimeSession;
use vortex::layout::session::LayoutSession;
use vortex::metrics::VortexMetrics;
use vortex::session::VortexSession;
use vortex_cuda::CudaSession;
use vortex_cuda::arrow::ArrowDeviceArray;
use vortex_cuda::arrow::DeviceArrayExt;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
VortexSession::empty()
.with::<VortexMetrics>()
.with::<ArraySession>()
.with::<LayoutSession>()
.with::<ExprSession>()
.with::<RuntimeSession>()
.with::<CudaSession>()
});

#[unsafe(no_mangle)]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could throw in more docs here. What does external mean here exactly, and is export_array part of the arrow device ABI etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is all just test code. I can comment to make that clearer

pub extern "C" fn export_array(
schema_ptr: &mut FFI_ArrowSchema,
array_ptr: &mut ArrowDeviceArray,
) -> i32 {
let mut ctx = CudaSession::create_execution_ctx(&SESSION).unwrap();

let primitive = PrimitiveArray::from_iter(0u32..1024);
let string =
VarBinViewArray::from_iter_str((0..1024).map(|idx| format!("this is string {idx}")));
let decimal = DecimalArray::from_iter(0i64..1024, DecimalDType::new(19, 2));

let array = StructArray::new(
FieldNames::from_iter(["prims", "strings", "decimals"]),
vec![
primitive.into_array(),
string.into_array(),
decimal.into_array(),
],
1024,
Validity::NonNullable,
)
.into_array();

let data_type = array
.dtype()
.to_arrow_dtype()
.expect("converting schema to Arrow DataType");

*schema_ptr = FFI_ArrowSchema::try_from(data_type).expect("data_type to FFI_ArrowSchema");

match block_on(array.export_device_array(&mut ctx)) {
Ok(exported) => {
*array_ptr = exported;
0
}
Err(err) => {
eprintln!("error in export_device_array: {err}");
1
}
}
}
Loading
Loading