Struct rust_gpu_tools::cuda::Kernel
source · [−]pub struct Kernel<'a> { /* private fields */ }
Expand description
A kernel that can be executed.
Implementations
sourceimpl<'a> Kernel<'a>
impl<'a> Kernel<'a>
sourcepub fn arg<T: KernelArgument>(self, t: &'a T) -> Self
pub fn arg<T: KernelArgument>(self, t: &'a T) -> Self
Set a kernel argument.
The arguments must live as long as the kernel. Hence make sure they are not dropped as long as the kernel is in use.
Example where this behaviour is enforced and leads to a compile-time error:
ⓘ
use rust_gpu_tools::cuda::Program;
fn would_break(program: &Program) {
let data = vec![1, 2, 3, 4];
let buffer = program.create_buffer_from_slice(&data).unwrap();
let kernel = program.create_kernel("my_kernel", 4, 256).unwrap();
let kernel = kernel.arg(&buffer);
// This drop wouldn't error if the arguments wouldn't be bound to the kernels lifetime.
drop(buffer);
kernel.run().unwrap();
}
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Kernel<'a>
impl<'a> !Send for Kernel<'a>
impl<'a> !Sync for Kernel<'a>
impl<'a> Unpin for Kernel<'a>
impl<'a> !UnwindSafe for Kernel<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more