Struct opencl3::kernel::ExecuteKernel

source ·
pub struct ExecuteKernel<'a> {
    pub kernel: &'a Kernel,
    pub num_args: cl_uint,
    pub global_work_offsets: Vec<size_t>,
    pub global_work_sizes: Vec<size_t>,
    pub local_work_sizes: Vec<size_t>,
    pub event_wait_list: Vec<cl_event>,
    /* private fields */
}
Expand description

A struct that implements the builder pattern to simplify setting up Kernel arguments and the NDRange when enqueueing a Kernel on a CommandQueue.

Fields§

§kernel: &'a Kernel§num_args: cl_uint§global_work_offsets: Vec<size_t>§global_work_sizes: Vec<size_t>§local_work_sizes: Vec<size_t>§event_wait_list: Vec<cl_event>

Implementations§

source§

impl<'a> ExecuteKernel<'a>

source

pub fn new(kernel: &'a Kernel) -> ExecuteKernel<'_>

source

pub unsafe fn set_arg<'b, T>(&'b mut self, arg: &T) -> &'b mut Self

Set the next argument of the kernel.
Calls self.kernel.set_arg to set the next unset kernel argument.

§Panics

Panics if too many arguments have been set or the argument is invalid.

  • arg - a reference to the data for the kernel argument.

returns a reference to self.

§Safety

This function is unsafe because arg must be valid.

source

pub unsafe fn set_arg_local_buffer(&mut self, size: size_t) -> &mut Self

Set the next argument of the kernel as a local buffer Calls self.kernel.set_arg_local_buffer to set the next unset kernel argument.

§Panics

Panics if too many arguments have been set or the argument is invalid.

  • size - the size of the local memory buffer in bytes.

returns a reference to self.

§Safety

This function is unsafe because size must be valid.

source

pub unsafe fn set_arg_svm<T>(&mut self, arg_ptr: *const T) -> &mut Self

Set the next argument of the kernel.
Calls self.kernel.set_arg to set the next unset kernel argument.

§Panics

Panics if too many arguments have been set or the argument is invalid.

  • arg - a reference to the data for the kernel argument.

returns a reference to self.

§Safety

This function is unsafe because ptr must be valid.

source

pub unsafe fn set_exec_info<T>( &mut self, param_name: cl_kernel_exec_info, param_ptr: *const T ) -> &mut Self

Pass additional information other than argument values to a kernel.

  • param_name - the information to be passed to kernel, see: Kernel Execution Properties.
  • param_ptr - pointer to the data for the param_name.

returns a reference to self.

§Safety

This function is unsafe because name and ptr must be valid.

source

pub fn set_global_work_offset(&mut self, size: size_t) -> &mut Self

Set a global work offset for a call to clEnqueueNDRangeKernel.

  • size - the size of the global work offset.

returns a reference to self.

source

pub fn set_global_work_offsets(&mut self, sizes: &[size_t]) -> &mut Self

Set the global work offsets for a call to clEnqueueNDRangeKernel.

§Panics

Panics if global_work_offsets is already set.

  • sizes - the sizes of the global work offset.

returns a reference to self.

source

pub fn set_global_work_size(&mut self, size: size_t) -> &mut Self

Set a global work size for a call to clEnqueueNDRangeKernel.

  • size - the size of the global work size.

returns a reference to self.

source

pub fn set_global_work_sizes<'b>(&'b mut self, sizes: &[size_t]) -> &'b mut Self

Set the global work sizes for a call to clEnqueueNDRangeKernel.

§Panics

Panics if global_work_sizes is already set.

  • sizes - the sizes of the global work sizes.

returns a reference to self.

source

pub fn set_local_work_size(&mut self, size: size_t) -> &mut Self

Set a local work size for a call to clEnqueueNDRangeKernel.

  • size - the size of the local work size.

returns a reference to self.

source

pub fn set_local_work_sizes<'b>(&'b mut self, sizes: &[size_t]) -> &'b mut Self

Set the local work sizes for a call to clEnqueueNDRangeKernel.

§Panics

Panics if local_work_sizes is already set.

  • sizes - the sizes of the local work sizes.

returns a reference to self.

source

pub fn set_wait_event<'b>(&'b mut self, event: &Event) -> &'b mut Self

Set an event for the event_wait_list in a call to clEnqueueNDRangeKernel.

  • event - the Event to add to the event_wait_list.

returns a reference to self.

source

pub fn set_event_wait_list<'b>( &'b mut self, events: &[cl_event] ) -> &'b mut Self

Set the event_wait_list in a call to clEnqueueNDRangeKernel.

§Panics

Panics if event_wait_list is already set.

  • events - the cl_events in the call to clEnqueueNDRangeKernel.

returns a reference to self.

source

pub unsafe fn enqueue_nd_range(&mut self, queue: &CommandQueue) -> Result<Event>

Calls clEnqueueNDRangeKernel on the given with CommandQueue with the global and local work sizes and the global work offsets together with an events wait list.

§Panics

Panics if:

  • too few kernel arguments have been set

  • no global_work_sizes have been set

  • too many global_work_sizes have been set

  • global_work_offsets have been set and their dimensions do not match global_work_sizes

  • local_work_sizes have been set and their dimensions do not match global_work_sizes

  • queue - the CommandQueue to enqueue the Kernel on.

return the Event for this command or the error code from the OpenCL C API function.

§Safety

This is unsafe when the kernel arguments have not been set up correctly.

Trait Implementations§

source§

impl<'a> Debug for ExecuteKernel<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ExecuteKernel<'a>

§

impl<'a> RefUnwindSafe for ExecuteKernel<'a>

§

impl<'a> !Send for ExecuteKernel<'a>

§

impl<'a> !Sync for ExecuteKernel<'a>

§

impl<'a> Unpin for ExecuteKernel<'a>

§

impl<'a> UnwindSafe for ExecuteKernel<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.