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§

§

Unspecified

§

One(usize)

§

Two(usize, usize)

§

Three(usize, usize, usize)

Implementations§

source§

impl SpatialDims

source

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.

source

pub fn dim_count(&self) -> u32

Returns the number of dimensions defined by this SpatialDims.

source

pub fn to_lens(&self) -> Result<[usize; 3], UnspecifiedDimensionsError>

Returns a 3D size or an error if unspecified.

source

pub fn to_offset(&self) -> Result<[usize; 3], UnspecifiedDimensionsError>

Returns a 3D offset or an error if unspecified.

source

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.

source

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.

source

pub fn is_unspecified(&self) -> bool

Returns true if this SpatialDims is an Unspecified variant.

Trait Implementations§

source§

impl Clone for SpatialDims

source§

fn clone(&self) -> SpatialDims

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 SpatialDims

source§

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

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

impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 1]> for SpatialDims

source§

fn from(val: &[T; 1]) -> SpatialDims

Converts to this type from the input type.
source§

impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 2]> for SpatialDims

source§

fn from(pair: &[T; 2]) -> SpatialDims

Converts to this type from the input type.
source§

impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a [T; 3]> for SpatialDims

source§

fn from(set: &[T; 3]) -> SpatialDims

Converts to this type from the input type.
source§

impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T,)> for SpatialDims

source§

fn from(val: &(T,)) -> SpatialDims

Converts to this type from the input type.
source§

impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T, T)> for SpatialDims

source§

fn from(pair: &(T, T)) -> SpatialDims

Converts to this type from the input type.
source§

impl<'a, T: Num + ToPrimitive + Debug + Copy> From<&'a (T, T, T)> for SpatialDims

source§

fn from(set: &(T, T, T)) -> SpatialDims

Converts to this type from the input type.
source§

impl<'a> From<&'a SpatialDims> for SpatialDims

source§

fn from(sd: &'a SpatialDims) -> SpatialDims

Converts to this type from the input type.
source§

impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 1]> for SpatialDims

source§

fn from(val: [T; 1]) -> SpatialDims

Converts to this type from the input type.
source§

impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 2]> for SpatialDims

source§

fn from(pair: [T; 2]) -> SpatialDims

Converts to this type from the input type.
source§

impl<T: Num + ToPrimitive + Debug + Copy> From<[T; 3]> for SpatialDims

source§

fn from(set: [T; 3]) -> SpatialDims

Converts to this type from the input type.
source§

impl<T: Num + ToPrimitive + Debug + Copy> From<(T,)> for SpatialDims

source§

fn from(val: (T,)) -> SpatialDims

Converts to this type from the input type.
source§

impl<T: Num + ToPrimitive + Debug + Copy> From<(T, T)> for SpatialDims

source§

fn from(pair: (T, T)) -> SpatialDims

Converts to this type from the input type.
source§

impl<T: Num + ToPrimitive + Debug + Copy> From<(T, T, T)> for SpatialDims

source§

fn from(set: (T, T, T)) -> SpatialDims

Converts to this type from the input type.
source§

impl From<i32> for SpatialDims

source§

fn from(val: i32) -> SpatialDims

Converts to this type from the input type.
source§

impl From<isize> for SpatialDims

source§

fn from(val: isize) -> SpatialDims

Converts to this type from the input type.
source§

impl From<u32> for SpatialDims

source§

fn from(val: u32) -> SpatialDims

Converts to this type from the input type.
source§

impl From<usize> for SpatialDims

source§

fn from(val: usize) -> SpatialDims

Converts to this type from the input type.
source§

impl Index<usize> for SpatialDims

§

type Output = usize

The returned type after indexing.
source§

fn index(&self, index: usize) -> &usize

Performs the indexing (container[index]) operation. Read more
source§

impl MemLen for SpatialDims

source§

fn to_len_padded(&self, incr: usize) -> usize

Returns the length of a volume of memory padded to the next multiple of incr.
source§

fn to_len(&self) -> usize

Returns the exact number of elements of a volume of memory (equivalent to Vec::len()).
source§

fn to_lens(&self) -> [usize; 3]

Returns the exact lengths of each dimension of a volume of memory.
source§

impl PartialEq for SpatialDims

source§

fn eq(&self, other: &SpatialDims) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl WorkDims for SpatialDims

source§

fn dim_count(&self) -> u32

Returns the number of dimensions defined.
source§

fn to_work_size(&self) -> Option<[usize; 3]>

Returns an array representing the amount of work to be done by a kernel. Read more
source§

fn to_work_offset(&self) -> Option<[usize; 3]>

Returns an array representing the offset of a work item or memory location. Read more
source§

impl Copy for SpatialDims

source§

impl Eq for SpatialDims

source§

impl StructuralPartialEq for SpatialDims

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.