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
impl Kernel
sourcepub fn new(kernel: cl_kernel) -> Kernel
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.
sourcepub fn create(program: &Program, name: &str) -> Result<Kernel>
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.
sourcepub unsafe fn set_arg<T>(&self, arg_index: cl_uint, arg: &T) -> Result<()>
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.
sourcepub unsafe fn set_arg_local_buffer(
&self,
arg_index: cl_uint,
size: size_t
) -> Result<()>
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.
sourcepub unsafe fn set_arg_svm_pointer(
&self,
arg_index: cl_uint,
arg_ptr: *const c_void
) -> Result<()>
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.
sourcepub unsafe fn set_exec_info<T>(
&self,
param_name: cl_kernel_exec_info,
param_ptr: *const T
) -> Result<()>
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.
pub fn function_name(&self) -> Result<String>
pub fn num_args(&self) -> Result<cl_uint>
pub fn reference_count(&self) -> Result<cl_uint>
pub fn context(&self) -> Result<cl_context>
pub fn program(&self) -> Result<cl_program>
pub fn attributes(&self) -> Result<String>
sourcepub fn get_data(&self, param_name: cl_kernel_info) -> Result<Vec<u8>>
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.
pub fn get_arg_address_qualifier(&self, arg_indx: cl_uint) -> Result<cl_uint>
pub fn get_arg_access_qualifier(&self, arg_indx: cl_uint) -> Result<cl_uint>
pub fn get_arg_type_qualifier(&self, arg_indx: cl_uint) -> Result<cl_ulong>
pub fn get_arg_type_name(&self, arg_indx: cl_uint) -> Result<String>
pub fn get_arg_name(&self, arg_indx: cl_uint) -> Result<String>
sourcepub fn get_arg_data(
&self,
arg_indx: cl_uint,
param_name: cl_kernel_arg_access_qualifier
) -> Result<Vec<u8>>
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.
pub fn get_work_group_size(&self, device: cl_device_id) -> Result<size_t>
pub fn get_compile_work_group_size( &self, device: cl_device_id ) -> Result<Vec<size_t>>
pub fn get_local_mem_size(&self, device: cl_device_id) -> Result<cl_ulong>
pub fn get_work_group_size_multiple( &self, device: cl_device_id ) -> Result<size_t>
pub fn get_private_mem_size(&self, device: cl_device_id) -> Result<cl_ulong>
sourcepub fn get_work_group_data(
&self,
device: cl_device_id,
param_name: cl_kernel_work_group_info
) -> Result<Vec<u8>>
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.