pub enum DeviceSpecifier {
    All,
    First,
    Single(Device),
    List(Vec<Device>),
    Indices(Vec<usize>),
    WrappingIndices(Vec<usize>),
    TypeFlags(DeviceType),
}
Expand description

Specifies [what boils down to] a list of devices.

The Indices variant is context-specific, not robust, and may lead to a panic if the context changes. It is useful for convenience only and not recommended for general use. The WrappingIndices variant is somewhat less dangerous but can still be somewhat machine-specific.

The TypeFlags variant is used for specifying a list of devices using a bitfield (DeviceType) and is the most robust / portable.

[FIXME: Add some links to the SDK]

Variants§

§

All

§

First

§

Single(Device)

§

List(Vec<Device>)

§

Indices(Vec<usize>)

§

WrappingIndices(Vec<usize>)

§

TypeFlags(DeviceType)

Implementations§

source§

impl DeviceSpecifier

source

pub fn all(self) -> DeviceSpecifier

Returns a DeviceSpecifier::All variant which specifies all devices on a platform.

source

pub fn first(self) -> DeviceSpecifier

Returns a DeviceSpecifier::First variant which specifies only the first device on a platform.

source

pub fn single(self, device: Device) -> DeviceSpecifier

Returns a DeviceSpecifier::Single variant which specifies a single device.

source

pub fn list(self, list: Vec<Device>) -> DeviceSpecifier

Returns a DeviceSpecifier::List variant which specifies a list of devices.

source

pub unsafe fn indices(self, indices: Vec<usize>) -> DeviceSpecifier

Returns a DeviceSpecifier::Indices variant which specifies a list of devices by index.

§Safety

This variant is context-specific, not robust, and may lead to a panic if the context changes. It is useful for convenience only and not recommended for general use.

Though using the Indices variant is not strictly unsafe in the usual way (will not lead to memory bugs, etc.), it is marked unsafe as a warning. Recommendations for a more idiomatic way to express this potential footgun are welcome.

Using ::wrapping_indices is a more robust (but still potentially non-portable) solution.

source

pub fn wrapping_indices(self, windices: Vec<usize>) -> DeviceSpecifier

Returns a DeviceSpecifier::WrappingIndices variant, specifying a list of devices by indices which are wrapped around (simply using the modulo operator) so that every index is always valid.

source

pub fn type_flags(self, flags: DeviceType) -> DeviceSpecifier

Returns a DeviceSpecifier::TypeFlags variant which specifies a list of devices using a conventional bitfield.

source

pub fn to_device_list<P: Borrow<Platform>>( &self, platform: Option<P> ) -> OclResult<Vec<Device>>

Returns the list of devices matching the parameters specified by this DeviceSpecifier

§Panics

Any device indices listed within the Indices variant must be within the range of the number of devices for the platform specified by Platform. If no platform has been specified, this behaviour is undefined and could end up using any platform at all.

Trait Implementations§

source§

impl Clone for DeviceSpecifier

source§

fn clone(&self) -> DeviceSpecifier

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 DeviceSpecifier

source§

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

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

impl Default for DeviceSpecifier

source§

fn default() -> DeviceSpecifier

Returns the “default value” for a type. Read more
source§

impl<'a> From<&'a [Device]> for DeviceSpecifier

source§

fn from(devices: &'a [Device]) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl<'a> From<&'a [usize]> for DeviceSpecifier

source§

fn from(indices: &'a [usize]) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl<'a> From<&'a Device> for DeviceSpecifier

source§

fn from(device: &'a Device) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl<'a> From<&'a DeviceId> for DeviceSpecifier

source§

fn from(device: &'a DeviceIdCore) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<Device>> for DeviceSpecifier

source§

fn from(devices: &'a Vec<Device>) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<usize>> for DeviceSpecifier

source§

fn from(indices: &'a Vec<usize>) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl From<Device> for DeviceSpecifier

source§

fn from(device: Device) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl From<DeviceId> for DeviceSpecifier

source§

fn from(device: DeviceIdCore) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl From<DeviceType> for DeviceSpecifier

source§

fn from(flags: DeviceType) -> DeviceSpecifier

Converts to this type from the input type.
source§

impl From<usize> for DeviceSpecifier

source§

fn from(index: usize) -> DeviceSpecifier

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