cudarc 0.19.4

Safe and minimal CUDA bindings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use cudarc::driver::{CudaContext, CudaSlice, DriverError};

fn main() -> Result<(), DriverError> {
    let ctx = CudaContext::new(0)?;
    let stream = ctx.default_stream();

    // unsafe initialization of unset memory
    let _: CudaSlice<f32> = unsafe { stream.alloc::<f32>(10) }?;

    // this will have memory initialized as 0
    let _: CudaSlice<f64> = stream.alloc_zeros::<f64>(10)?;

    // initialize with slices!
    let _: CudaSlice<usize> = stream.clone_htod(&[0; 10])?;
    let _: CudaSlice<u32> = stream.clone_htod(&[1, 2, 3])?;

    Ok(())
}