Struct opencl3::kernel::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 fn new(kernel: cl_kernel) -> Kernel

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 fn get(&self) -> cl_kernel

Get the underlying OpenCL cl_kernel.

source

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

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.

Trait Implementations§

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