Tpetra: "New RTI" (Reduction Transform Interface), Part 1 (for_each, transform)
Created by: mhoemmen
@trilinos/tpetra
Description
Tpetra once had something called the Reduction Transform Interface (RTI). It let users apply a function to each entry of one or two (or three, I think) Tpetra::Vector
s, and then possibly end with a reduction over the output Vector.
This commit starts anew with RTI, by adding the following features:
-
withLocalAccess
: Access the local data of aTpetra::)Multi)Vector
in a given memory space -- a declarative replacement for DualView-style functions -
for_each
: Works likestd::for_each
, but forTpetra::(Multi)Vector
-
transform
: Works like unary or binarystd::transform
, but forTpetra::(Multi)Vector
(2) and (3) use (1). All of these have extension points so that they can be adapted for other objects, such as CrsGraph or CrsMatrix.
Motivation and Context
Users want to apply functions entrywise to a Vector or MultiVector. They want to get at the local data, and they want Tpetra to handle the sync and modify flag stuff for them. Tpetra wants the power to do things like lazy allocation (see #333) that go beyond what Kokkos::DualView
allows. Tpetra wants to protect users from holding on to owning Kokkos::View
that really belong to Tpetra objects, because that can cause bugs (e.g., if the mesh that produced the linear system has changed) and unnecessary memory usage.
Next steps
- Add
transform_reduce
(the "R" in "RTI") - Think about how to do kernel fusion with a mixture of Vector and CrsMatrix (or at least provide a "residual" interface)