-
Notifications
You must be signed in to change notification settings - Fork 130
feat[cuda]: export arrays to ArrowDeviceArray #6253
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
base: develop
Are you sure you want to change the base?
Changes from all commits
e54c3cb
1135748
032e334
182e35b
a31192f
da8c680
fc53a44
2c94c69
0990251
1495dbc
b489712
e67b57a
b672525
75cb1ee
a06184d
861e17c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| ./cudf-test-harness check $GITHUB_WORKSPACE/target/x86_64-unknown-linux-gnu/debug/libvortex_cudf_test.so | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }})" | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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"] } |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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
cdin shell scripts, considering the current pwd as state. obs not super important, naturally keep as is if you like.