From e21678790fb1eb6453b2d7b24eb742e6d790b346 Mon Sep 17 00:00:00 2001 From: Alexander Droste Date: Fri, 23 Oct 2026 12:20:00 +0100 Subject: [PATCH] perf(cuda): migrate consumers to vortex-cuda-driver Migrate CUDA consumers, Arrow export, FFI, benchmarks, mapped-file copies, and stream/pinned-buffer tests to vortex-cuda-driver. Keep i256 support in the unpublished driver's optional feature and remove cudarc from vortex-array and the workspace. Original-commit: 3a3c3057bf Signed-off-by: Alexander Droste --- Cargo.lock | 38 ++------- Cargo.toml | 6 -- vortex-array/Cargo.toml | 2 - vortex-array/src/dtype/bigint/mod.rs | 3 - vortex-cuda/Cargo.toml | 4 +- vortex-cuda/benches/alp_cuda.rs | 2 +- vortex-cuda/benches/bitpacked_cuda.rs | 2 +- vortex-cuda/benches/core_primitives.rs | 20 ++--- vortex-cuda/benches/delta_cuda.rs | 2 +- vortex-cuda/benches/dict_cuda.rs | 2 +- vortex-cuda/benches/dynamic_dispatch_cuda.rs | 14 ++-- vortex-cuda/benches/filter_cuda.rs | 14 ++-- vortex-cuda/benches/for_cuda.rs | 2 +- vortex-cuda/benches/runend_cuda.rs | 2 +- vortex-cuda/benches/throughput_cuda.rs | 8 +- .../benches/timed_launch_strategy/mod.rs | 5 +- vortex-cuda/benches/zstd_cuda.rs | 4 +- vortex-cuda/driver/Cargo.toml | 2 + vortex-cuda/driver/src/repr.rs | 4 + vortex-cuda/ffi/Cargo.toml | 2 +- vortex-cuda/ffi/src/lib.rs | 6 +- vortex-cuda/src/arrow/canonical.rs | 8 +- vortex-cuda/src/arrow/list_view.rs | 6 +- vortex-cuda/src/arrow/mod.rs | 15 ++-- vortex-cuda/src/arrow/offsets.rs | 4 +- vortex-cuda/src/cub.rs | 10 +-- vortex-cuda/src/device_buffer.rs | 30 +++---- vortex-cuda/src/dynamic_dispatch/mod.rs | 16 ++-- vortex-cuda/src/executor.rs | 18 ++-- vortex-cuda/src/kernel/arrays/constant.rs | 4 +- vortex-cuda/src/kernel/arrays/dict.rs | 4 +- vortex-cuda/src/kernel/arrays/list.rs | 4 +- vortex-cuda/src/kernel/encodings/alp.rs | 6 +- vortex-cuda/src/kernel/encodings/bitpacked.rs | 8 +- .../src/kernel/encodings/date_time_parts.rs | 4 +- vortex-cuda/src/kernel/encodings/delta.rs | 4 +- vortex-cuda/src/kernel/encodings/for_.rs | 4 +- vortex-cuda/src/kernel/encodings/fsst.rs | 6 +- vortex-cuda/src/kernel/encodings/onpair.rs | 10 +-- vortex-cuda/src/kernel/encodings/runend.rs | 4 +- vortex-cuda/src/kernel/encodings/sequence.rs | 4 +- vortex-cuda/src/kernel/encodings/zigzag.rs | 4 +- vortex-cuda/src/kernel/encodings/zstd.rs | 6 +- .../src/kernel/encodings/zstd_buffers.rs | 6 +- vortex-cuda/src/kernel/filter/decimal.rs | 2 +- vortex-cuda/src/kernel/filter/mod.rs | 6 +- vortex-cuda/src/kernel/filter/primitive.rs | 2 +- vortex-cuda/src/kernel/mod.rs | 17 ++-- vortex-cuda/src/kernel/patches/mod.rs | 2 +- vortex-cuda/src/lib.rs | 8 +- vortex-cuda/src/pinned.rs | 82 ++++++------------- vortex-cuda/src/pooled_read_at/file.rs | 12 +-- vortex-cuda/src/session.rs | 8 +- vortex-cuda/src/stream.rs | 10 +-- vortex-cuda/src/stream_pool.rs | 6 +- 55 files changed, 213 insertions(+), 271 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b550b64627d..6691c1efd5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1986,7 +1986,7 @@ checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" dependencies = [ "glob", "libc", - "libloading 0.8.9", + "libloading", ] [[package]] @@ -2619,16 +2619,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" -[[package]] -name = "cudarc" -version = "0.19.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7359bf1de037ddada72729c3acec9b040f3468400c6e9e740b01ba0cd2e89562" -dependencies = [ - "half", - "libloading 0.9.0", -] - [[package]] name = "custom-labels" version = "0.4.6" @@ -5110,8 +5100,6 @@ dependencies = [ "cfg-if", "crunchy", "num-traits", - "rand 0.9.5", - "rand_distr 0.5.1", "zerocopy", ] @@ -5927,7 +5915,7 @@ dependencies = [ "java-locator", "jni-macros", "jni-sys", - "libloading 0.8.9", + "libloading", "log", "simd_cesu8", "thiserror 2.0.21", @@ -6738,16 +6726,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "libloading" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" -dependencies = [ - "cfg-if", - "windows-link", -] - [[package]] name = "liblzma" version = "0.4.8" @@ -11400,7 +11378,6 @@ dependencies = [ "bytes", "cfg-if", "codspeed-divan-compat", - "cudarc", "enum-iterator", "fearless_simd", "fearless_simd_macros", @@ -11723,7 +11700,7 @@ name = "vortex-cub" version = "0.1.0" dependencies = [ "bindgen", - "libloading 0.8.9", + "libloading", "paste", "vortex-array", "vortex-cuda-macros", @@ -11737,7 +11714,6 @@ dependencies = [ "async-trait", "bindgen", "codspeed-criterion-compat-walltime", - "cudarc", "fastlanes 0.7.2", "futures", "itertools 0.14.0", @@ -11759,6 +11735,7 @@ dependencies = [ "vortex-arrow", "vortex-cub", "vortex-cuda", + "vortex-cuda-driver", "vortex-cuda-macros", "vortex-error", "vortex-fsst", @@ -11771,9 +11748,10 @@ name = "vortex-cuda-driver" version = "0.1.0" dependencies = [ "half", - "libloading 0.8.9", + "libloading", "parking_lot", "smallvec", + "vortex-array", ] [[package]] @@ -11782,11 +11760,11 @@ version = "0.1.0" dependencies = [ "arrow-schema 59.3.1", "cbindgen", - "cudarc", "futures", "tempfile", "vortex", "vortex-cuda", + "vortex-cuda-driver", "vortex-cuda-macros", "vortex-ffi", ] @@ -12273,7 +12251,7 @@ name = "vortex-nvcomp" version = "0.1.0" dependencies = [ "bindgen", - "libloading 0.8.9", + "libloading", "liblzma", "reqwest 0.13.5", "tar", diff --git a/Cargo.toml b/Cargo.toml index f7d5a15e8a5..31c8a368200 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,12 +132,6 @@ clap = "4.5" criterion = { package = "codspeed-criterion-compat-walltime", version = "5.0.0" } crossbeam-channel = "0.5.16" crossterm = "0.29" -cudarc = { version = "0.19.0", features = [ - # The NSight Compute version available on lambda.ai hosts does not inject a symbol for - # several functions that cudarc expects to load when this is set to "cuda-12080". We - # don't use any CUDA 12.8 specific features currently so this is fine. - "cuda-12050", -] } custom-labels = "0.4.4" dashmap = "6.2.1" datafusion = { version = "55.0.0", default-features = false, features = [ diff --git a/vortex-array/Cargo.toml b/vortex-array/Cargo.toml index 4beb0672421..fbbc3b42575 100644 --- a/vortex-array/Cargo.toml +++ b/vortex-array/Cargo.toml @@ -28,7 +28,6 @@ arcref = { workspace = true } arrow-buffer = { workspace = true } bytes = { workspace = true } cfg-if = { workspace = true } -cudarc = { workspace = true, optional = true } enum-iterator = { workspace = true } fearless_simd = { workspace = true } fearless_simd_macros = { workspace = true } @@ -76,7 +75,6 @@ vortex-utils = { workspace = true, features = ["dyn-traits"] } [features] arbitrary = ["dep:arbitrary", "dep:primitive-types"] canonical_counter = [] -cudarc = ["dep:cudarc"] table-display = ["dep:tabled"] _test-harness = ["dep:goldenfile", "dep:rstest", "dep:rstest_reuse"] serde = ["dep:serde", "vortex-buffer/serde", "vortex-mask/serde"] diff --git a/vortex-array/src/dtype/bigint/mod.rs b/vortex-array/src/dtype/bigint/mod.rs index 4e715d1bf36..e6dae936c0a 100644 --- a/vortex-array/src/dtype/bigint/mod.rs +++ b/vortex-array/src/dtype/bigint/mod.rs @@ -39,9 +39,6 @@ use vortex_error::VortexExpect; #[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash, PartialOrd, Ord)] pub struct i256(arrow_buffer::i256); -#[cfg(feature = "cudarc")] -unsafe impl cudarc::driver::DeviceRepr for i256 {} - #[expect( clippy::same_name_method, reason = "inherent methods intentionally shadow arrow_buffer::i256 methods" diff --git a/vortex-cuda/Cargo.toml b/vortex-cuda/Cargo.toml index d328d963fc8..f11e14dfd23 100644 --- a/vortex-cuda/Cargo.toml +++ b/vortex-cuda/Cargo.toml @@ -23,7 +23,6 @@ _test-harness = [] [dependencies] arrow-schema = { workspace = true, features = ["ffi"] } async-trait = { workspace = true } -cudarc = { workspace = true, features = ["f16"] } futures = { workspace = true, features = ["executor"] } itertools = { workspace = true } kanal = { workspace = true } @@ -36,9 +35,10 @@ prost = { workspace = true } tokio = { workspace = true, features = ["fs"] } tracing = { workspace = true, features = ["std", "attributes"] } vortex = { workspace = true, features = ["zstd"] } -vortex-array = { workspace = true, features = ["cudarc"] } +vortex-array = { workspace = true } vortex-arrow = { workspace = true } vortex-cub = { path = "cub" } +vortex-cuda-driver = { workspace = true, features = ["f16", "i256"] } vortex-cuda-macros = { workspace = true } vortex-error = { workspace = true, features = ["object_store"] } vortex-nvcomp = { path = "nvcomp" } diff --git a/vortex-cuda/benches/alp_cuda.rs b/vortex-cuda/benches/alp_cuda.rs index dbe4392829d..4af0ae33d56 100644 --- a/vortex-cuda/benches/alp_cuda.rs +++ b/vortex-cuda/benches/alp_cuda.rs @@ -19,7 +19,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::DeviceRepr; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::array::IntoArray; @@ -43,6 +42,7 @@ use vortex_array::session::ArraySession; use vortex_cuda::CudaDispatchMode; use vortex_cuda::CudaSession; use vortex_cuda::executor::CudaArrayExt; +use vortex_cuda_driver::DeviceRepr; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/bitpacked_cuda.rs b/vortex-cuda/benches/bitpacked_cuda.rs index c4f816ae68f..bffae0ba542 100644 --- a/vortex-cuda/benches/bitpacked_cuda.rs +++ b/vortex-cuda/benches/bitpacked_cuda.rs @@ -19,7 +19,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::DeviceRepr; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::array::IntoArray; @@ -42,6 +41,7 @@ use vortex_array::session::ArraySession; use vortex_cuda::CudaDispatchMode; use vortex_cuda::CudaSession; use vortex_cuda::executor::CudaArrayExt; +use vortex_cuda_driver::DeviceRepr; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/core_primitives.rs b/vortex-cuda/benches/core_primitives.rs index 6c9d9dcdec1..43c06872e68 100644 --- a/vortex-cuda/benches/core_primitives.rs +++ b/vortex-cuda/benches/core_primitives.rs @@ -15,15 +15,15 @@ use criterion::BatchSize; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::CudaContext; -use cudarc::driver::CudaStream; -use cudarc::driver::HostSlice; -use cudarc::driver::SyncOnDrop; -use cudarc::driver::result; -use cudarc::driver::sys; -use cudarc::driver::sys::CU_MEMHOSTALLOC_WRITECOMBINED; -use cudarc::driver::sys::CUmemPool_attribute_enum; use mimalloc::MiMalloc; +use vortex_cuda_driver::CudaContext; +use vortex_cuda_driver::CudaStream; +use vortex_cuda_driver::HostSlice; +use vortex_cuda_driver::SyncOnDrop; +use vortex_cuda_driver::result; +use vortex_cuda_driver::sys; +use vortex_cuda_driver::sys::CU_MEMHOSTALLOC_WRITECOMBINED; +use vortex_cuda_driver::sys::CUmemPool_attribute_enum; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; @@ -92,7 +92,7 @@ impl HostSlice for CudaHostBuffer { ) -> (&'a [u8], SyncOnDrop<'a>) { ( unsafe { std::slice::from_raw_parts(self.ptr, self.len) }, - SyncOnDrop::Sync(None), + SyncOnDrop::none(), ) } @@ -102,7 +102,7 @@ impl HostSlice for CudaHostBuffer { ) -> (&'a mut [u8], SyncOnDrop<'a>) { ( unsafe { std::slice::from_raw_parts_mut(self.ptr, self.len) }, - SyncOnDrop::Sync(None), + SyncOnDrop::none(), ) } } diff --git a/vortex-cuda/benches/delta_cuda.rs b/vortex-cuda/benches/delta_cuda.rs index 893d14b6013..751d5f79ba0 100644 --- a/vortex-cuda/benches/delta_cuda.rs +++ b/vortex-cuda/benches/delta_cuda.rs @@ -21,7 +21,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::DeviceRepr; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::array::IntoArray; @@ -43,6 +42,7 @@ use vortex_array::session::ArraySession; use vortex_cuda::CudaDispatchMode; use vortex_cuda::CudaSession; use vortex_cuda::executor::CudaArrayExt; +use vortex_cuda_driver::DeviceRepr; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/dict_cuda.rs b/vortex-cuda/benches/dict_cuda.rs index 97e3ed5c1eb..fee572a4fa8 100644 --- a/vortex-cuda/benches/dict_cuda.rs +++ b/vortex-cuda/benches/dict_cuda.rs @@ -18,7 +18,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::DeviceRepr; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::array::IntoArray; @@ -31,6 +30,7 @@ use vortex::error::VortexExpect; use vortex_cuda::CudaDispatchMode; use vortex_cuda::CudaSession; use vortex_cuda::executor::CudaArrayExt; +use vortex_cuda_driver::DeviceRepr; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/dynamic_dispatch_cuda.rs b/vortex-cuda/benches/dynamic_dispatch_cuda.rs index e0d5b694788..f28ee37b54c 100644 --- a/vortex-cuda/benches/dynamic_dispatch_cuda.rs +++ b/vortex-cuda/benches/dynamic_dispatch_cuda.rs @@ -18,13 +18,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::CudaFunction; -use cudarc::driver::CudaSlice; -use cudarc::driver::DevicePtr; -use cudarc::driver::DeviceRepr; -use cudarc::driver::LaunchConfig; -use cudarc::driver::PushKernelArg; -use cudarc::driver::sys::CUevent_flags; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::array::ArrayRef; @@ -76,6 +69,13 @@ use vortex_cuda::cuda_session; use vortex_cuda::dynamic_dispatch::CudaDispatchPlan; use vortex_cuda::dynamic_dispatch::DispatchPlan; use vortex_cuda::dynamic_dispatch::MaterializedPlan; +use vortex_cuda_driver::CudaFunction; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::PushKernelArg; +use vortex_cuda_driver::sys::CUevent_flags; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/filter_cuda.rs b/vortex-cuda/benches/filter_cuda.rs index 8703a49a706..d8cdf53edb4 100644 --- a/vortex-cuda/benches/filter_cuda.rs +++ b/vortex-cuda/benches/filter_cuda.rs @@ -16,13 +16,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::CudaSlice; -use cudarc::driver::CudaView; -use cudarc::driver::DevicePtr; -use cudarc::driver::DevicePtrMut; -use cudarc::driver::DeviceRepr; -use cudarc::driver::ValidAsZeroBits; -use cudarc::driver::sys::CUevent_flags; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::error::VortexExpect; @@ -33,6 +26,13 @@ use vortex_cub::filter::cudaStream_t; use vortex_cuda::CudaDeviceBuffer; use vortex_cuda::CudaExecutionCtx; use vortex_cuda::CudaSession; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::CudaView; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DevicePtrMut; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::ValidAsZeroBits; +use vortex_cuda_driver::sys::CUevent_flags; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/for_cuda.rs b/vortex-cuda/benches/for_cuda.rs index c5a6464d2e7..efbaf1fa4b6 100644 --- a/vortex-cuda/benches/for_cuda.rs +++ b/vortex-cuda/benches/for_cuda.rs @@ -19,7 +19,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::DeviceRepr; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::array::IntoArray; @@ -44,6 +43,7 @@ use vortex_array::session::ArraySession; use vortex_cuda::CudaDispatchMode; use vortex_cuda::CudaSession; use vortex_cuda::executor::CudaArrayExt; +use vortex_cuda_driver::DeviceRepr; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/runend_cuda.rs b/vortex-cuda/benches/runend_cuda.rs index 4c76a70e387..2742bdeb290 100644 --- a/vortex-cuda/benches/runend_cuda.rs +++ b/vortex-cuda/benches/runend_cuda.rs @@ -17,7 +17,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::DeviceRepr; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::array::ExecutionCtx; @@ -30,6 +29,7 @@ use vortex::encodings::runend::RunEnd; use vortex::encodings::runend::RunEndArray; use vortex_cuda::CudaSession; use vortex_cuda::executor::CudaArrayExt; +use vortex_cuda_driver::DeviceRepr; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/throughput_cuda.rs b/vortex-cuda/benches/throughput_cuda.rs index 465e276cab5..86b67497570 100644 --- a/vortex-cuda/benches/throughput_cuda.rs +++ b/vortex-cuda/benches/throughput_cuda.rs @@ -17,13 +17,13 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::DevicePtr; -use cudarc::driver::DevicePtrMut; -use cudarc::driver::sys; -use cudarc::driver::sys::CUevent_flags; use mimalloc::MiMalloc; use vortex_cuda::CudaExecutionCtx; use vortex_cuda::CudaSession; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DevicePtrMut; +use vortex_cuda_driver::sys; +use vortex_cuda_driver::sys::CUevent_flags; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/benches/timed_launch_strategy/mod.rs b/vortex-cuda/benches/timed_launch_strategy/mod.rs index 9535f6e1c1c..e136ca69ba5 100644 --- a/vortex-cuda/benches/timed_launch_strategy/mod.rs +++ b/vortex-cuda/benches/timed_launch_strategy/mod.rs @@ -5,11 +5,10 @@ use std::sync::Arc; use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering; -use cudarc::driver::sys::CUevent_flags; -use cudarc::driver::sys::CUevent_flags::CU_EVENT_BLOCKING_SYNC; use vortex::error::VortexResult; use vortex_cuda::CudaKernelEvents; use vortex_cuda::LaunchStrategy; +use vortex_cuda_driver::sys::CUevent_flags; #[derive(Debug, Default)] pub struct TimedLaunchStrategy { @@ -26,7 +25,7 @@ impl TimedLaunchStrategy { impl LaunchStrategy for TimedLaunchStrategy { fn event_flags(&self) -> CUevent_flags { // using blocking_sync to make sure all events flush before we complete. - CU_EVENT_BLOCKING_SYNC + CUevent_flags::CU_EVENT_BLOCKING_SYNC } fn on_complete(&self, events: &CudaKernelEvents, _len: usize) -> VortexResult<()> { diff --git a/vortex-cuda/benches/zstd_cuda.rs b/vortex-cuda/benches/zstd_cuda.rs index 5086a907355..a616faa3901 100644 --- a/vortex-cuda/benches/zstd_cuda.rs +++ b/vortex-cuda/benches/zstd_cuda.rs @@ -8,8 +8,6 @@ use std::time::Duration; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; -use cudarc::driver::DevicePtrMut; -use cudarc::driver::sys::CUevent_flags; use futures::executor::block_on; use mimalloc::MiMalloc; use vortex::array::arrays::VarBinViewArray; @@ -24,6 +22,8 @@ use vortex_cuda::CudaSession; use vortex_cuda::ZstdKernelPrep; use vortex_cuda::nvcomp::zstd as nvcomp_zstd; use vortex_cuda::zstd_kernel_prepare; +use vortex_cuda_driver::DevicePtrMut; +use vortex_cuda_driver::sys::CUevent_flags; use vortex_cuda_macros::cuda_available; use vortex_cuda_macros::cuda_not_available; diff --git a/vortex-cuda/driver/Cargo.toml b/vortex-cuda/driver/Cargo.toml index 7cb879b2d87..1c7cbec260e 100644 --- a/vortex-cuda/driver/Cargo.toml +++ b/vortex-cuda/driver/Cargo.toml @@ -22,9 +22,11 @@ workspace = true [features] default = [] f16 = ["dep:half"] +i256 = ["dep:vortex-array"] [dependencies] half = { workspace = true, optional = true } libloading = { workspace = true } parking_lot = { workspace = true } smallvec = { workspace = true } +vortex-array = { workspace = true, optional = true } diff --git a/vortex-cuda/driver/src/repr.rs b/vortex-cuda/driver/src/repr.rs index 39280b2f7b9..518e518c4b9 100644 --- a/vortex-cuda/driver/src/repr.rs +++ b/vortex-cuda/driver/src/repr.rs @@ -36,6 +36,10 @@ impl_plain!( #[cfg(feature = "f16")] impl_plain!(half::f16, half::bf16); +#[cfg(feature = "i256")] +// SAFETY: i256 transparently wraps Arrow's pair of 128-bit integers, matching the CUDA layout. +unsafe impl DeviceRepr for vortex_array::dtype::i256 {} + // SAFETY: Arrays of device values are laid out contiguously. unsafe impl DeviceRepr for [T; N] {} // SAFETY: Arrays of values valid as zeros are valid as zeros. diff --git a/vortex-cuda/ffi/Cargo.toml b/vortex-cuda/ffi/Cargo.toml index 323c709e70b..c21150b9898 100644 --- a/vortex-cuda/ffi/Cargo.toml +++ b/vortex-cuda/ffi/Cargo.toml @@ -17,10 +17,10 @@ arrow-schema = { workspace = true, features = ["ffi"] } futures = { workspace = true, features = ["executor"] } vortex = { workspace = true, features = ["object_store"] } vortex-cuda = { path = ".." } +vortex-cuda-driver = { workspace = true } vortex-ffi = { path = "../../vortex-ffi" } [dev-dependencies] -cudarc = { workspace = true } tempfile = { workspace = true } vortex-cuda-macros = { workspace = true } diff --git a/vortex-cuda/ffi/src/lib.rs b/vortex-cuda/ffi/src/lib.rs index f34e4408ef4..fd2cfc8c08c 100644 --- a/vortex-cuda/ffi/src/lib.rs +++ b/vortex-cuda/ffi/src/lib.rs @@ -505,9 +505,6 @@ mod tests { use arrow_schema::DataType; use arrow_schema::Field; use arrow_schema::Schema; - use cudarc::driver::CudaContext; - use cudarc::driver::result; - use cudarc::driver::sys::CUevent; use futures::TryStreamExt; use tempfile::NamedTempFile; use vortex::VortexSessionDefault; @@ -543,6 +540,9 @@ mod tests { use vortex_cuda::arrow::ArrowArray; use vortex_cuda::arrow::release_device_array; use vortex_cuda::arrow::release_schema; + use vortex_cuda_driver::CudaContext; + use vortex_cuda_driver::result; + use vortex_cuda_driver::sys::CUevent; use vortex_cuda_macros::cuda_not_available; use vortex_cuda_macros::test as cuda_test; use vortex_ffi::vx_array_free as free_test_array; diff --git a/vortex-cuda/src/arrow/canonical.rs b/vortex-cuda/src/arrow/canonical.rs index 44e4b11f0b0..23859bcf4de 100644 --- a/vortex-cuda/src/arrow/canonical.rs +++ b/vortex-cuda/src/arrow/canonical.rs @@ -7,10 +7,6 @@ use std::ptr; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::CudaSlice; -use cudarc::driver::DeviceRepr; -use cudarc::driver::LaunchConfig; -use cudarc::driver::PushKernelArg; use futures::future::BoxFuture; use futures::future::join; use vortex::array::ArrayRef; @@ -63,6 +59,10 @@ use vortex::error::vortex_ensure; use vortex::error::vortex_ensure_eq; use vortex::error::vortex_err; use vortex::extension::datetime::AnyTemporal; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::PushKernelArg; use vortex_onpair::OnPair; use crate::CudaBufferExt; diff --git a/vortex-cuda/src/arrow/list_view.rs b/vortex-cuda/src/arrow/list_view.rs index 2ce3b3b5669..e76d71d4a96 100644 --- a/vortex-cuda/src/arrow/list_view.rs +++ b/vortex-cuda/src/arrow/list_view.rs @@ -5,9 +5,6 @@ use std::sync::Arc; -use cudarc::driver::CudaSlice; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use vortex::array::ArrayRef; use vortex::array::Canonical; use vortex::array::IntoArray; @@ -27,6 +24,9 @@ use vortex::error::VortexResult; use vortex::error::vortex_bail; use vortex::error::vortex_ensure; use vortex::error::vortex_err; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use super::ArrowArray; use super::SyncEvent; diff --git a/vortex-cuda/src/arrow/mod.rs b/vortex-cuda/src/arrow/mod.rs index 3baa16b8853..9d4da485966 100644 --- a/vortex-cuda/src/arrow/mod.rs +++ b/vortex-cuda/src/arrow/mod.rs @@ -30,10 +30,6 @@ use arrow_schema::Schema; use arrow_schema::ffi::FFI_ArrowSchema; use async_trait::async_trait; pub(crate) use canonical::CanonicalDeviceArrayExport; -use cudarc::driver::CudaEvent; -use cudarc::driver::CudaStream; -use cudarc::driver::DevicePtr; -use cudarc::runtime::sys::cudaEvent_t; pub(crate) use offsets::I32Offsets; pub(crate) use offsets::i32_offsets_from_lengths; use vortex::array::ArrayRef; @@ -61,6 +57,10 @@ use vortex::io::runtime::BlockingRuntime; use vortex::io::runtime::current::CurrentThreadRuntime; use vortex::session::VortexSession; use vortex_arrow::ArrowSessionExt; +use vortex_cuda_driver::CudaEvent; +use vortex_cuda_driver::CudaStream; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::sys::CUevent as cudaEvent_t; use crate::CudaBufferExt; use crate::CudaExecutionCtx; @@ -172,10 +172,9 @@ impl PrivateData { Ok(ptr::null()) } Some(handle) => { - // The buffer may have been populated on a different stream (for example, - // pooled file reads use a dedicated H2D stream). Access it through cudarc's - // stream-aware API so this export stream waits for pending writes before - // its Arrow sync event is recorded. + // The buffer may have been populated on a different pooled stream. + // Access it through the driver's stream-aware API so this export stream + // waits for pending writes before its Arrow sync event is recorded. let view = handle.cuda_view::()?; let (device_ptr, record_read) = view.device_ptr(ctx.stream()); drop(record_read); diff --git a/vortex-cuda/src/arrow/offsets.rs b/vortex-cuda/src/arrow/offsets.rs index 4eda482cb41..008f10ae04e 100644 --- a/vortex-cuda/src/arrow/offsets.rs +++ b/vortex-cuda/src/arrow/offsets.rs @@ -5,8 +5,6 @@ use std::sync::Arc; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use vortex::array::arrays::PrimitiveArray; use vortex::array::arrays::primitive::PrimitiveDataParts; use vortex::array::buffer::BufferHandle; @@ -16,6 +14,8 @@ use vortex::dtype::NativePType; use vortex::error::VortexResult; use vortex::error::vortex_bail; use vortex::error::vortex_err; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/cub.rs b/vortex-cuda/src/cub.rs index 0612a13fc07..ee9552ab494 100644 --- a/vortex-cuda/src/cub.rs +++ b/vortex-cuda/src/cub.rs @@ -5,15 +5,15 @@ use std::ffi::c_void; -use cudarc::driver::CudaSlice; -use cudarc::driver::DevicePtr; -use cudarc::driver::DevicePtrMut; use vortex::array::buffer::BufferHandle; use vortex::error::VortexResult; use vortex::error::vortex_err; use vortex_cub::onpair; use vortex_cub::scan; use vortex_cub::scan::cudaStream_t; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DevicePtrMut; use crate::CudaBufferExt; use crate::CudaExecutionCtx; @@ -120,8 +120,8 @@ mod tests { lens: Vec, ) -> VortexResult<(Vec, u32)> where - C: cudarc::driver::DeviceRepr - + cudarc::driver::ValidAsZeroBits + C: vortex_cuda_driver::DeviceRepr + + vortex_cuda_driver::ValidAsZeroBits + std::fmt::Debug + Send + Sync diff --git a/vortex-cuda/src/device_buffer.rs b/vortex-cuda/src/device_buffer.rs index 19d23e7e2a1..2729c992115 100644 --- a/vortex-cuda/src/device_buffer.rs +++ b/vortex-cuda/src/device_buffer.rs @@ -10,12 +10,6 @@ use std::hash::Hasher; use std::ops::Range; use std::sync::Arc; -use cudarc::driver::CudaSlice; -use cudarc::driver::CudaView; -use cudarc::driver::CudaViewMut; -use cudarc::driver::DevicePtr; -use cudarc::driver::DeviceRepr; -use cudarc::driver::sys; use futures::executor::block_on; use futures::future::BoxFuture; use vortex::array::buffer::BufferHandle; @@ -28,6 +22,12 @@ use vortex::error::VortexResult; use vortex::error::vortex_ensure; use vortex::error::vortex_err; use vortex::error::vortex_panic; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::CudaView; +use vortex_cuda_driver::CudaViewMut; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::sys; use crate::stream::await_stream_callback; @@ -60,13 +60,13 @@ mod private { use std::fmt::Debug; use std::sync::Arc; - use cudarc::driver::CudaSlice; - use cudarc::driver::CudaStream; - use cudarc::driver::CudaView; - use cudarc::driver::CudaViewMut; - use cudarc::driver::DeviceRepr; use vortex::buffer::Alignment; use vortex::error::VortexExpect; + use vortex_cuda_driver::CudaSlice; + use vortex_cuda_driver::CudaStream; + use vortex_cuda_driver::CudaView; + use vortex_cuda_driver::CudaViewMut; + use vortex_cuda_driver::DeviceRepr; pub trait DeviceAllocation: Debug + Send + Sync + 'static { /// Get the minimum alignment of the allocation. @@ -407,8 +407,8 @@ impl DeviceBuffer for CudaDeviceBuffer { ) -> VortexResult>> { let stream = self.allocation.stream(); let source = self.as_view::(); - // Use cudarc's read guard so this allocation stream waits for writes submitted on any - // other managed stream before scheduling the device-to-host copy. + // Use the read guard so this allocation stream waits for writes submitted on any + // other stream before scheduling the device-to-host copy. let (src_ptr, record_read) = source.device_ptr(stream); let mut host_buffer: ByteBufferMut = @@ -512,13 +512,13 @@ impl DeviceBuffer for CudaDeviceBuffer { #[cfg(test)] mod tests { - use cudarc::driver::CudaContext; - use cudarc::driver::PushKernelArg; use vortex::buffer::Buffer; use vortex::dtype::PType; use vortex::error::VortexResult; use vortex::error::vortex_bail; use vortex::session::VortexSession; + use vortex_cuda_driver::CudaContext; + use vortex_cuda_driver::PushKernelArg; use super::*; use crate::CudaSession; diff --git a/vortex-cuda/src/dynamic_dispatch/mod.rs b/vortex-cuda/src/dynamic_dispatch/mod.rs index 0a031dc95ef..62b7add849b 100644 --- a/vortex-cuda/src/dynamic_dispatch/mod.rs +++ b/vortex-cuda/src/dynamic_dispatch/mod.rs @@ -21,9 +21,6 @@ use std::borrow::Borrow; use std::mem::size_of; use std::sync::Arc; -use cudarc::driver::DevicePtr; -use cudarc::driver::LaunchConfig; -use cudarc::driver::PushKernelArg; use vortex::array::Canonical; use vortex::array::IntoArray; use vortex::array::arrays::ConstantArray; @@ -41,6 +38,9 @@ use vortex::dtype::PType; use vortex::error::VortexResult; use vortex::error::vortex_bail; use vortex::error::vortex_err; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; @@ -405,7 +405,7 @@ impl MaterializedPlan { ctx: &mut CudaExecutionCtx, ) -> VortexResult where - T: cudarc::driver::DeviceRepr + vortex::dtype::NativePType, + T: vortex_cuda_driver::DeviceRepr + vortex::dtype::NativePType, { let nullability = self.validity.nullability(); @@ -477,9 +477,6 @@ mod tests { use std::sync::Arc; use std::sync::LazyLock; - use cudarc::driver::DevicePtr; - use cudarc::driver::LaunchConfig; - use cudarc::driver::PushKernelArg; use rstest::rstest; use vortex::array::ArrayRef; use vortex::array::IntoArray; @@ -521,6 +518,9 @@ mod tests { use vortex_array::arrays::FilterArray; use vortex_array::assert_arrays_eq; use vortex_array::patches::Patches; + use vortex_cuda_driver::DevicePtr; + use vortex_cuda_driver::LaunchConfig; + use vortex_cuda_driver::PushKernelArg; use super::*; use crate::CanonicalCudaExt; @@ -629,7 +629,7 @@ mod tests { fn copy_raw_to_device( cuda_ctx: &CudaExecutionCtx, data: &[u32], - ) -> VortexResult<(u64, Arc>)> { + ) -> VortexResult<(u64, Arc>)> { let device_buf = Arc::new( cuda_ctx .stream() diff --git a/vortex-cuda/src/executor.rs b/vortex-cuda/src/executor.rs index 205b16f83a2..c61db212623 100644 --- a/vortex-cuda/src/executor.rs +++ b/vortex-cuda/src/executor.rs @@ -6,13 +6,6 @@ use std::sync::Arc; use std::time::Duration; use async_trait::async_trait; -use cudarc::driver::CudaEvent; -use cudarc::driver::CudaFunction; -use cudarc::driver::CudaSlice; -use cudarc::driver::DeviceRepr; -use cudarc::driver::LaunchArgs; -use cudarc::driver::LaunchConfig; -use cudarc::driver::ValidAsZeroBits; use futures::future::BoxFuture; use tracing::debug; use tracing::trace; @@ -39,6 +32,13 @@ use vortex::error::vortex_bail; use vortex::error::vortex_ensure; use vortex::error::vortex_ensure_eq; use vortex::error::vortex_err; +use vortex_cuda_driver::CudaEvent; +use vortex_cuda_driver::CudaFunction; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::LaunchArgs; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::ValidAsZeroBits; use crate::CudaSession; use crate::DictionaryExport; @@ -146,7 +146,7 @@ impl CudaExecutionCtx { /// Perform an external kernel launch, with events created and logged via the configured /// [`LaunchStrategy`]. /// - /// We use CUB and NVCOMP routines, and those don't match the normal `cudarc` entrypoints, so + /// We use CUB and NVCOMP routines, and those don't match the normal launch entrypoints, so /// to inject the configured launch strategy we need to bracket it ourselves. pub fn launch_external VortexResult<()>>( &self, @@ -315,7 +315,7 @@ impl CudaExecutionCtx { /// Returns a reference to the underlying [`VortexCudaStream`]. /// /// Through [`Deref`][std::ops::Deref], this also provides access to the - /// inner [`Arc`] and all of cudarc's stream methods. + /// inner [`Arc`] and all of its stream methods. pub fn stream(&self) -> &VortexCudaStream { &self.stream } diff --git a/vortex-cuda/src/kernel/arrays/constant.rs b/vortex-cuda/src/kernel/arrays/constant.rs index 0fbad72493e..86f13a77e2b 100644 --- a/vortex-cuda/src/kernel/arrays/constant.rs +++ b/vortex-cuda/src/kernel/arrays/constant.rs @@ -5,8 +5,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -26,6 +24,8 @@ use vortex::dtype::NativePType; use vortex::error::VortexResult; use vortex::error::vortex_bail; use vortex::error::vortex_err; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CudaDeviceBuffer; use crate::executor::CudaExecute; diff --git a/vortex-cuda/src/kernel/arrays/dict.rs b/vortex-cuda/src/kernel/arrays/dict.rs index e9bb20daa94..aad8bc677dd 100644 --- a/vortex-cuda/src/kernel/arrays/dict.rs +++ b/vortex-cuda/src/kernel/arrays/dict.rs @@ -4,8 +4,6 @@ use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -32,6 +30,8 @@ use vortex::error::VortexExpect; use vortex::error::VortexResult; use vortex::error::vortex_bail; use vortex::error::vortex_ensure; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/kernel/arrays/list.rs b/vortex-cuda/src/kernel/arrays/list.rs index 167c12df9c4..2f1580afdaa 100644 --- a/vortex-cuda/src/kernel/arrays/list.rs +++ b/vortex-cuda/src/kernel/arrays/list.rs @@ -4,8 +4,6 @@ use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -24,6 +22,8 @@ use vortex::dtype::Nullability; use vortex::error::VortexResult; use vortex::error::vortex_ensure_eq; use vortex::error::vortex_err; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/kernel/encodings/alp.rs b/vortex-cuda/src/kernel/encodings/alp.rs index e543db1aca0..5019b56f8c7 100644 --- a/vortex-cuda/src/kernel/encodings/alp.rs +++ b/vortex-cuda/src/kernel/encodings/alp.rs @@ -4,9 +4,6 @@ use std::fmt::Debug; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::LaunchConfig; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -24,6 +21,9 @@ use vortex::encodings::alp::match_each_alp_float_ptype; use vortex::error::VortexResult; use vortex::error::vortex_ensure; use vortex::error::vortex_err; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/kernel/encodings/bitpacked.rs b/vortex-cuda/src/kernel/encodings/bitpacked.rs index 3b28692722c..3f1056bd406 100644 --- a/vortex-cuda/src/kernel/encodings/bitpacked.rs +++ b/vortex-cuda/src/kernel/encodings/bitpacked.rs @@ -5,10 +5,6 @@ use std::fmt::Debug; use std::ops::Range; use async_trait::async_trait; -use cudarc::driver::CudaFunction; -use cudarc::driver::DeviceRepr; -use cudarc::driver::LaunchConfig; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::ArrayVTable; @@ -33,6 +29,10 @@ use vortex::error::VortexResult; use vortex::error::vortex_bail; use vortex::error::vortex_ensure; use vortex::error::vortex_err; +use vortex_cuda_driver::CudaFunction; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/kernel/encodings/date_time_parts.rs b/vortex-cuda/src/kernel/encodings/date_time_parts.rs index 9a1a339aa67..05efae4cb05 100644 --- a/vortex-cuda/src/kernel/encodings/date_time_parts.rs +++ b/vortex-cuda/src/kernel/encodings/date_time_parts.rs @@ -4,8 +4,6 @@ use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -29,6 +27,8 @@ use vortex::error::vortex_err; use vortex::extension::datetime::TimeUnit; use vortex::extension::datetime::Timestamp; use vortex::scalar::Scalar; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/kernel/encodings/delta.rs b/vortex-cuda/src/kernel/encodings/delta.rs index 0d01b3789c9..f75b2776a34 100644 --- a/vortex-cuda/src/kernel/encodings/delta.rs +++ b/vortex-cuda/src/kernel/encodings/delta.rs @@ -15,8 +15,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::LaunchConfig; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -33,6 +31,8 @@ use vortex::error::VortexResult; use vortex::error::vortex_ensure; use vortex::error::vortex_ensure_eq; use vortex::error::vortex_err; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/kernel/encodings/for_.rs b/vortex-cuda/src/kernel/encodings/for_.rs index bcec39213a2..52dbfd377a6 100644 --- a/vortex-cuda/src/kernel/encodings/for_.rs +++ b/vortex-cuda/src/kernel/encodings/for_.rs @@ -5,8 +5,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -30,6 +28,8 @@ use vortex::error::VortexExpect; use vortex::error::VortexResult; use vortex::error::vortex_ensure; use vortex::error::vortex_err; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use vortex_error::vortex_bail; use crate::CudaBufferExt; diff --git a/vortex-cuda/src/kernel/encodings/fsst.rs b/vortex-cuda/src/kernel/encodings/fsst.rs index efa499b60ec..0a0e91d1b54 100644 --- a/vortex-cuda/src/kernel/encodings/fsst.rs +++ b/vortex-cuda/src/kernel/encodings/fsst.rs @@ -7,9 +7,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DevicePtr; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -37,6 +34,9 @@ use vortex::encodings::fsst::FSSTArraySlotsExt; use vortex::error::VortexExpect; use vortex::error::VortexResult; use vortex::error::vortex_err; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CanonicalCudaExt; use crate::CudaBufferExt; diff --git a/vortex-cuda/src/kernel/encodings/onpair.rs b/vortex-cuda/src/kernel/encodings/onpair.rs index a97aca0941b..75e6677ee50 100644 --- a/vortex-cuda/src/kernel/encodings/onpair.rs +++ b/vortex-cuda/src/kernel/encodings/onpair.rs @@ -40,11 +40,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::CudaSlice; -use cudarc::driver::DevicePtr; -use cudarc::driver::DeviceRepr; -use cudarc::driver::LaunchConfig; -use cudarc::driver::PushKernelArg; use num_traits::AsPrimitive; use tracing::instrument; use vortex::array::ArrayRef; @@ -71,6 +66,11 @@ use vortex::error::vortex_ensure; use vortex::error::vortex_ensure_eq; use vortex::error::vortex_err; use vortex_array::ArrayView; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::PushKernelArg; use vortex_onpair::DictionaryView; use vortex_onpair::MAX_TOKEN_SIZE; use vortex_onpair::OnPair; diff --git a/vortex-cuda/src/kernel/encodings/runend.rs b/vortex-cuda/src/kernel/encodings/runend.rs index 5519e3de79c..54337f71941 100644 --- a/vortex-cuda/src/kernel/encodings/runend.rs +++ b/vortex-cuda/src/kernel/encodings/runend.rs @@ -4,8 +4,6 @@ use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -30,6 +28,8 @@ use vortex::error::vortex_bail; use vortex::error::vortex_ensure; use vortex::error::vortex_err; use vortex::scalar::Scalar; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/kernel/encodings/sequence.rs b/vortex-cuda/src/kernel/encodings/sequence.rs index 86bf56107d4..f38a6ba1bac 100644 --- a/vortex-cuda/src/kernel/encodings/sequence.rs +++ b/vortex-cuda/src/kernel/encodings/sequence.rs @@ -4,8 +4,6 @@ use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -18,6 +16,8 @@ use vortex::dtype::PType; use vortex::encodings::sequence::Sequence; use vortex::error::VortexResult; use vortex::error::vortex_err; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CudaDeviceBuffer; use crate::CudaExecutionCtx; diff --git a/vortex-cuda/src/kernel/encodings/zigzag.rs b/vortex-cuda/src/kernel/encodings/zigzag.rs index 33b22bdc29f..927e80ba686 100644 --- a/vortex-cuda/src/kernel/encodings/zigzag.rs +++ b/vortex-cuda/src/kernel/encodings/zigzag.rs @@ -5,8 +5,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DeviceRepr; -use cudarc::driver::PushKernelArg; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -23,6 +21,8 @@ use vortex::error::VortexResult; use vortex::error::vortex_ensure; use vortex::error::vortex_ensure_eq; use vortex::error::vortex_err; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::PushKernelArg; use crate::CudaBufferExt; use crate::CudaDeviceBuffer; diff --git a/vortex-cuda/src/kernel/encodings/zstd.rs b/vortex-cuda/src/kernel/encodings/zstd.rs index 0266fd573aa..5286acbf31b 100644 --- a/vortex-cuda/src/kernel/encodings/zstd.rs +++ b/vortex-cuda/src/kernel/encodings/zstd.rs @@ -7,9 +7,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::CudaSlice; -use cudarc::driver::DevicePtr; -use cudarc::driver::DevicePtrMut; use futures::future::try_join_all; use tracing::debug; use tracing::instrument; @@ -35,6 +32,9 @@ use vortex::error::VortexResult; use vortex::error::vortex_bail; use vortex::error::vortex_err; use vortex::mask::AllOr; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DevicePtrMut; use vortex_nvcomp::sys::nvcompStatus_t; use vortex_nvcomp::zstd as nvcomp_zstd; diff --git a/vortex-cuda/src/kernel/encodings/zstd_buffers.rs b/vortex-cuda/src/kernel/encodings/zstd_buffers.rs index 2ea33dff00b..79d0b36efb9 100644 --- a/vortex-cuda/src/kernel/encodings/zstd_buffers.rs +++ b/vortex-cuda/src/kernel/encodings/zstd_buffers.rs @@ -7,9 +7,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::CudaSlice; -use cudarc::driver::DevicePtr; -use cudarc::driver::DevicePtrMut; use vortex::array::ArrayRef; use vortex::array::Canonical; use vortex::array::buffer::BufferHandle; @@ -21,6 +18,9 @@ use vortex::encodings::zstd::ZstdBuffersArray; use vortex::encodings::zstd::ZstdBuffersDecodePlan; use vortex::error::VortexResult; use vortex::error::vortex_err; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DevicePtrMut; use vortex_nvcomp::sys; use vortex_nvcomp::sys::nvcompStatus_t; use vortex_nvcomp::zstd as nvcomp_zstd; diff --git a/vortex-cuda/src/kernel/filter/decimal.rs b/vortex-cuda/src/kernel/filter/decimal.rs index c8b303c81b1..c09997520b5 100644 --- a/vortex-cuda/src/kernel/filter/decimal.rs +++ b/vortex-cuda/src/kernel/filter/decimal.rs @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -use cudarc::driver::DeviceRepr; use vortex::array::Canonical; use vortex::array::arrays::DecimalArray; use vortex::array::arrays::decimal::DecimalDataParts; @@ -9,6 +8,7 @@ use vortex::dtype::NativeDecimalType; use vortex::error::VortexResult; use vortex::mask::Mask; use vortex_cub::filter::CubFilterable; +use vortex_cuda_driver::DeviceRepr; use crate::CudaExecutionCtx; use crate::kernel::filter::filter_sized; diff --git a/vortex-cuda/src/kernel/filter/mod.rs b/vortex-cuda/src/kernel/filter/mod.rs index 3bb02d7f8db..60556585fa3 100644 --- a/vortex-cuda/src/kernel/filter/mod.rs +++ b/vortex-cuda/src/kernel/filter/mod.rs @@ -12,9 +12,6 @@ use std::fmt::Debug; use std::sync::Arc; use async_trait::async_trait; -use cudarc::driver::DevicePtr; -use cudarc::driver::DevicePtrMut; -use cudarc::driver::DeviceRepr; use tracing::instrument; use vortex::array::ArrayRef; use vortex::array::Canonical; @@ -29,6 +26,9 @@ use vortex::error::vortex_err; use vortex::mask::Mask; use vortex_cub::filter::CubFilterable; use vortex_cub::filter::cudaStream_t; +use vortex_cuda_driver::DevicePtr; +use vortex_cuda_driver::DevicePtrMut; +use vortex_cuda_driver::DeviceRepr; use crate::CudaDeviceBuffer; use crate::executor::CudaArrayExt; diff --git a/vortex-cuda/src/kernel/filter/primitive.rs b/vortex-cuda/src/kernel/filter/primitive.rs index f49b63e2748..82f07007250 100644 --- a/vortex-cuda/src/kernel/filter/primitive.rs +++ b/vortex-cuda/src/kernel/filter/primitive.rs @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -use cudarc::driver::DeviceRepr; use vortex::array::Canonical; use vortex::array::arrays::PrimitiveArray; use vortex::array::arrays::primitive::PrimitiveDataParts; @@ -9,6 +8,7 @@ use vortex::dtype::NativePType; use vortex::error::VortexResult; use vortex::mask::Mask; use vortex_cub::filter::CubFilterable; +use vortex_cuda_driver::DeviceRepr; use crate::CudaExecutionCtx; use crate::kernel::filter::filter_sized; diff --git a/vortex-cuda/src/kernel/mod.rs b/vortex-cuda/src/kernel/mod.rs index 70ab4c5fbca..f81a5c05119 100644 --- a/vortex-cuda/src/kernel/mod.rs +++ b/vortex-cuda/src/kernel/mod.rs @@ -6,18 +6,17 @@ use std::fmt::Debug; use std::sync::Arc; -use cudarc::driver::CudaContext; -use cudarc::driver::CudaFunction; -use cudarc::driver::CudaModule; -use cudarc::driver::CudaStream; -use cudarc::driver::LaunchArgs; -use cudarc::driver::LaunchConfig; -use cudarc::driver::sys::CUevent_flags; -use cudarc::nvrtc::Ptx; use tracing::trace; use vortex::error::VortexResult; use vortex::error::vortex_err; use vortex::utils::aliases::dash_map::DashMap; +use vortex_cuda_driver::CudaContext; +use vortex_cuda_driver::CudaFunction; +use vortex_cuda_driver::CudaModule; +use vortex_cuda_driver::CudaStream; +use vortex_cuda_driver::LaunchArgs; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::sys::CUevent_flags; mod arrays; // Fatbins let the CUDA driver select among the configured real and virtual architectures. @@ -259,7 +258,7 @@ impl KernelLoader { })?; cuda_context - .load_module(Ptx::from_binary(fatbin.to_vec())) + .load_module(fatbin) .map_err(|e| vortex_err!("Failed to load embedded CUDA module {module_name}: {e}")) } } diff --git a/vortex-cuda/src/kernel/patches/mod.rs b/vortex-cuda/src/kernel/patches/mod.rs index 101d3c8ff7f..36e7c9ebaa1 100644 --- a/vortex-cuda/src/kernel/patches/mod.rs +++ b/vortex-cuda/src/kernel/patches/mod.rs @@ -10,10 +10,10 @@ pub mod gpu { include!(concat!(env!("OUT_DIR"), "/patches.rs")); } -use cudarc::driver::DeviceRepr; use vortex::dtype::PType; use vortex::error::VortexResult; use vortex::error::vortex_bail; +use vortex_cuda_driver::DeviceRepr; use crate::CudaBufferExt; use crate::kernel::patches::gpu::ChunkOffsetType; diff --git a/vortex-cuda/src/lib.rs b/vortex-cuda/src/lib.rs index f2e22433418..f57daf0c58d 100644 --- a/vortex-cuda/src/lib.rs +++ b/vortex-cuda/src/lib.rs @@ -3,9 +3,9 @@ //! CUDA support for Vortex arrays. -use cudarc::driver::CudaContext; -use cudarc::driver::sys; use tracing::info; +use vortex_cuda_driver::CudaContext; +use vortex_cuda_driver::sys; pub mod arrow; mod canonical; @@ -104,8 +104,8 @@ use crate::kernel::SliceExecutor; /// Checks if a CUDA driver and at least one CUDA device are available. /// -/// cudarc loads `libcuda` lazily and panics if the driver library is absent, so we first probe -/// for it with cudarc's own `is_culib_present`. Creating the context then fails gracefully with +/// The driver crate loads `libcuda` lazily and panics if the driver library is absent, so we +/// first probe for it with `is_culib_present`. Creating the context then fails gracefully with /// `Err`, rather than panicking, when the driver is present but no usable device is. pub fn cuda_available() -> bool { // SAFETY: `is_culib_present` only tries to dlopen the driver library to test for its diff --git a/vortex-cuda/src/pinned.rs b/vortex-cuda/src/pinned.rs index 3ef8362d136..9b3a6a13888 100644 --- a/vortex-cuda/src/pinned.rs +++ b/vortex-cuda/src/pinned.rs @@ -7,14 +7,6 @@ use std::sync::Arc; use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering; -use cudarc::driver::CudaContext; -use cudarc::driver::CudaEvent; -use cudarc::driver::CudaStream; -use cudarc::driver::CudaViewMut; -use cudarc::driver::HostSlice; -use cudarc::driver::SyncOnDrop; -use cudarc::driver::result; -use cudarc::driver::sys::CUevent_flags; use parking_lot::Mutex; use vortex::error::VortexExpect; use vortex::error::VortexResult; @@ -22,6 +14,14 @@ use vortex::error::vortex_ensure; use vortex::error::vortex_ensure_eq; use vortex::error::vortex_err; use vortex::utils::aliases::hash_map::HashMap; +use vortex_cuda_driver::CudaContext; +use vortex_cuda_driver::CudaEvent; +use vortex_cuda_driver::CudaStream; +use vortex_cuda_driver::CudaViewMut; +use vortex_cuda_driver::HostSlice; +use vortex_cuda_driver::SyncOnDrop; +use vortex_cuda_driver::result; +use vortex_cuda_driver::sys::CUevent_flags; use crate::CudaDeviceBuffer; use crate::stream::VortexCudaStream; @@ -66,8 +66,7 @@ impl PinnedByteBuffer { // Bind explicitly rather than relying on event creation to bind this worker thread. ctx.bind_to_thread() .map_err(|e| vortex_err!("failed to bind pinned host buffer context: {e}"))?; - // Keep file-I/O staging cacheable: cudarc's allocator uses write-combined memory, - // which makes CPU reads expensive. + // Keep file-I/O staging cacheable: write-combined pinned memory makes CPU reads expensive. let ptr = unsafe { result::malloc_host(capacity, 0) } .map_err(|e| vortex_err!("failed to allocate pinned host buffer: {e}"))? .cast::(); @@ -117,7 +116,7 @@ impl HostSlice for PinnedByteBufferView<'_> { let slice = unsafe { std::slice::from_raw_parts(self.buffer.ptr.add(self.range.start), self.range.len()) }; - let sync = SyncOnDrop::Record(Some((&self.buffer.event, stream))); + let sync = SyncOnDrop::record_event(&self.buffer.event, stream); (slice, sync) } @@ -131,7 +130,7 @@ impl HostSlice for PinnedByteBufferView<'_> { let slice = unsafe { std::slice::from_raw_parts_mut(self.buffer.ptr.add(self.range.start), self.range.len()) }; - let sync = SyncOnDrop::Record(Some((&self.buffer.event, stream))); + let sync = SyncOnDrop::record_event(&self.buffer.event, stream); (slice, sync) } } @@ -390,8 +389,8 @@ impl PooledPinnedBuffer { buffer: pinned, range, }; - // Keep the source guard's record as well as the explicit completion record. The latter - // also fences the source when cudarc's automatic event tracking is disabled. + // Check an explicit completion record as well as the source guard so failures take + // the recovery path before the allocation can return to the pool. let completion = stream .memcpy_htod(&source, destination) .and_then(|()| source.buffer.event.record(stream)); @@ -437,14 +436,17 @@ impl Drop for PooledPinnedBuffer { #[cfg(test)] mod tests { use std::sync::Arc; + use std::sync::mpsc::Receiver; use std::sync::mpsc::Sender; + use std::sync::mpsc::channel; - use cudarc::driver::CudaContext; - use cudarc::driver::sys::cudaError_enum; use rstest::rstest; use vortex::array::buffer::DeviceBuffer; use vortex::buffer::Alignment; use vortex::error::VortexResult; + use vortex_cuda_driver::CudaContext; + use vortex_cuda_driver::CudaSlice; + use vortex_cuda_driver::sys::cudaError_enum; use super::*; @@ -534,16 +536,8 @@ mod tests { #[rstest] #[crate::test] - fn transfer_retains_and_reuses_source( - #[values(false, true)] ranged: bool, - #[values(false, true)] automatic_tracking: bool, - ) -> VortexResult<()> { + fn transfer_retains_and_reuses_source(#[values(false, true)] ranged: bool) -> VortexResult<()> { let (pool, stream) = setup()?; - if !automatic_tracking { - // SAFETY: Device allocations are used and freed on their allocation stream; - // the pool must independently fence host reuse even without cudarc tracking. - unsafe { stream.context().disable_event_tracking() }; - } let mut pinned = pool.get(1024)?; pinned.as_mut_slice().fill(0xAB); let allocation = pinned.as_mut_slice().as_ptr(); @@ -607,9 +601,7 @@ mod tests { Ok(()) } - fn setup_resubmission( - automatic_tracking: bool, - ) -> VortexResult<( + fn setup_resubmission() -> VortexResult<( Arc, VortexCudaStream, VortexCudaStream, @@ -622,10 +614,6 @@ mod tests { ctx.new_stream() .map_err(|e| vortex_err!("Failed to create stream: {e}"))?, ); - if !automatic_tracking { - // SAFETY: Each destination stays on its allocation stream. The pool fences sources. - unsafe { stream.context().disable_event_tracking() }; - } let other = VortexCudaStream( pool.ctx .new_stream() @@ -637,7 +625,7 @@ mod tests { fn submit_to_bucket( mut pinned: PooledPinnedBuffer, stream: &VortexCudaStream, - destination: &mut cudarc::driver::CudaSlice, + destination: &mut CudaSlice, ) -> VortexResult<()> { let owner = pinned.inner.as_mut().unwrap(); // SAFETY: Tests initialize the source. On failure retain_after_transfer synchronizes @@ -655,8 +643,6 @@ mod tests { } fn block_stream(stream: &VortexCudaStream) -> VortexResult> { - use std::sync::mpsc::Receiver; - use std::sync::mpsc::channel; let (release, receiver) = channel::<()>(); stream .context() @@ -698,18 +684,15 @@ mod tests { Ok(()) } - fn assert_device_bytes(device: cudarc::driver::CudaSlice, byte: u8) -> VortexResult<()> { + fn assert_device_bytes(device: CudaSlice, byte: u8) -> VortexResult<()> { let host = CudaDeviceBuffer::new(device).copy_to_host_sync(Alignment::of::())?; assert!(host.as_ref().iter().all(|value| *value == byte)); Ok(()) } - #[rstest] - #[case::untracked(false)] - #[case::tracked(true)] #[crate::test] - fn pending_bucket_source_resubmission(#[case] automatic_tracking: bool) -> VortexResult<()> { - let (pool, stream, other) = setup_resubmission(automatic_tracking)?; + fn pending_bucket_source_resubmission() -> VortexResult<()> { + let (pool, stream, other) = setup_resubmission()?; let len = 1024 * 1024; let mut pinned = pool.get(len)?; pinned.as_mut_slice().fill(0x5A); @@ -731,12 +714,9 @@ mod tests { assert_device_bytes(second, 0x5A) } - #[rstest] - #[case::untracked(false)] - #[case::tracked(true)] #[crate::test] - fn pending_bucket_source_wait_failure(#[case] automatic_tracking: bool) -> VortexResult<()> { - let (pool, stream, other) = setup_resubmission(automatic_tracking)?; + fn pending_bucket_source_wait_failure() -> VortexResult<()> { + let (pool, stream, other) = setup_resubmission()?; let len = 1024 * 1024; let mut pinned = pool.get(len)?; pinned.as_mut_slice().fill(0x5A); @@ -765,17 +745,9 @@ mod tests { assert_device_bytes(second, 0xCC) } - #[rstest] #[crate::test] - fn failed_fence_waits_before_reuse( - #[values(false, true)] automatic_tracking: bool, - ) -> VortexResult<()> { + fn failed_fence_waits_before_reuse() -> VortexResult<()> { let (pool, stream) = setup()?; - if !automatic_tracking { - // SAFETY: The destination is used only on its allocation stream; the explicit - // recovery path must fence the source without depending on automatic tracking. - unsafe { stream.context().disable_event_tracking() }; - } let mut pinned = pool.get(1024 * 1024)?; pinned.as_mut_slice().fill(0x3C); let mut destination = stream.device_alloc::(1024 * 1024)?; diff --git a/vortex-cuda/src/pooled_read_at/file.rs b/vortex-cuda/src/pooled_read_at/file.rs index dea1e26f693..237a3bb91fc 100644 --- a/vortex-cuda/src/pooled_read_at/file.rs +++ b/vortex-cuda/src/pooled_read_at/file.rs @@ -15,12 +15,6 @@ use std::sync::LazyLock; use std::sync::mpsc; use std::time::SystemTime; -use cudarc::driver::CudaFunction; -use cudarc::driver::CudaSlice; -use cudarc::driver::DevicePtrMut; -use cudarc::driver::LaunchConfig; -use cudarc::driver::PushKernelArg; -use cudarc::driver::sys::CUdevice_attribute; use futures::FutureExt; use futures::StreamExt; use futures::TryFutureExt; @@ -42,6 +36,12 @@ use vortex::io::CoalesceConfig; use vortex::io::VortexReadAt; use vortex::io::runtime::Handle; use vortex::io::std_file::read_exact_at; +use vortex_cuda_driver::CudaFunction; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::DevicePtrMut; +use vortex_cuda_driver::LaunchConfig; +use vortex_cuda_driver::PushKernelArg; +use vortex_cuda_driver::sys::CUdevice_attribute; #[cfg(target_os = "linux")] use self::direct::DirectFileReadBackend; diff --git a/vortex-cuda/src/session.rs b/vortex-cuda/src/session.rs index 2d4ff54e65f..cdbcb794656 100644 --- a/vortex-cuda/src/session.rs +++ b/vortex-cuda/src/session.rs @@ -7,7 +7,6 @@ use std::panic::AssertUnwindSafe; use std::panic::catch_unwind; use std::sync::Arc; -use cudarc::driver::CudaContext; use vortex::array::ArrayId; use vortex::array::VortexSessionExecute; use vortex::error::VortexResult; @@ -16,6 +15,7 @@ use vortex::session::SessionExt; use vortex::session::SessionGuard; use vortex::session::SessionVar; use vortex::utils::aliases::dash_map::DashMap; +use vortex_cuda_driver::CudaContext; use crate::ExportDeviceArray; use crate::arrow::CanonicalDeviceArrayExport; @@ -131,8 +131,8 @@ impl CudaSession { /// Unlike [`Default::default`], this returns an error instead of panicking when CUDA cannot be /// initialized. pub fn try_default() -> VortexResult { - // cudarc panics rather than returning an error when the CUDA driver library cannot be - // loaded, so catch any unwind here to uphold this constructor's no-panic contract. + // The driver crate panics rather than returning an error when the CUDA driver library + // cannot be loaded, so catch any unwind here to uphold this constructor's no-panic contract. match catch_unwind(AssertUnwindSafe(|| -> VortexResult { let context = CudaContext::new(0) .map_err(|err| vortex_err!("failed to initialize CUDA device 0: {err}"))?; @@ -212,7 +212,7 @@ impl CudaSession { &self, module_name: &str, type_suffixes: &[&str], - ) -> VortexResult { + ) -> VortexResult { self.kernel_loader .load_function(module_name, type_suffixes, &self.context) } diff --git a/vortex-cuda/src/stream.rs b/vortex-cuda/src/stream.rs index a6515b1f8db..eebde8c539c 100644 --- a/vortex-cuda/src/stream.rs +++ b/vortex-cuda/src/stream.rs @@ -9,11 +9,6 @@ use std::mem::size_of_val; use std::ops::Deref; use std::sync::Arc; -use cudarc::driver::CudaSlice; -use cudarc::driver::CudaStream; -use cudarc::driver::DeviceRepr; -use cudarc::driver::ValidAsZeroBits; -use cudarc::driver::result::stream; use futures::future::BoxFuture; use kanal::Sender; use tracing::warn; @@ -21,6 +16,11 @@ use vortex::array::buffer::BufferHandle; use vortex::error::VortexResult; use vortex::error::vortex_ensure; use vortex::error::vortex_err; +use vortex_cuda_driver::CudaSlice; +use vortex_cuda_driver::CudaStream; +use vortex_cuda_driver::DeviceRepr; +use vortex_cuda_driver::ValidAsZeroBits; +use vortex_cuda_driver::result::stream; use crate::CudaDeviceBuffer; use crate::device_buffer::CUDF_VALIDITY_BUFFER_PADDING; diff --git a/vortex-cuda/src/stream_pool.rs b/vortex-cuda/src/stream_pool.rs index 7f1548e311b..4505c6e1f4f 100644 --- a/vortex-cuda/src/stream_pool.rs +++ b/vortex-cuda/src/stream_pool.rs @@ -7,11 +7,11 @@ use std::sync::Arc; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; -use cudarc::driver::CudaContext; -use cudarc::driver::CudaStream; use once_cell::sync::OnceCell; use vortex::error::VortexResult; use vortex::error::vortex_err; +use vortex_cuda_driver::CudaContext; +use vortex_cuda_driver::CudaStream; use crate::stream::VortexCudaStream; @@ -92,10 +92,10 @@ mod tests { use std::sync::Barrier; use std::thread; - use cudarc::driver::CudaContext; use vortex::error::VortexResult; use vortex::error::vortex_err; use vortex::utils::aliases::hash_set::HashSet; + use vortex_cuda_driver::CudaContext; use super::VortexCudaStreamPool;