Struct rust_gpu_tools::opencl::Kernel [−][src]
pub struct Kernel<'a> {
pub builder: ExecuteKernel<'a>,
// some fields omitted
}
Expand description
A kernel that can be executed.
Fields
builder: ExecuteKernel<'a>
The underlying kernel builder.
Implementations
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();
}