Safe Rust wrappers for the CUDA Driver API.
This crate takes the raw FFI in [baracuda_cuda_sys] and dresses it up
with RAII handles, typed memory, lifetime-checked slices, and a kernel
launch builder. It deliberately does not hide the Driver-API model:
contexts are explicit, modules are explicit, streams are explicit.
Quickstart
use baracuda_driver::{Context, Device, DeviceBuffer, Module, Stream};
# fn demo() -> baracuda_driver::Result<()> {
let device = Device::get(0)?;
let ctx = Context::new(&device)?;
let stream = Stream::new(&ctx)?;
let host_data: Vec<f32> = (0..1024).map(|i| i as f32).collect();
let device_data = DeviceBuffer::from_slice(&ctx, &host_data)?;
let mut back = vec![0.0f32; host_data.len()];
device_data.copy_to_host(&mut back)?;
stream.synchronize()?;
assert_eq!(host_data, back);
# Ok(())
# }
Modules
- [
device] — [Device] enumeration and attributes. - [
context] — [Context] (explicit CUDA contexts + primary-context reuse). - [
stream] — [Stream], ordered async work queues. - [
event] — [Event], synchronization and timing. - [
memory] — [DeviceBuffer<T>], [DeviceSlice<'_, T>], [DeviceSliceMut<'_, T>]. - [
module] — [Module], [Function] (PTX/CUBIN loading). - [
launch] — [launch::LaunchBuilder] forcuLaunchKernel. - [
init()] —init()helper and driver version queries.