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>
impl<'a> ExecuteKernel<'a>
pub fn new(kernel: &'a Kernel) -> ExecuteKernel<'_>
sourcepub unsafe fn set_arg<'b, T>(&'b mut self, arg: &T) -> &'b mut Self
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.
sourcepub unsafe fn set_arg_local_buffer(&mut self, size: size_t) -> &mut Self
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.
sourcepub unsafe fn set_arg_svm<T>(&mut self, arg_ptr: *const T) -> &mut Self
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.
sourcepub unsafe fn set_exec_info<T>(
&mut self,
param_name: cl_kernel_exec_info,
param_ptr: *const T
) -> &mut Self
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.
sourcepub fn set_global_work_offset(&mut self, size: size_t) -> &mut Self
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.
sourcepub fn set_global_work_offsets(&mut self, sizes: &[size_t]) -> &mut Self
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.
sourcepub fn set_global_work_size(&mut self, size: size_t) -> &mut Self
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.
sourcepub fn set_global_work_sizes<'b>(&'b mut self, sizes: &[size_t]) -> &'b mut Self
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.
sourcepub fn set_local_work_size(&mut self, size: size_t) -> &mut Self
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.
sourcepub fn set_local_work_sizes<'b>(&'b mut self, sizes: &[size_t]) -> &'b mut Self
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.
sourcepub fn set_wait_event<'b>(&'b mut self, event: &Event) -> &'b mut Self
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.
sourcepub fn set_event_wait_list<'b>(
&'b mut self,
events: &[cl_event]
) -> &'b mut Self
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.
sourcepub unsafe fn enqueue_nd_range(&mut self, queue: &CommandQueue) -> Result<Event>
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.