[][src]Struct opencl3::context::Context

pub struct Context { /* fields omitted */ }

An OpenCL context.
A Context manages OpenCL objects that are constructed from it, i.e.:

It implements the Drop trait which clears the collections of OpenCL objects so that they are released when the Context goes out of scope.

Implementations

impl Context[src]

pub fn get(&self) -> cl_context[src]

Get the underlying OpenCL cl_context.

pub fn from_devices(
    devices: Vec<cl_device_id>,
    properties: *const cl_context_properties,
    pfn_notify: Option<extern "C" fn(_: *const c_char, _: *const c_void, _: size_t, _: *mut c_void)>,
    user_data: *mut c_void
) -> Result<Context, cl_int>
[src]

Create a Context from a vector of cl_device_ids.
Note: the vector of cl_device_ids are moved into Context

  • devices - a vector of cl_device_ids for an OpenCL Platform.
  • properties - a null terminated list of cl_context_properties, see Context Properties.
  • pfn_notify - an optional callback function that can be registered by the application.
  • user_data - passed as the user_data argument when pfn_notify is called.

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

pub fn from_device(device: Device) -> Result<Context, cl_int>[src]

Create a Context from a Device.

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

pub fn add_command_queue(&mut self, queue: CommandQueue)[src]

Add a CommandQueue to the Context for it to manage.

  • queue - a command queue on one of the devices or sub-devices managed by the Context.

pub fn create_command_queues(
    &mut self,
    properties: cl_command_queue_properties
) -> Result<(), cl_int>
[src]

Create a CommandQueue for every device and append them to the queues managed by this context.
Deprecated in CL_VERSION_2_0 by create_command_queue_with_properties.

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

pub fn create_command_queues_with_properties(
    &mut self,
    properties: cl_command_queue_properties,
    queue_size: cl_uint
) -> Result<(), cl_int>
[src]

Create a CommandQueue for every device and append them to the queues managed by this context.
CL_VERSION_2_0 onwards.

  • properties - a null terminated list of properties for the command-queue, see cl_queue_properties.

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

pub fn add_program(&mut self, program: Program) -> Result<usize, cl_int>[src]

Add a built Program to the Context for it to manage.
It also creates and manages the Kernels in the program.

  • program - a Program to be managed by the Context.

returns a Result containing the number of kernels in the Program. or the error code from the OpenCL C API function.

pub fn build_program_from_source(
    &mut self,
    src: &CStr,
    options: &CStr
) -> Result<usize, cl_int>
[src]

Create and build a Program from source code.
It also creates and manages the Kernels in the program.

  • src - a CStr containing the source code character string.
  • options - the build options in a null-terminated string.

returns a Result containing the number of kernels in the Program. or the error code from the OpenCL C API function.

pub fn build_program_from_binary(
    &mut self,
    binaries: &[&[u8]],
    options: &CStr
) -> Result<usize, cl_int>
[src]

Create and build a Program from binaries.
It also creates and manages the Kernels in the program.

  • src - a CStr containing the source code character string.
  • binaries - a slice of program binaries slices.
  • options - the build options in a null-terminated string.

returns a Result containing the number of kernels in the Program. or the error code from the OpenCL C API function.

pub fn create_sub_devices(
    &mut self,
    device: cl_device_id,
    properties: &[cl_device_partition_property]
) -> Result<usize, cl_int>
[src]

Create sub-devices from a device. Stores the sub-devices in the sub_devices vector.

  • device - the cl_device_id.
  • properties - the slice of cl_device_partition_property, see Subdevice Partition.

returns a Result containing the number of sub-devices created or the error code from the OpenCL C API function.

pub fn get_kernel(&self, kernel_name: &CStr) -> Option<&Kernel>[src]

Get the kernel with the given name.

  • kernel_name - the name of the Kernel

returns an Option containing a reference to the Kernel on None.

pub fn get_svm_mem_capability(&self) -> cl_device_svm_capabilities[src]

Get the common Shared Virtual Memory (SVM) capabilities of the devices in the Context.

pub fn get_supported_image_formats(
    &self,
    flags: cl_mem_flags,
    image_type: cl_mem_object_type
) -> Result<Vec<cl_image_format>, cl_int>
[src]

Get the list of image formats supported by the Context for an image type, and allocation information.
Calls clGetSupportedImageFormats to get the desired information about the program.

  • flags - a bit-field used to specify allocation and usage information about the image memory object being created, see: Memory Flags.
  • image_type - describes the image type.

returns a Result containing the desired information in an InfoType enum or the error code from the OpenCL C API function.

pub fn devices(&self) -> &[cl_device_id]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

pub fn sub_devices(&self) -> &[SubDevice]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

pub fn queues(&self) -> &[CommandQueue]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

pub fn default_queue(&self) -> &CommandQueue[src]

pub fn programs(&self) -> &[Program]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

pub fn kernels(&self) -> &HashMap<CString, Kernel>[src]

pub fn reference_count(&self) -> Result<cl_uint, cl_int>[src]

pub fn properties(&self) -> Result<Vec<intptr_t>, cl_int>[src]

Trait Implementations

impl Drop for Context[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.