Enum ocl::SpatialDims
source · pub enum SpatialDims {
Unspecified,
One(usize),
Two(usize, usize),
Three(usize, usize, usize),
}
Expand description
Specifies a size or offset in up to three dimensions.
Using SpatialDims
to specify dimensions for your application may not be
appropriate. Custom types implementing the traits MemLen
and WorkDims
should be created to express more complex relationships between data shape
and work size for kernels which do not have a 1:1 correspondence between
data set length and global work size.
[FIXME]: Describe the ways a SpatialDims
can be created using various
From
implementations.
[UNSTABLE]: This type and its methods may be renamed or otherwise changed at any time. This is still a work in progress.
Variants§
Implementations§
source§impl SpatialDims
impl SpatialDims
sourcepub fn new(
d0: Option<usize>,
d1: Option<usize>,
d2: Option<usize>
) -> OclResult<SpatialDims>
pub fn new( d0: Option<usize>, d1: Option<usize>, d2: Option<usize> ) -> OclResult<SpatialDims>
Returns a new SpatialDims
.
Dimensions must be specified in order from d0 -> d1 -> d2; i.e. d1
cannot be Some(x)
if d0
is None
.
Explicitly setting all zeros as values is not recommended as it is
invalid to OpenCL functions. Use ::Unspecified
to represent NULL
instead.
sourcepub fn to_lens(&self) -> Result<[usize; 3], UnspecifiedDimensionsError>
pub fn to_lens(&self) -> Result<[usize; 3], UnspecifiedDimensionsError>
Returns a 3D size or an error if unspecified.
sourcepub fn to_offset(&self) -> Result<[usize; 3], UnspecifiedDimensionsError>
pub fn to_offset(&self) -> Result<[usize; 3], UnspecifiedDimensionsError>
Returns a 3D offset or an error if unspecified.
sourcepub fn to_len(&self) -> usize
pub fn to_len(&self) -> usize
Returns the product of all contained dimensional values (equivalent to a length, area, or volume) or zero if unspecified.
Check ::is_unspecified
if it matters whether or not the zero length
has been explicitly set however, explicitly setting all zeros as
dimensions is not recommended as it is an invalid value to OpenCL
functions. Use ::Unspecified
to represent NULL
instead.
sourcepub fn try_to_padded_len(&self, incr: usize) -> OclResult<usize>
pub fn try_to_padded_len(&self, incr: usize) -> OclResult<usize>
Takes the length and rounds it up to the nearest incr
or an error.
sourcepub fn is_unspecified(&self) -> bool
pub fn is_unspecified(&self) -> bool
Returns true
if this SpatialDims
is an Unspecified
variant.
Trait Implementations§
source§impl Clone for SpatialDims
impl Clone for SpatialDims
source§fn clone(&self) -> SpatialDims
fn clone(&self) -> SpatialDims
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SpatialDims
impl Debug for SpatialDims
source§impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 1]> for SpatialDims
impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 1]> for SpatialDims
source§fn from(val: &[T; 1]) -> SpatialDims
fn from(val: &[T; 1]) -> SpatialDims
source§impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 2]> for SpatialDims
impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 2]> for SpatialDims
source§fn from(pair: &[T; 2]) -> SpatialDims
fn from(pair: &[T; 2]) -> SpatialDims
source§impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 3]> for SpatialDims
impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 3]> for SpatialDims
source§fn from(set: &[T; 3]) -> SpatialDims
fn from(set: &[T; 3]) -> SpatialDims
source§impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T,)> for SpatialDims
impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T,)> for SpatialDims
source§fn from(val: &(T,)) -> SpatialDims
fn from(val: &(T,)) -> SpatialDims
source§impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T, T)> for SpatialDims
impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T, T)> for SpatialDims
source§fn from(pair: &(T, T)) -> SpatialDims
fn from(pair: &(T, T)) -> SpatialDims
source§impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T, T, T)> for SpatialDims
impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T, T, T)> for SpatialDims
source§fn from(set: &(T, T, T)) -> SpatialDims
fn from(set: &(T, T, T)) -> SpatialDims
source§impl<'a> From<&'a SpatialDims> for SpatialDims
impl<'a> From<&'a SpatialDims> for SpatialDims
source§fn from(sd: &'a SpatialDims) -> SpatialDims
fn from(sd: &'a SpatialDims) -> SpatialDims
source§impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 1]> for SpatialDims
impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 1]> for SpatialDims
source§fn from(val: [T; 1]) -> SpatialDims
fn from(val: [T; 1]) -> SpatialDims
source§impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 2]> for SpatialDims
impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 2]> for SpatialDims
source§fn from(pair: [T; 2]) -> SpatialDims
fn from(pair: [T; 2]) -> SpatialDims
source§impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 3]> for SpatialDims
impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 3]> for SpatialDims
source§fn from(set: [T; 3]) -> SpatialDims
fn from(set: [T; 3]) -> SpatialDims
source§impl<T: Num + ToPrimitive + Debug + Copy> From<(T,)> for SpatialDims
impl<T: Num + ToPrimitive + Debug + Copy> From<(T,)> for SpatialDims
source§fn from(val: (T,)) -> SpatialDims
fn from(val: (T,)) -> SpatialDims
source§impl<T: Num + ToPrimitive + Debug + Copy> From<(T, T)> for SpatialDims
impl<T: Num + ToPrimitive + Debug + Copy> From<(T, T)> for SpatialDims
source§fn from(pair: (T, T)) -> SpatialDims
fn from(pair: (T, T)) -> SpatialDims
source§impl<T: Num + ToPrimitive + Debug + Copy> From<(T, T, T)> for SpatialDims
impl<T: Num + ToPrimitive + Debug + Copy> From<(T, T, T)> for SpatialDims
source§fn from(set: (T, T, T)) -> SpatialDims
fn from(set: (T, T, T)) -> SpatialDims
source§impl From<i32> for SpatialDims
impl From<i32> for SpatialDims
source§fn from(val: i32) -> SpatialDims
fn from(val: i32) -> SpatialDims
source§impl From<isize> for SpatialDims
impl From<isize> for SpatialDims
source§fn from(val: isize) -> SpatialDims
fn from(val: isize) -> SpatialDims
source§impl From<u32> for SpatialDims
impl From<u32> for SpatialDims
source§fn from(val: u32) -> SpatialDims
fn from(val: u32) -> SpatialDims
source§impl From<usize> for SpatialDims
impl From<usize> for SpatialDims
source§fn from(val: usize) -> SpatialDims
fn from(val: usize) -> SpatialDims
source§impl Index<usize> for SpatialDims
impl Index<usize> for SpatialDims
source§impl MemLen for SpatialDims
impl MemLen for SpatialDims
source§impl PartialEq for SpatialDims
impl PartialEq for SpatialDims
source§fn eq(&self, other: &SpatialDims) -> bool
fn eq(&self, other: &SpatialDims) -> bool
self
and other
values to be equal, and is used
by ==
.