Struct opencl3::context::Context

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

An OpenCL context object. Implements the Drop trait to call release_context when the object is dropped.

Implementations§

source§

impl Context

source

pub fn get(&self) -> cl_context

Get the underlying OpenCL cl_context.

source

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

Create a Context from a slice of cl_device_ids.

  • devices - a slice 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.

source

pub fn from_device(device: &Device) -> Result<Context>

Create a Context from a Device.

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

source

pub fn from_sub_devices( sub_devices: &[SubDevice], properties: &[cl_context_properties], pfn_notify: Option<unsafe extern "C" fn(_: *const c_char, _: *const c_void, _: size_t, _: *mut c_void)>, user_data: *mut c_void ) -> Result<Context>

Create a Context from a slice of SubDevices.

  • devices - a slice of SubDevices 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.

source

pub fn from_device_type( device_type: cl_device_type, properties: &[cl_context_properties], pfn_notify: Option<unsafe extern "C" fn(_: *const c_char, _: *const c_void, _: size_t, _: *mut c_void)>, user_data: *mut c_void ) -> Result<Context>

Create a Context from a cl_device_type.

  • device_type - the cl_device_type to create a Context for.
  • 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.

source

pub fn get_svm_mem_capability(&self) -> cl_device_svm_capabilities

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

source

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

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

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

source

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

source

pub fn default_device(&self) -> cl_device_id

source

pub fn num_devices(&self) -> cl_uint

source

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

source

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

source

pub fn get_data(&self, param_name: cl_context_info) -> Result<Vec<u8>>

Get data about an OpenCL context. Calls clGetContextInfo to get the desired data about the context.

Trait Implementations§

source§

impl Debug for Context

source§

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

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

impl Drop for Context

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<Context> for cl_context

source§

fn from(value: Context) -> Self

Converts to this type from the input type.
source§

impl Send for Context

source§

impl Sync for Context

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.