Rust-GPU / Rust-CUDA

Ecosystem of libraries and tools for writing and executing fast GPU code fully in Rust.
Apache License 2.0
2.97k stars 112 forks source link

LockedBox use examples #99

Open solkitten opened 1 year ago

solkitten commented 1 year ago

Could you please give some examples how to use LockedBox? I have a code like this:

#[repr(C, packed)]
#[derive(Debug, Clone, Copy, DeviceCopy)]
pub struct SomeResult {
    pub field: u32
}
...
let mut some_result = SomeResult::default();
let mut lb_some_result = LockedBox::new(&some_result).unwrap();

What should I do to copy it to DeviceBox and back from DeviceBox after the kernel finishes? Things like let dev_results = DeviceBox::new(&lb_some_result).unwrap(); are not working.