Struct ocl::Context

source ·
pub struct Context(/* private fields */);
Expand description

A context for a particular platform and set of device types.

Thread safety and destruction for any enclosed pointers are all handled automatically. Clone, store, and share between threads to your heart’s content.

Implementations§

source§

impl Context

source

pub fn builder() -> ContextBuilder

Returns a ContextBuilder.

This is the preferred way to create a Context.

source

pub fn new( properties: Option<ContextProperties>, device_spec: Option<DeviceSpecifier>, pfn_notify: Option<CreateContextCallbackFn>, user_data: Option<UserDataPtr> ) -> OclResult<Context>

Returns a newly created context.

Prefer Context::builder()... instead of this method unless you know what you’re doing. Please also immediately contact us if you do, in fact, know what you’re doing so that you can be added to the development team as the one who does.

§Defaults
  • The ‘NULL’ platform (which is not to be relied on but is generally the first avaliable).
  • All devices associated with the ‘NULL’ platform
  • No notify callback function or user data.

Don’t rely on these defaults, instead rely on the ContextBuilder defaults. In other words, use: Context::builder().build().unwrap() rather than Context::new(None, None, None, None).unwrap().

§Panics

[TEMPORARY] Passing a Some variant for pfn_notify or user_data is not yet supported. File an issue if you need this.

source

pub fn resolve_wrapping_device_idxs(&self, idxs: &[usize]) -> Vec<Device>

Resolves a list of zero-based device indices into a list of Devices.

If any index is out of bounds it will wrap around zero (%) to the next valid device index.

source

pub fn get_device_by_wrapping_index(&self, index: usize) -> Device

Returns a device by its ordinal count within this context.

Round-robins (%) to the next valid device.

source

pub fn platform_info( &self, info_kind: PlatformInfo ) -> OclResult<PlatformInfoResult>

Returns info about the platform associated with the context.

source

pub fn device_info( &self, index: usize, info_kind: DeviceInfo ) -> OclResult<DeviceInfoResult>

Returns info about the device indexed by index associated with this context.

source

pub fn info(&self, info_kind: ContextInfo) -> OclResult<ContextInfoResult>

Returns info about the context.

source

pub fn as_core(&self) -> &ContextCore

Returns a reference to the core pointer wrapper, usable by functions in the core module.

source

pub fn devices(&self) -> Vec<Device>

Returns the list of devices associated with this context.

Panics upon any OpenCL error.

source

pub fn device_versions(&self) -> OclResult<Vec<OpenclVersion>>

Returns the list of device versions associated with this context.

source

pub fn platform(&self) -> OclResult<Option<Platform>>

Returns the platform this context is associated with.

Methods from Deref<Target = ContextCore>§

source

pub fn as_ptr(&self) -> *mut c_void

Returns a pointer, do not store it.

source

pub fn devices(&self) -> Result<Vec<DeviceId>, Error>

Returns the devices associated with this context.

source

pub fn platform(&self) -> Result<Option<PlatformId>, Error>

Returns the platform associated with this context, if any.

Errors upon the usual OpenCL errors.

Returns None if the context properties do not specify a platform.

Trait Implementations§

source§

impl<'a> ClContextPtr for &'a Context

source§

impl<'a> ClVersions for &'a Context

source§

impl ClVersions for Context

source§

impl Clone for Context

source§

fn clone(&self) -> Context

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Context

source§

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

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

impl Deref for Context

§

type Target = Context

The resulting type after dereferencing.
source§

fn deref(&self) -> &ContextCore

Dereferences the value.
source§

impl DerefMut for Context

source§

fn deref_mut(&mut self) -> &mut ContextCore

Mutably dereferences the value.
source§

impl Display for Context

source§

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

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

impl From<Context> for Context

source§

fn from(c: ContextCore) -> Context

Converts to this type from the input type.

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.