Enum ocl::builders::DeviceSpecifier
source · 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
impl DeviceSpecifier
sourcepub fn all(self) -> DeviceSpecifier
pub fn all(self) -> DeviceSpecifier
Returns a DeviceSpecifier::All
variant which specifies all
devices on a platform.
sourcepub fn first(self) -> DeviceSpecifier
pub fn first(self) -> DeviceSpecifier
Returns a DeviceSpecifier::First
variant which specifies only
the first device on a platform.
sourcepub fn single(self, device: Device) -> DeviceSpecifier
pub fn single(self, device: Device) -> DeviceSpecifier
Returns a DeviceSpecifier::Single
variant which specifies a single
device.
sourcepub fn list(self, list: Vec<Device>) -> DeviceSpecifier
pub fn list(self, list: Vec<Device>) -> DeviceSpecifier
Returns a DeviceSpecifier::List
variant which specifies a list of
devices.
sourcepub unsafe fn indices(self, indices: Vec<usize>) -> DeviceSpecifier
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.
sourcepub fn wrapping_indices(self, windices: Vec<usize>) -> DeviceSpecifier
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.
sourcepub fn type_flags(self, flags: DeviceType) -> DeviceSpecifier
pub fn type_flags(self, flags: DeviceType) -> DeviceSpecifier
Returns a DeviceSpecifier::TypeFlags
variant which specifies a list
of devices using a conventional bitfield.
sourcepub fn to_device_list<P: Borrow<Platform>>(
&self,
platform: Option<P>
) -> OclResult<Vec<Device>>
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
impl Clone for DeviceSpecifier
source§fn clone(&self) -> DeviceSpecifier
fn clone(&self) -> DeviceSpecifier
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more