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
impl Program
sourcepub fn get(&self) -> cl_program
pub fn get(&self) -> cl_program
Get the underlying OpenCL cl_program.
sourcepub fn kernel_names(&self) -> &str
pub fn kernel_names(&self) -> &str
Get the names of the OpenCL kernels in the Program, in a string separated by semicolons.
sourcepub fn create_from_sources(
context: &Context,
sources: &[&str]
) -> Result<Program>
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.
sourcepub fn create_from_source(context: &Context, src: &str) -> Result<Program>
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.
sourcepub unsafe fn create_from_binary(
context: &Context,
devices: &[cl_device_id],
binaries: &[&[u8]]
) -> Result<Program>
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.
sourcepub unsafe fn create_from_builtin_kernels(
context: &Context,
devices: &[cl_device_id],
kernel_names: &str
) -> Result<Program>
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.
sourcepub fn build(&mut self, devices: &[cl_device_id], options: &str) -> Result<()>
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.
sourcepub fn create_and_build_from_sources(
context: &Context,
sources: &[&str],
options: &str
) -> Result<Program, String>
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.
sourcepub fn create_and_build_from_source(
context: &Context,
src: &str,
options: &str
) -> Result<Program, String>
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.
sourcepub fn create_and_build_from_binary(
context: &Context,
binaries: &[&[u8]],
options: &str
) -> Result<Program>
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.
sourcepub fn compile(
&mut self,
devices: &[cl_device_id],
options: &str,
input_headers: &[cl_program],
header_include_names: &[&CStr]
) -> Result<()>
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.
sourcepub unsafe fn link(
&mut self,
devices: &[cl_device_id],
options: &str,
input_programs: &[cl_program]
) -> Result<()>
pub unsafe fn link( &mut self, devices: &[cl_device_id], options: &str, input_programs: &[cl_program] ) -> Result<()>
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.
pub fn get_reference_count(&self) -> Result<cl_uint>
pub fn get_context(&self) -> Result<cl_context>
pub fn get_num_devices(&self) -> Result<cl_uint>
pub fn get_devices(&self) -> Result<Vec<intptr_t>>
pub fn get_source(&self) -> Result<String>
pub fn get_binary_sizes(&self) -> Result<Vec<size_t>>
pub fn get_binaries(&self) -> Result<Vec<Vec<cl_uchar>>>
pub fn get_num_kernels(&self) -> Result<size_t>
pub fn get_kernel_names(&self) -> Result<String>
sourcepub fn get_program_il(&self) -> Result<String>
pub fn get_program_il(&self) -> Result<String>
CL_VERSION_2_1
sourcepub fn get_program_scope_global_ctors_present(&self) -> Result<bool>
pub fn get_program_scope_global_ctors_present(&self) -> Result<bool>
CL_VERSION_2_2
sourcepub fn get_program_scope_global_dtors_present(&self) -> Result<bool>
pub fn get_program_scope_global_dtors_present(&self) -> Result<bool>
CL_VERSION_2_2
pub fn get_build_status(&self, device: cl_device_id) -> Result<cl_int>
pub fn get_build_options(&self, device: cl_device_id) -> Result<String>
pub fn get_build_log(&self, device: cl_device_id) -> Result<String>
pub fn get_build_binary_type(&self, device: cl_device_id) -> Result<cl_uint>
sourcepub fn get_build_global_variable_total_size(
&self,
device: cl_device_id
) -> Result<size_t>
pub fn get_build_global_variable_total_size( &self, device: cl_device_id ) -> Result<size_t>
CL_VERSION_2_0