Module poc_kokkos_rs::view
source · Expand description
data structure related code
This module contains code used for the implementations of Views
, a data structure
defined and used by the Kokkos library. There are different types of views, all
implemented using the same backend, ViewBase.
Eventually, the different types of Views should be removed and replaced by a single type. The distinction between original and mirrors doesn’t seem necessary in a Rust implementation where the ownership system handles all memory transaction.
In order to have thread-safe structures to use in parallel statement, the inner data
type of views is adjusted implicitly when compiling using parallelization features.
To match the adjusted data type, view access is done through get
and set
methods,
allowing for feature-specific mutability in signatures while keeping a consistent user
API.
Parameters of aforementionned views are defined in the parameters
sub-module.
Example
Initialize and fill a 2D matrix:
use poc_kokkos_rs::view::{
parameters::Layout,
ViewOwned,
};
let mut viewA: ViewOwned<'_, 2, f64> = ViewOwned::new(
Layout::Right, // see parameters & Kokkos doc
[3, 5], // 3 rows, 5 columns
);
for row in 0..3 {
for col in 0..5 {
viewA.set([row, col], row as f64);
}
}
// viewA:
// (0.0 0.0 0.0 0.0 0.0)
// (1.0 1.0 1.0 1.0 1.0)
// (2.0 2.0 2.0 2.0 2.0)
Modules
- view parameterization code
Structs
- Common structure used as the backend of all
View
types. The main differences between usable types is the type of thedata
field.
Enums
- Enum used to classify view-related errors.
Type Aliases
- View type owning the data it yields access to, i.e. “original” view.
- View type owning a read-only borrow to the data it yields access to, i.e. a read-only mirror.
- View type owning a mutable borrow to the data it yields access to, i.e. a read-write mirror.