Struct opencl3::program::Program

source ·
pub struct Program { /* private fields */ }
Expand description

An OpenCL program object.
Stores the names of the OpenCL kernels in the program. Implements the Drop trait to call release_program when the object is dropped.

Implementations§

source§

impl Program

source

pub fn get(&self) -> cl_program

Get the underlying OpenCL cl_program.

source

pub fn kernel_names(&self) -> &str

Get the names of the OpenCL kernels in the Program, in a string separated by semicolons.

source

pub fn create_from_sources( context: &Context, sources: &[&str] ) -> Result<Program>

Create a Program for a context and load source code into that object.

  • context - a valid OpenCL context.
  • sources - an array of strs containing the source code strings.

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

source

pub fn create_from_source(context: &Context, src: &str) -> Result<Program>

Create a Program for a context and load a source code string into that object.

  • context - a valid OpenCL context.
  • src - a str containing a source code string.

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

source

pub unsafe fn create_from_binary( context: &Context, devices: &[cl_device_id], binaries: &[&[u8]] ) -> Result<Program>

Create a Program for a context and load binary bits into that object.

  • context - a valid OpenCL context.
  • devices - a slice of devices that are in context.
  • binaries - a slice of program binaries slices.

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

Safety

This is unsafe when a device is not a member of context.

source

pub unsafe fn create_from_builtin_kernels( context: &Context, devices: &[cl_device_id], kernel_names: &str ) -> Result<Program>

Create a Program for a context and loads the information related to the built-in kernels into that object.

  • context - a valid OpenCL context.
  • devices - a slice of devices that are in context.
  • kernel_names - a semi-colon separated list of built-in kernel names.

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

Safety

This is unsafe when a device is not a member of context.

source

pub fn build(&mut self, devices: &[cl_device_id], options: &str) -> Result<()>

Build (compile & link) a Program.

  • devices - a slice of devices that are in context.
  • options - the build options in a null-terminated string.
  • pfn_notify - an optional function pointer to a notification routine.
  • user_data - passed as an argument when pfn_notify is called, or ptr::null_mut().

returns a null Result or the error code from the OpenCL C API function.

source

pub fn create_and_build_from_sources( context: &Context, sources: &[&str], options: &str ) -> Result<Program, String>

Create and build an OpenCL Program from an array of source code strings with the given options.

  • context - a valid OpenCL context.
  • sources - an array of strs containing the source code strings.
  • options - the build options in a null-terminated string.

returns a Result containing the new Program, the name of the error code from the OpenCL C API function or the build log, if the build failed.

source

pub fn create_and_build_from_source( context: &Context, src: &str, options: &str ) -> Result<Program, String>

Create and build an OpenCL Program from source code with the given options.

  • context - a valid OpenCL context.
  • src - a str containing a source code string.
  • options - the build options in a null-terminated string.

returns a Result containing the new Program, the name of the error code from the OpenCL C API function or the build log, if the build failed.

source

pub fn create_and_build_from_binary( context: &Context, binaries: &[&[u8]], options: &str ) -> Result<Program>

Create and build an OpenCL Program from binaries with the given options.

  • context - a valid OpenCL context.
  • binaries - a slice of program binaries slices.
  • options - the build options in a null-terminated string.

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

source

pub fn compile( &mut self, devices: &[cl_device_id], options: &str, input_headers: &[cl_program], header_include_names: &[&CStr] ) -> Result<()>

Compile a program’s source for the devices the OpenCL context associated with the program.

  • devices - a slice of devices that are in context.
  • options - the compilation options in a null-terminated string.
  • input_headers - a slice of programs that describe headers in the input_headers.
  • header_include_names - an array that has a one to one correspondence with input_headers.

returns a null Result or the error code from the OpenCL C API function.

Link a set of compiled program objects and libraries for the devices in the OpenCL context associated with the program.

  • devices - a slice of devices that are in context.
  • options - the link options in a null-terminated string.
  • input_programs - a slice of programs that describe headers in the input_headers.

returns a null Result or the error code from the OpenCL C API function.

Safety

This is unsafe when a device is not a member of context.

source

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

source

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

source

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

source

pub fn get_devices(&self) -> Result<Vec<intptr_t>>

source

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

source

pub fn get_binary_sizes(&self) -> Result<Vec<size_t>>

source

pub fn get_binaries(&self) -> Result<Vec<Vec<cl_uchar>>>

source

pub fn get_num_kernels(&self) -> Result<size_t>

source

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

source

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

CL_VERSION_2_1

source

pub fn get_program_scope_global_ctors_present(&self) -> Result<bool>

CL_VERSION_2_2

source

pub fn get_program_scope_global_dtors_present(&self) -> Result<bool>

CL_VERSION_2_2

source

pub fn get_build_status(&self, device: cl_device_id) -> Result<cl_int>

source

pub fn get_build_options(&self, device: cl_device_id) -> Result<String>

source

pub fn get_build_log(&self, device: cl_device_id) -> Result<String>

source

pub fn get_build_binary_type(&self, device: cl_device_id) -> Result<cl_uint>

source

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

CL_VERSION_2_0

Trait Implementations§

source§

impl Debug for Program

source§

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

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

impl Drop for Program

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<Program> for cl_program

source§

fn from(value: Program) -> Self

Converts to this type from the input type.
source§

impl Send for Program

source§

impl Sync for Program

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.