pub struct Kernel<'a> {
pub builder: ExecuteKernel<'a>,
/* private fields */
}Expand description
A kernel that can be executed.
Fields§
§builder: ExecuteKernel<'a>The underlying kernel builder.
Implementations§
Source§impl<'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::opencl::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> Freeze for Kernel<'a>
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> UnsafeUnpin for Kernel<'a>
impl<'a> UnwindSafe for Kernel<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more