pub struct ViewBase<'a, const N: usize, T>where
    T: DataTraits,{
    pub data: DataType<'a, T>,
    pub layout: Layout<N>,
    pub dim: [usize; N],
    pub stride: [usize; N],
}
Expand description

Common structure used as the backend of all View types. The main differences between usable types is the type of the data field.

Fields§

§data: DataType<'a, T>

Data container. Depending on the type, it can be a vector (Owned), a reference (ReadOnly) or a mutable reference (ReadWrite).

§layout: Layout<N>

Memory layout of the view. Refer to Kokkos documentation for more information.

§dim: [usize; N]

Dimensions of the data represented by the view. The view can:

  • be a vector (1 dimension)
  • be a multi-dimensionnal array (up to 8 dimensions) The number of dimensions is referred to as the depth. Dimension 0, i.e. scalar, is not directly supported.
§stride: [usize; N]

Stride between each element of a given dimension. Computed automatically for Layout::Left and Layout::Right.

Implementations§

source§

impl<'a, const N: usize, T> ViewBase<'a, N, T>where T: DataTraits,

source

pub fn new(layout: Layout<N>, dim: [usize; N]) -> Self

Constructor used to create owned views. See dedicated methods for others.

source

pub fn new_from_data(data: Vec<T>, layout: Layout<N>, dim: [usize; N]) -> Self

Constructor used to create owned views. See dedicated methods for others.

source§

impl<'a, const N: usize, T> ViewBase<'a, N, T>where T: DataTraits,

source

pub fn set(&mut self, index: [usize; N], val: T)

Writing interface.

Two different implementations of this method are defined in order to satisfy the (im)mutability requirements when using parallelization features & keep a consistent user API:

  • any feature enabled: implictly use an atomic store operation on top of the regular Index trait implementation to prevent a mutable borrow. The store currently uses relaxed ordering, this may change.
  • no feature enabled: uses a regular IndexMut trait implementation.

Note that Index is always implemented while IndexMut only is when no features are enabled.

Current version: no feature

source

pub fn get(&self, index: [usize; N]) -> T

Reading interface.

Two different implementations of this method are defined in order to keep a consistent user API across features:

  • any feature enabled: implictly use an atomic load operation on top of the regular Index trait implementation. The load currently uses relaxed ordering, this may change.
  • no feature enabled: uses the regular Index trait implementation.

Note that Index is always implemented while IndexMut only is when no features are enabled.

Current version: no feature

source

pub fn create_mirror<'b>(&'a self) -> Result<ViewRO<'b, N, T>, ViewError<'_>>where 'a: 'b,

Create a new View mirroring self, i.e. referencing the same data. This mirror is always immutable, but it inner values might still be writable if they are atomic types.

Note that mirrors currently can only be created from the “original” view, i.e. the view owning the data.

source

pub fn create_mutable_mirror<'b>( &'a mut self ) -> Result<ViewRW<'b, N, T>, ViewError<'_>>where 'a: 'b,

Create a new View mirroring self, i.e. referencing the same data. This mirror uses a mutable reference, hence the serial-only definition

Note that mirrors currently can only be created from the “original” view, i.e. the view owning the data.

Only defined when no feature are enabled since all interfaces should be immutable otherwise.

source

pub fn flat_idx(&self, index: [usize; N]) -> usize

Mapping function between N-indices and the flat offset.

Trait Implementations§

source§

impl<'a, const N: usize, T> Debug for ViewBase<'a, N, T>where T: DataTraits + Debug,

source§

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

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

impl<'a, const N: usize, T> Index<[usize; N]> for ViewBase<'a, N, T>where T: DataTraits,

Read-only access is always implemented.

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: [usize; N]) -> &Self::Output

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

impl<'a, const N: usize, T> IndexMut<[usize; N]> for ViewBase<'a, N, T>where T: DataTraits,

Read-write access is only implemented when no parallel features are enabled.

source§

fn index_mut(&mut self, index: [usize; N]) -> &mut Self::Output

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

impl<'a, const N: usize, T> PartialEq<ViewBase<'a, N, T>> for ViewBase<'a, N, T>where T: DataTraits + PartialEq,

source§

fn eq(&self, other: &ViewBase<'a, N, T>) -> 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<'a, const N: usize, T> StructuralPartialEq for ViewBase<'a, N, T>where T: DataTraits,

Auto Trait Implementations§

§

impl<'a, const N: usize, T> RefUnwindSafe for ViewBase<'a, N, T>where T: RefUnwindSafe,

§

impl<'a, const N: usize, T> Send for ViewBase<'a, N, T>where T: Send + Sync,

§

impl<'a, const N: usize, T> Sync for ViewBase<'a, N, T>where T: Sync,

§

impl<'a, const N: usize, T> Unpin for ViewBase<'a, N, T>where T: Unpin,

§

impl<'a, const N: usize, T> !UnwindSafe for ViewBase<'a, N, T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.