Type Alias poc_kokkos_rs::view::ViewRO
source · pub type ViewRO<'a, const N: usize, T> = ViewBase<'a, N, T>;
Expand description
View type owning a read-only borrow to the data it yields access to, i.e. a read-only mirror.
Aliased Type§
struct ViewRO<'a, const N: usize, T> {
pub data: DataType<'a, T>,
pub layout: Layout<N>,
pub dim: [usize; N],
pub stride: [usize; N],
}
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,
impl<'a, const N: usize, T> ViewBase<'a, N, T>where T: DataTraits,
source§impl<'a, const N: usize, T> ViewBase<'a, N, T>where
T: DataTraits,
impl<'a, const N: usize, T> ViewBase<'a, N, T>where T: DataTraits,
sourcepub fn set(&mut self, index: [usize; N], val: T)
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
sourcepub fn get(&self, index: [usize; N]) -> T
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
sourcepub fn create_mirror<'b>(&'a self) -> Result<ViewRO<'b, N, T>, ViewError<'_>>where
'a: 'b,
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.
sourcepub fn create_mutable_mirror<'b>(
&'a mut self
) -> Result<ViewRW<'b, N, T>, ViewError<'_>>where
'a: 'b,
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.
Trait Implementations§
source§impl<'a, const N: usize, T> Index<[usize; N]> for ViewBase<'a, N, T>where
T: DataTraits,
impl<'a, const N: usize, T> Index<[usize; N]> for ViewBase<'a, N, T>where T: DataTraits,
Read-only access is always implemented.
source§impl<'a, const N: usize, T> IndexMut<[usize; N]> for ViewBase<'a, N, T>where
T: DataTraits,
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.