pub struct Kernel<'a> { /* private fields */ }
Expand description

A kernel that can be executed.

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::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();
}

Actually run the kernel.

Panics

Panics if the wrong number of arguments was provided.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.