Skip to main content

Kernel

Struct Kernel 

Source
pub struct Kernel { /* private fields */ }
Expand description

An OpenCL kernel object.
Implements the Drop trait to call release_kernel when the object is dropped.

Implementations§

Source§

impl Kernel

Source

pub const fn new(kernel: cl_kernel) -> Self

Create a Kernel from an OpenCL cl_kernel.

  • kernel - a valid OpenCL cl_kernel.

returns a Result containing the new Kernel or the error code from the OpenCL C API function to get the number of kernel arguments.

Source

pub const fn get(&self) -> cl_kernel

Get the underlying OpenCL cl_kernel.

Source

pub fn create(program: &Program, name: &str) -> Result<Self>

Create a Kernel from an OpenCL Program.

  • program - a built OpenCL Program.
  • name - the name of the OpenCL kernel.

returns a Result containing the new Kernel or the error code from the OpenCL C API function to get the number of kernel arguments.

Source

pub unsafe fn set_arg<T>(&self, arg_index: cl_uint, arg: &T) -> Result<()>

Set the argument value for a specific argument of a kernel.

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

returns an empty Result or the error code from the OpenCL C API function.

§Safety

This function is unsafe because the index, size and value must be valid.

Source

pub unsafe fn set_arg_local_buffer( &self, arg_index: cl_uint, size: size_t, ) -> Result<()>

Create a local memory buffer for a specific argument of a kernel.

  • arg_index - the kernel argument index.
  • size - the size of the local memory buffer in bytes.

returns an empty Result or the error code from the OpenCL C API function.

§Safety

This function is unsafe because the index and size must be valid.

Source

pub unsafe fn set_arg_svm_pointer( &self, arg_index: cl_uint, arg_ptr: *const c_void, ) -> Result<()>

Set set a SVM pointer as the argument value for a specific argument of a kernel.

  • arg_index - the kernel argument index.
  • arg_ptr - the SVM pointer to the data for the argument at arg_index.

returns an empty Result or the error code from the OpenCL C API function.

§Safety

This function is unsafe because the index and ptr must be valid.

Source

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

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 an empty Result or the error code from the OpenCL C API function.

§Safety

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

Source

pub fn function_name(&self) -> Result<String>

Source

pub fn num_args(&self) -> Result<cl_uint>

Source

pub fn reference_count(&self) -> Result<cl_uint>

Source

pub fn context(&self) -> Result<cl_context>

Source

pub fn program(&self) -> Result<cl_program>

Source

pub fn attributes(&self) -> Result<String>

Source

pub fn get_data(&self, param_name: cl_kernel_info) -> Result<Vec<u8>>

Get data about an OpenCL kernel. Calls clGetKernelInfo to get the desired data about the kernel.

Source

pub fn get_arg_address_qualifier(&self, arg_indx: cl_uint) -> Result<cl_uint>

Source

pub fn get_arg_access_qualifier(&self, arg_indx: cl_uint) -> Result<cl_uint>

Source

pub fn get_arg_type_qualifier(&self, arg_indx: cl_uint) -> Result<cl_ulong>

Source

pub fn get_arg_type_name(&self, arg_indx: cl_uint) -> Result<String>

Source

pub fn get_arg_name(&self, arg_indx: cl_uint) -> Result<String>

Source

pub fn get_arg_data( &self, arg_indx: cl_uint, param_name: cl_kernel_arg_access_qualifier, ) -> Result<Vec<u8>>

Get data about arguments of an OpenCL kernel. Calls clGetKernelArgInfo to get the desired data about arguments of the kernel.

Source

pub fn get_work_group_size(&self, device: cl_device_id) -> Result<size_t>

Source

pub fn get_compile_work_group_size( &self, device: cl_device_id, ) -> Result<Vec<size_t>>

Source

pub fn get_local_mem_size(&self, device: cl_device_id) -> Result<cl_ulong>

Source

pub fn get_work_group_size_multiple( &self, device: cl_device_id, ) -> Result<size_t>

Source

pub fn get_private_mem_size(&self, device: cl_device_id) -> Result<cl_ulong>

Source

pub fn get_work_group_data( &self, device: cl_device_id, param_name: cl_kernel_work_group_info, ) -> Result<Vec<u8>>

Get data about work groups of an OpenCL kernel. Calls clGetKernelArgInfo to get the desired data about work groups of the kernel.

Source

pub fn get_kernel_sub_group_info_khr( &self, device: cl_device_id, param_name: cl_kernel_sub_group_info, input_values: &[size_t], ) -> Result<size_t>

Source

pub fn get_kernel_suggested_local_work_size_khr( &self, command_queue: cl_command_queue, work_dim: cl_uint, global_work_offset: *const size_t, global_work_size: *const size_t, ) -> Result<size_t>

Trait Implementations§

Source§

impl Clone for Kernel

Available on crate features CL_VERSION_2_1 or dynamic only.
Source§

fn clone(&self) -> Self

Clone an OpenCL kernel object.
CL_VERSION_2_1 see: Copying Kernel Objects

returns a Result containing the new Kernel or the error code from the OpenCL C API function.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Kernel

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Kernel

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<Kernel> for cl_kernel

Source§

fn from(value: Kernel) -> Self

Converts to this type from the input type.
Source§

impl Send for Kernel

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.