|
Tpetra Matrix/Vector Services
Version of the Day
|
One or more distributed dense vectors. More...
#include <Tpetra_MultiVector_decl.hpp>

Public Types | |
Typedefs to facilitate template metaprogramming. | |
| typedef Scalar | scalar_type |
| The type of entries in the vector(s). | |
| typedef LocalOrdinal | local_ordinal_type |
| The type of local indices. | |
| typedef GlobalOrdinal | global_ordinal_type |
| The type of global indices. | |
| typedef Node | node_type |
| The Kokkos Node type. | |
Public Member Functions | |
Constructors and destructor | |
| MultiVector (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true) | |
| Basic constuctor. | |
| MultiVector (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source) | |
| Copy constructor (performs a deep copy). | |
| MultiVector (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayView< const Scalar > &A, size_t LDA, size_t NumVectors) | |
| Create multivector by copying two-dimensional array of local data. | |
| MultiVector (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &ArrayOfPtrs, size_t NumVectors) | |
| Create multivector by copying array of views of local data. | |
| virtual | ~MultiVector () |
| Destructor (virtual for memory safety of derived classes). | |
Post-construction modification routines | |
| void | replaceGlobalValue (GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) |
| Replace value, using global (row) index. | |
| void | sumIntoGlobalValue (GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) |
| Add value to existing value, using global (row) index. | |
| void | replaceLocalValue (LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) |
| Replace value, using local (row) index. | |
| void | sumIntoLocalValue (LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) |
| Add value to existing value, using local (row) index. | |
| void | putScalar (const Scalar &value) |
| Set all values in the multivector with the given value. | |
| void | randomize () |
| Set all values in the multivector to pseudorandom numbers. | |
| void | replaceMap (const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map) |
| Replace the underlying Map with a compatible one. | |
| void | reduce () |
| Sum values of a locally replicated multivector across all processes. | |
| MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | operator= (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source) |
Assign the contents of source to this multivector (deep copy). | |
Data Copy and View get methods | |
| Teuchos::RCP< MultiVector < Scalar, LocalOrdinal, GlobalOrdinal, Node > > | subCopy (const Teuchos::Range1D &colRng) const |
| Return a MultiVector with copies of selected columns. | |
| Teuchos::RCP< MultiVector < Scalar, LocalOrdinal, GlobalOrdinal, Node > > | subCopy (const Teuchos::ArrayView< const size_t > &cols) const |
| Return a MultiVector with copies of selected columns. | |
| Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > | subView (const Teuchos::Range1D &colRng) const |
| Return a const MultiVector with const views of selected columns. | |
| Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > | subView (const Teuchos::ArrayView< const size_t > &cols) const |
| Return a const MultiVector with const views of selected columns. | |
| Teuchos::RCP< MultiVector < Scalar, LocalOrdinal, GlobalOrdinal, Node > > | subViewNonConst (const Teuchos::Range1D &colRng) |
| Return a MultiVector with views of selected columns. | |
| Teuchos::RCP< MultiVector < Scalar, LocalOrdinal, GlobalOrdinal, Node > > | subViewNonConst (const Teuchos::ArrayView< const size_t > &cols) |
| Return a MultiVector with views of selected columns. | |
| Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > | offsetView (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &subMap, size_t offset) const |
| Return a const MultiVector view of a subset of rows. | |
| Teuchos::RCP< MultiVector < Scalar, LocalOrdinal, GlobalOrdinal, Node > > | offsetViewNonConst (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &subMap, size_t offset) |
| Return a non-const MultiVector view of a subset of rows. | |
| Teuchos::RCP< const Vector < Scalar, LocalOrdinal, GlobalOrdinal, Node > > | getVector (size_t j) const |
| Return a Vector which is a const view of column j. | |
| Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > | getVectorNonConst (size_t j) |
| Return a Vector which is a nonconst view of column j. | |
| Teuchos::ArrayRCP< const Scalar > | getData (size_t j) const |
| Const view of the local values in a particular vector of this multivector. | |
| Teuchos::ArrayRCP< Scalar > | getDataNonConst (size_t j) |
| View of the local values in a particular vector of this multivector. | |
| void | get1dCopy (Teuchos::ArrayView< Scalar > A, size_t LDA) const |
| Fill the given array with a copy of this multivector's local values. | |
| void | get2dCopy (Teuchos::ArrayView< const Teuchos::ArrayView< Scalar > > ArrayOfPtrs) const |
| Fill the given array with a copy of this multivector's local values. | |
| Teuchos::ArrayRCP< const Scalar > | get1dView () const |
| Const persisting (1-D) view of this multivector's local values. | |
| Teuchos::ArrayRCP < Teuchos::ArrayRCP< const Scalar > > | get2dView () const |
| Return const persisting pointers to values. | |
| Teuchos::ArrayRCP< Scalar > | get1dViewNonConst () |
| Nonconst persisting (1-D) view of this multivector's local values. | |
| Teuchos::ArrayRCP < Teuchos::ArrayRCP< Scalar > > | get2dViewNonConst () |
| Return non-const persisting pointers to values. | |
| const Kokkos::MultiVector < Scalar, Node > & | getLocalMV () const |
| Return a const reference to the underlying Kokkos::MultiVector object (advanced use only) | |
| Kokkos::MultiVector< Scalar, Node > & | getLocalMVNonConst () |
| Return a non-const reference to the underlying Kokkos::MultiVector object (advanced use only) | |
Mathematical methods | |
| void | dot (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const |
| Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]) | |
| void | abs (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) |
| Put element-wise absolute values of input Multi-vector in target: A = abs(this) | |
| void | reciprocal (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) |
| Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j). | |
| void | scale (const Scalar &alpha) |
| Scale the current values of a multi-vector, this = alpha*this. | |
| void | scale (Teuchos::ArrayView< const Scalar > alpha) |
| Scale the current values of a multi-vector, this[j] = alpha[j]*this[j]. | |
| void | scale (const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) |
| Replace multi-vector values with scaled values of A, this = alpha*A. | |
| void | update (const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta) |
| Update multi-vector values with scaled values of A, this = beta*this + alpha*A. | |
| void | update (const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &gamma) |
| Update multi-vector with scaled values of A and B, this = gamma*this + alpha*A + beta*B. | |
| void | norm1 (const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const |
| Compute 1-norm of each vector in multi-vector. | |
| void | norm2 (const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const |
| Compute 2-norm of each vector in multi-vector. | |
| void | normInf (const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const |
| Compute Inf-norm of each vector in multi-vector. | |
| void | normWeighted (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const |
| Compute Weighted 2-norm (RMS Norm) of each vector in multi-vector. | |
| void | meanValue (const Teuchos::ArrayView< Scalar > &means) const |
| Compute mean (average) value of each vector in multi-vector. | |
| void | multiply (Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &beta) |
| Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B). | |
| void | elementWiseMultiply (Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis) |
| Element-wise multiply of a Vector A with a MultiVector B. | |
Attribute access functions | |
| size_t | getNumVectors () const |
| Number of columns in the multivector. | |
| size_t | getLocalLength () const |
| Local number of rows on the calling process. | |
| global_size_t | getGlobalLength () const |
| Global number of rows in the multivector. | |
| size_t | getStride () const |
| Stride between columns in the multivector. | |
| bool | isConstantStride () const |
| Whether this multivector has constant stride between columns. | |
Overridden from Teuchos::Describable | |
| std::string | description () const |
| A simple one-line description of this object. | |
| void | describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const |
| Print the object with the given verbosity level to a FancyOStream. | |
Public methods for redistributing data | |
| void | doImport (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM) |
| Import using an Import object ("forward mode"). | |
| void | doImport (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM) |
| Import using an Export object ("reverse mode"). | |
| void | doExport (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM) |
| Export using an Export object ("forward mode"). | |
| void | doExport (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM) |
| Export using an Import object ("reverse mode"). | |
Attribute accessor methods | |
| bool | isDistributed () const |
| Whether this is a globally distributed object. | |
| const Teuchos::RCP< const Map < LocalOrdinal, GlobalOrdinal, Node > > & | getMap () const |
| The Map with which this DistObject was constructed. | |
I/O methods | |
| void | print (std::ostream &os) const |
| Print this object to the given output stream. | |
Protected Member Functions | |
| virtual void | doTransfer (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, CombineMode CM, size_t numSameIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteToLIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteFromLIDs, const Teuchos::ArrayView< const LocalOrdinal > &remoteLIDs, const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Distributor &distor, ReverseOption revOp) |
| Redistribute data across memory images. | |
Methods implemented by subclasses and used by \c doTransfer(). | |
The | |
| virtual void | copyAndPermute (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, size_t numSameIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteToLIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteFromLIDs)=0 |
| Perform copies and permutations that are local to this process. | |
| virtual void | packAndPrepare (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Teuchos::Array< Scalar > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets, Distributor &distor)=0 |
| Perform any packing or preparation required for communication. | |
| virtual void | unpackAndCombine (const Teuchos::ArrayView< const LocalOrdinal > &importLIDs, const Teuchos::ArrayView< const Scalar > &imports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t constantNumPackets, Distributor &distor, CombineMode CM)=0 |
| Perform any unpacking and combining after communication. | |
Protected Attributes | |
| KMV | lclMV_ |
| The Kokkos::MultiVector containing the compute buffer of data. | |
| Array< size_t > | whichVectors_ |
| Indices of columns this multivector is viewing. | |
| Teuchos::RCP< const Map < LocalOrdinal, GlobalOrdinal, Node > > | map_ |
| The Map over which this object is distributed. | |
Instance data for tracking efficiency warnings | |
| bool | releaseViewsRaisedEfficiencyWarning_ |
| Whether releaseViews() has yet raised an efficiency warning. | |
| bool | createViewsRaisedEfficiencyWarning_ |
| Whether createViews() has yet raised an efficiency warning. | |
| bool | createViewsNonConstRaisedEfficiencyWarning_ |
| Whether createViewsNonConst() has yet raised an efficiency warning. | |
Related Functions | |
(Note that these are not member functions.) | |
| template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node > | |
| Teuchos::RCP< MultiVector < Scalar, LocalOrdinal, GlobalOrdinal, Node > > | createMultiVector (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t numVectors) |
| Nonmember MultiVector constructor: make a MultiVector from a given Map. | |
View constructors, used only by nonmember constructors. | |
| template<class S , class LO , class GO , class N > | |
| RCP< MultiVector< S, LO, GO, N > > | createMultiVectorFromView (const Teuchos::RCP< const Map< LO, GO, N > > &, const Teuchos::ArrayRCP< S > &, size_t, size_t) |
| MultiVector (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayRCP< Scalar > &view, size_t LDA, size_t NumVectors, EPrivateHostViewConstructor) | |
| View constructor with user-allocated data, for CPU nodes only. | |
| bool | vectorIndexOutOfRange (size_t VectorIndex) const |
| template<class T > | |
| ArrayRCP< T > | getSubArrayRCP (ArrayRCP< T > arr, size_t j) const |
| Persisting view of j-th column in the given ArrayRCP. | |
| MultiVector (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, Teuchos::ArrayRCP< Scalar > data, size_t LDA, Teuchos::ArrayView< const size_t > whichVectors, EPrivateComputeViewConstructor) | |
| Advanced constructor for non-contiguous views. | |
| MultiVector (const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, Teuchos::ArrayRCP< Scalar > data, size_t LDA, size_t NumVectors, EPrivateComputeViewConstructor) | |
| Advanced constructor for contiguous views. | |
Implementation of Tpetra::DistObject | |
| ArrayRCP< Scalar > | ncview_ |
| Nonconst host view created in createViewsNonConst(). | |
| ArrayRCP< const Scalar > | cview_ |
| Const host view created in createViews(). | |
| bool | checkSizes (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &sourceObj) |
Whether data redistribution between sourceObj and this object is legal. | |
| void | copyAndPermute (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &sourceObj, size_t numSameIDs, const ArrayView< const LocalOrdinal > &permuteToLIDs, const ArrayView< const LocalOrdinal > &permuteFromLIDs) |
| void | packAndPrepare (const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &sourceObj, const ArrayView< const LocalOrdinal > &exportLIDs, Array< Scalar > &exports, const ArrayView< size_t > &numExportPacketsPerLID, size_t &constantNumPackets, Distributor &distor) |
| void | unpackAndCombine (const ArrayView< const LocalOrdinal > &importLIDs, const ArrayView< const Scalar > &imports, const ArrayView< size_t > &numPacketsPerLID, size_t constantNumPackets, Distributor &distor, CombineMode CM) |
| void | createViews () const |
| Hook for creating a const view. | |
| void | createViewsNonConst (Kokkos::ReadWriteOption rwo) |
| Hook for creating a nonconst view. | |
| void | releaseViews () const |
| Hook for releasing views. | |
One or more distributed dense vectors.
A "multivector" contains one or more dense vectors. All the vectors in a multivector have the same distribution of rows in parallel over the communicator used to create the multivector. Multivectors containing more than one vector are useful for algorithms that solve multiple linear systems at once, or that solve for a cluster of eigenvalues and their corresponding eigenvectors at once. These "block" algorithms often have accuracy or performance advantages over corresponding algorithms that solve for only one vector at a time. For example, working with multiple vectors at a time allows Tpetra to use faster BLAS 3 routines for local computations. It may also reduce the number of parallel reductions.
The Vector class implements the MultiVector interface, so if you only wish to work with a single vector at a time, you may simply use Vector instead of MultiVector. However, if you are writing solvers or preconditioners, you would do better to write to the MultiVector interface and always assume that each MultiVector contains more than one vector. This will make your solver or preconditioner more compatible with other Trilinos packages, and it will also let you exploit the performance optimizations mentioned above.
| Scalar | The type of the numerical entries of the vector(s). (You can use real-valued or complex-valued types here, unlike in Epetra, where the scalar type is always double.) |
| LocalOrdinal | The type of local indices. Same as the LocalOrdinal template parameter of Map objects used by this matrix. (In Epetra, this is just int.) The default type is int, which should suffice for most users. This type must be big enough to store the local (per process) number of rows. |
| GlobalOrdinal | The type of global indices. Same as the GlobalOrdinal template parameter of Map objects used by this matrix. (In Epetra, this is just int. One advantage of Tpetra over Epetra is that you can use a 64-bit integer type here if you want to solve big problems.) The default type is LocalOrdinal. This type must be big enough to store the global (over all processes in the communicator) number of rows or columns. |
| Node | A class implementing on-node shared-memory parallel operations. It must implement the Kokkos Node API. The default Node type should suffice for most users. The actual default type depends on your Trilinos build options. |
GlobalOrdinal type, which is int, then the global number of rows or columns in the matrix may be no more than INT_MAX, which for typical 32-bit int is
(about two billion). If you want to solve larger problems, you must use a 64-bit integer type here.Before reading the rest of this documentation, it helps to know something about the Teuchos memory management classes, in particular Teuchos::RCP, Teuchos::ArrayRCP, and Teuchos::ArrayView. You may also want to know about the differences between BLAS 1, 2, and 3 operations, and learn a little bit about MPI (the Message Passing Interface for distributed-memory programming). You won't have to use MPI directly to use MultiVector, but it helps to be familiar with the general idea of distributed storage of data over a communicator.
A multivector could be a view of some subset of another multivector's columns and rows. A view is like a pointer; it provides access to the original multivector's data without copying the data. There are no public constructors for creating a view, but any instance method with "view" in the name that returns an RCP<MultiVector> serves as a view constructor.
The subset of columns in a view need not be contiguous. For example, given a multivector X with 43 columns, it is possible to have a multivector Y which is a view of columns 1, 3, and 42 (zero-based indices) of X. We call such multivectors noncontiguous. They have the the property that isConstantStride() returns false.
Noncontiguous multivectors lose some performance advantages. For example, local computations may be slower, since Tpetra cannot use BLAS 3 routines (e.g., matrix-matrix multiply) on a noncontiguous multivectors without copying into temporary contiguous storage. Noncontiguous multivectors also affect the ability to access the data in certain ways, which we will explain below.
We have unfortunately overloaded the term "view." In the section above, we explained the idea of a "multivector which is a view of another multivector." This section is about "views of a multivector's data." If you want to read or write the actual values in a multivector, this is what you want. All the instance methods which return an ArrayRCP of Scalar data, or an ArrayRCP of ArrayRCP of Scalar data, return views to the data. These data are always local data, meaning that the corresponding rows of the multivector are owned by the calling process. You can't use these methods to access remote data (rows that do not belong to the calling process).
Data views may be either one-dimensional (1-D) or two-dimensional (2-D). A 1-D view presents the data as a dense matrix in column-major order, returned as a single array. On the calling process, the matrix has getLocalLength() rows, getNumVectors() columns, and column stride getStride(). You may not get a 1-D view of a noncontiguous multivector. If you need the data of a noncontiguous multivector in a 1-D format, you may get a copy by calling get1dCopy(). A 2-D view presents the data as an array of arrays, one array per column (i.e., vector in the multivector). The entries in each column are stored contiguously. You may get a 2-D view of any multivector, whether or not it is noncontiguous.
Views are not necessarily just encapsulated pointers. The meaning of view depends in part on the Kokkos Node type (the Node template parameter). This matters in particular if you are running on a Graphics Processing Unit (GPU) device. You can tell at compile time whether you are running on a GPU by looking at the Kokkos Node type. (Currently, the only GPU Node type we provide is Kokkos::ThrustGPUNode. All other types are CPU Nodes.) If the Kokkos Node is a GPU Node type, then views always reside in host (CPU) memory, rather than device (GPU) memory. When you ask for a view, it copies data from the device to the host.
What happens next to your view depends on whether the view is const (read-only) or nonconst (read and write). Const views disappear (their host memory is deallocated) when the corresponding reference count (of the ArrayRCP) goes to zero. (Since the data were not changed, there is no need to update the original copy on the device.) When a nonconst view's reference count goes to zero, the view's data are copied back to device memory, thus "pushing" your changes on the host back to the device.
These device-host-device copy semantics on GPUs mean that we can only promise that a view is a snapshot of the multivector's data at the time the view was created. If you create a const view, then a nonconst view, then modify the nonconst view, the contents of the const view are undefined. For host-only (CPU only, no GPU) Kokkos Nodes, views may be just encapsulated pointers to the data, so modifying a nonconst view will change the original data. For GPU Nodes, modifying a nonconst view will not change the original data until the view's reference count goes to zero. Furthermore, if the nonconst view's reference count never goes to zero, the nonconst view will never be copied back to device memory, and thus the original data will never be changed.
Tpetra was designed to allow different data representations underneath the same interface. This lets Tpetra run correctly and efficiently on many different kinds of hardware, including single-core CPUs, multicore CPUs with Non-Uniform Memory Access (NUMA), and even "discrete compute accelerators" like Graphics Processing Units (GPUs). These different kinds of hardware all have in common the following:
These conclusions have practical consequences for the MultiVector interface. In particular, we have deliberately made it difficult for you to access data directly by raw pointer. This is because the underlying layout may not be what you expect. In some cases, you are not even allowed to dereference the raw pointer (for example, if it resides in GPU device memory, and you are working on the host CPU). This is why we require accessing the data through views.
The above section also explains why we do not offer a Scalar& operator[] to access each entry of a vector directly. Direct access on GPUs would require implicitly creating an internal host copy of the device data. This would consume host memory, and it would not be clear when to write the resulting host data back to device memory. The resulting operator would violate users' performance expectations, since it would be much slower than raw array access. We have preferred in our design to expose what is expensive, by exposing data views and letting users control when to copy data between host and device.
"Directly" here means without views, using a device kernel if the data reside on the GPU.
There are two different options for direct access to the multivector's data. One is to use the optional RTI (Reduction / Transformation Interface) subpackage of Tpetra. You may enable this at Trilinos configure time by setting the CMake Boolean option Tpetra_ENABLE_RTI to ON. Be aware that building and using RTI requires that your C++ compiler support the language features in the new C++11 standard. RTI allows you to implement arbitrary element-wise operations over a vector, followed by arbitrary reductions over the elements of that vector. We recommend RTI for most users.
Another option is to access the local data through its Kokkos container data structure, Kokkos::MultiVector, and then use the Kokkos Node API to implement arbitrary operations on the data. We do not recommend this approach for most users. In particular, the local data structures are likely to change over the next few releases. If you find yourself wanting to try this option, please contact the Tpetra developers for recommendations. We will be happy to work with you.
A MultiVector's rows are distributed over processes in its (row) Map's communicator. A MultiVector is a DistObject; the Map of the DistObject tells which process in the communicator owns which rows. This means that you may use Import and Export operations to migrate between different distributions. Please refer to the documentation of Map, Import, and Export for more information.
MultiVector includes methods that perform parallel all-reduces. These include inner products and various kinds of norms. All of these methods have the same blocking semantics as MPI_Allreduce.
Definition at line 327 of file Tpetra_MultiVector_decl.hpp.
| typedef Scalar Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::scalar_type |
The type of entries in the vector(s).
Reimplemented in Tpetra::BlockMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 335 of file Tpetra_MultiVector_decl.hpp.
| typedef LocalOrdinal Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_ordinal_type |
The type of local indices.
Reimplemented in Tpetra::BlockMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 337 of file Tpetra_MultiVector_decl.hpp.
| typedef GlobalOrdinal Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::global_ordinal_type |
The type of global indices.
Reimplemented in Tpetra::BlockMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 339 of file Tpetra_MultiVector_decl.hpp.
| typedef Node Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type |
The Kokkos Node type.
Reimplemented in Tpetra::BlockMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 341 of file Tpetra_MultiVector_decl.hpp.
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MultiVector | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | map, |
| size_t | NumVectors, | ||
| bool | zeroOut = true |
||
| ) |
Basic constuctor.
| map | [in] Map describing the distribution of rows. |
| NumVectors | [in] Number of vectors (columns). |
| zeroOut | [in] Whether to initialize all the entries of the MultiVector to zero. |
Definition at line 60 of file Tpetra_MultiVector_def.hpp.
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MultiVector | ( | const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | source | ) |
Copy constructor (performs a deep copy).
Definition at line 96 of file Tpetra_MultiVector_def.hpp.
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MultiVector | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | map, |
| const Teuchos::ArrayView< const Scalar > & | A, | ||
| size_t | LDA, | ||
| size_t | NumVectors | ||
| ) |
Create multivector by copying two-dimensional array of local data.
| map | [in] The Map describing the distribution of rows of the multivector. |
| view | [in] A view of column-major dense matrix data. The calling process will make a deep copy of this data. |
| LDA | [in] The leading dimension (a.k.a. "stride") of the column-major input data. |
| NumVectors | [in] The number of columns in the input data. This will be the number of vectors in the returned multivector. |
Definition at line 283 of file Tpetra_MultiVector_def.hpp.
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MultiVector | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | map, |
| const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > & | ArrayOfPtrs, | ||
| size_t | NumVectors | ||
| ) |
Create multivector by copying array of views of local data.
| map | [in] The Map describing the distribution of rows of the multivector. |
| ArrayOfPtrs | [in/out] Array of views of each column's data. The calling process will make a deep copy of this data. |
| NumVectors | [in] The number of columns in the input data, and the number of elements in ArrayOfPtrs. This will be the number of vectors in the returned multivector. |
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::~MultiVector | ( | ) | [virtual] |
Destructor (virtual for memory safety of derived classes).
Definition at line 386 of file Tpetra_MultiVector_def.hpp.
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MultiVector | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | map, |
| const Teuchos::ArrayRCP< Scalar > & | view, | ||
| size_t | LDA, | ||
| size_t | NumVectors, | ||
| EPrivateHostViewConstructor | |||
| ) | [protected] |
View constructor with user-allocated data, for CPU nodes only.
The tag says that views of the MultiVector are always host views, that is, they do not live on a separate device memory space (for example, on a GPU).
This member constructor is meant to be called by its nonmember constructor friend; it is not meant to be called by users (hence it is protected).
Definition at line 178 of file Tpetra_MultiVector_def.hpp.
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MultiVector | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | map, |
| Teuchos::ArrayRCP< Scalar > | data, | ||
| size_t | LDA, | ||
| Teuchos::ArrayView< const size_t > | whichVectors, | ||
| EPrivateComputeViewConstructor | |||
| ) | [protected] |
Advanced constructor for non-contiguous views.
Definition at line 239 of file Tpetra_MultiVector_def.hpp.
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::MultiVector | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | map, |
| Teuchos::ArrayRCP< Scalar > | data, | ||
| size_t | LDA, | ||
| size_t | NumVectors, | ||
| EPrivateComputeViewConstructor | |||
| ) | [protected] |
Advanced constructor for contiguous views.
Definition at line 209 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::replaceGlobalValue | ( | GlobalOrdinal | globalRow, |
| size_t | vectorIndex, | ||
| const Scalar & | value | ||
| ) |
Replace value, using global (row) index.
Replace the current value at row globalRow (a global index) and column vectorIndex with the given value. The column index is zero based.
globalRow must be a valid global element on this process, according to the row Map. Definition at line 2134 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::sumIntoGlobalValue | ( | GlobalOrdinal | globalRow, |
| size_t | vectorIndex, | ||
| const Scalar & | value | ||
| ) |
Add value to existing value, using global (row) index.
Add the given value to the existing value at row globalRow (a global index) and column vectorIndex. The column index is zero based.
globalRow must be a valid global element on this process, according to the row Map. Definition at line 2148 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::replaceLocalValue | ( | LocalOrdinal | myRow, |
| size_t | vectorIndex, | ||
| const Scalar & | value | ||
| ) |
Replace value, using local (row) index.
Replace the current value at row myRow (a local index) and column vectorIndex with the given value. The column index is zero based.
myRow must be a valid local element on this process, according to the row Map. Definition at line 2098 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::sumIntoLocalValue | ( | LocalOrdinal | myRow, |
| size_t | vectorIndex, | ||
| const Scalar & | value | ||
| ) |
Add value to existing value, using local (row) index.
Add the given value to the existing value at row myRow (a local index) and column vectorIndex. The column index is zero based.
myRow must be a valid local element on this process, according to the row Map. Definition at line 2116 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::putScalar | ( | const Scalar & | value | ) |
Set all values in the multivector with the given value.
Definition at line 983 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::randomize | ( | ) |
Set all values in the multivector to pseudorandom numbers.
srand() and rand().Definition at line 962 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::replaceMap | ( | const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | map | ) |
Replace the underlying Map with a compatible one.
This method relabels the rows of the multivector using the global IDs in the input Map. Thus, it implicitly applies a permutation, without actually moving data. This only works if the input Map is compatible (in the sense of Map::isCompatible()) with the multivector's current Map, so that the number of rows per process does not change.
We only check for compatibility in debug mode (when Trilinos was built with the Trilinos_ENABLE_DEBUG option set). In that case, if the input Map is not compatible, then this method throws std::invalid_argument. We only check in debug mode because the check requires communication (
all-reduces).
Import or Export.Definition at line 1004 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::reduce | ( | ) |
Sum values of a locally replicated multivector across all processes.
Definition at line 2029 of file Tpetra_MultiVector_def.hpp.
| MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::operator= | ( | const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | source | ) |
Assign the contents of source to this multivector (deep copy).
this->getMap ()->isCompatible (source.getMap ());
Definition at line 1323 of file Tpetra_MultiVector_def.hpp.
| Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::subCopy | ( | const Teuchos::Range1D & | colRng | ) | const |
Return a MultiVector with copies of selected columns.
These methods are used to get the data underlying the MultiVector. They return data in one of three forms:
Definition at line 1390 of file Tpetra_MultiVector_def.hpp.
| Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::subCopy | ( | const Teuchos::ArrayView< const size_t > & | cols | ) | const |
Return a MultiVector with copies of selected columns.
Definition at line 1363 of file Tpetra_MultiVector_def.hpp.
| Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::subView | ( | const Teuchos::Range1D & | colRng | ) | const |
Return a const MultiVector with const views of selected columns.
Definition at line 1549 of file Tpetra_MultiVector_def.hpp.
| Teuchos::RCP<const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::subView | ( | const Teuchos::ArrayView< const size_t > & | cols | ) | const |
Return a const MultiVector with const views of selected columns.
| Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::subViewNonConst | ( | const Teuchos::Range1D & | colRng | ) |
Return a MultiVector with views of selected columns.
Definition at line 1610 of file Tpetra_MultiVector_def.hpp.
| Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::subViewNonConst | ( | const Teuchos::ArrayView< const size_t > & | cols | ) |
Return a MultiVector with views of selected columns.
| Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::offsetView | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | subMap, |
| size_t | offset | ||
| ) | const |
Return a const MultiVector view of a subset of rows.
Return a const view of this MultiVector consisting of a subset of the rows, as specified by an offset and a subset Map of this MultiVector's current row Map.
| In | subMap - The row Map for the new MultiVector. |
| In | offset - The offset into the data of (*this). |
subMap->getNodeNumElements() + offset < this->getLocalLength() Definition at line 1417 of file Tpetra_MultiVector_def.hpp.
| Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::offsetViewNonConst | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | subMap, |
| size_t | offset | ||
| ) |
Return a non-const MultiVector view of a subset of rows.
Returns a non-const view of this MultiVector consisting of a subset of the rows, as specified by an offset and a subset Map of this MultiVector's current row Map.
| In | subMap - The row Map for the new MultiVector. |
| In | offset - The offset into the data of (*this). |
subMap->getNodeNumElements() + offset < this->getLocalLength() Definition at line 1456 of file Tpetra_MultiVector_def.hpp.
| Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getVector | ( | size_t | j | ) | const |
Return a Vector which is a const view of column j.
Definition at line 1643 of file Tpetra_MultiVector_def.hpp.
| Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getVectorNonConst | ( | size_t | j | ) |
Return a Vector which is a nonconst view of column j.
Definition at line 1668 of file Tpetra_MultiVector_def.hpp.
| Teuchos::ArrayRCP< const Scalar > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getData | ( | size_t | j | ) | const |
Const view of the local values in a particular vector of this multivector.
Definition at line 1301 of file Tpetra_MultiVector_def.hpp.
| Teuchos::ArrayRCP< Scalar > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getDataNonConst | ( | size_t | j | ) |
View of the local values in a particular vector of this multivector.
Definition at line 1312 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::get1dCopy | ( | Teuchos::ArrayView< Scalar > | A, |
| size_t | LDA | ||
| ) | const |
Fill the given array with a copy of this multivector's local values.
| A | [out] View of the array to fill. We consider A as a matrix with column-major storage. |
| LDA | [in] Leading dimension of the matrix A. |
Definition at line 1689 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::get2dCopy | ( | Teuchos::ArrayView< const Teuchos::ArrayView< Scalar > > | ArrayOfPtrs | ) | const |
Fill the given array with a copy of this multivector's local values.
| ArrayOfPtrs | [out] Array of arrays, one for each column of the multivector. On output, we fill ArrayOfPtrs[j] with the data for column j of this multivector. |
Definition at line 1724 of file Tpetra_MultiVector_def.hpp.
| Teuchos::ArrayRCP< const Scalar > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::get1dView | ( | ) | const |
Const persisting (1-D) view of this multivector's local values.
This method assumes that the columns of the multivector are stored contiguously. If not, this method throws std::runtime_error.
Definition at line 1758 of file Tpetra_MultiVector_def.hpp.
| Teuchos::ArrayRCP< Teuchos::ArrayRCP< const Scalar > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::get2dView | ( | ) | const |
Return const persisting pointers to values.
Definition at line 1822 of file Tpetra_MultiVector_def.hpp.
| Teuchos::ArrayRCP< Scalar > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::get1dViewNonConst | ( | ) |
Nonconst persisting (1-D) view of this multivector's local values.
This method assumes that the columns of the multivector are stored contiguously. If not, this method throws std::runtime_error.
Definition at line 1770 of file Tpetra_MultiVector_def.hpp.
| Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::get2dViewNonConst | ( | ) |
Return non-const persisting pointers to values.
Definition at line 1782 of file Tpetra_MultiVector_def.hpp.
| const Kokkos::MultiVector< Scalar, Node > & Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getLocalMV | ( | ) | const |
Return a const reference to the underlying Kokkos::MultiVector object (advanced use only)
Definition at line 2182 of file Tpetra_MultiVector_def.hpp.
| Kokkos::MultiVector< Scalar, Node > & Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getLocalMVNonConst | ( | ) |
Return a non-const reference to the underlying Kokkos::MultiVector object (advanced use only)
Definition at line 2188 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::dot | ( | const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | A, |
| const Teuchos::ArrayView< Scalar > & | dots | ||
| ) | const |
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i])
Definition at line 674 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::abs | ( | const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | A | ) |
Put element-wise absolute values of input Multi-vector in target: A = abs(this)
Definition at line 1167 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::reciprocal | ( | const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | A | ) |
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
Definition at line 1120 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::scale | ( | const Scalar & | alpha | ) |
Scale the current values of a multi-vector, this = alpha*this.
Definition at line 1018 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::scale | ( | Teuchos::ArrayView< const Scalar > | alpha | ) |
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
Definition at line 1048 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::scale | ( | const Scalar & | alpha, |
| const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | A | ||
| ) |
Replace multi-vector values with scaled values of A, this = alpha*A.
Definition at line 1077 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::update | ( | const Scalar & | alpha, |
| const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | A, | ||
| const Scalar & | beta | ||
| ) |
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
Definition at line 1205 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::update | ( | const Scalar & | alpha, |
| const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | A, | ||
| const Scalar & | beta, | ||
| const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | B, | ||
| const Scalar & | gamma | ||
| ) |
Update multi-vector with scaled values of A and B, this = gamma*this + alpha*A + beta*B.
Definition at line 1249 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::norm1 | ( | const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > & | norms | ) | const |
Compute 1-norm of each vector in multi-vector.
Definition at line 841 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::norm2 | ( | const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > & | norms | ) | const |
Compute 2-norm of each vector in multi-vector.
Definition at line 723 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::normInf | ( | const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > & | norms | ) | const |
Compute Inf-norm of each vector in multi-vector.
Definition at line 876 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::normWeighted | ( | const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | weights, |
| const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > & | norms | ||
| ) | const |
Compute Weighted 2-norm (RMS Norm) of each vector in multi-vector.
Definition at line 769 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::meanValue | ( | const Teuchos::ArrayView< Scalar > & | means | ) | const |
Compute mean (average) value of each vector in multi-vector.
Definition at line 911 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::multiply | ( | Teuchos::ETransp | transA, |
| Teuchos::ETransp | transB, | ||
| const Scalar & | alpha, | ||
| const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | A, | ||
| const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | B, | ||
| const Scalar & | beta | ||
| ) |
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
Definition at line 1863 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::elementWiseMultiply | ( | Scalar | scalarAB, |
| const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | A, | ||
| const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | B, | ||
| Scalar | scalarThis | ||
| ) |
Element-wise multiply of a Vector A with a MultiVector B.
Forms this = scalarThis * this + scalarAB * B @ A where @ denotes element-wise multiplication. B must be the same shape (size and num-vectors) as this, while A is the same size but a single vector (column).
this = scalarThis * this(i,j) + scalarAB * B(i,j) * A(i,1) (A has only 1 column)
Definition at line 1994 of file Tpetra_MultiVector_def.hpp.
| size_t Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getNumVectors | ( | ) | const [inline] |
Number of columns in the multivector.
Definition at line 661 of file Tpetra_MultiVector_def.hpp.
| size_t Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getLocalLength | ( | ) | const |
Local number of rows on the calling process.
Definition at line 397 of file Tpetra_MultiVector_def.hpp.
| global_size_t Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getGlobalLength | ( | ) | const |
Global number of rows in the multivector.
Definition at line 403 of file Tpetra_MultiVector_def.hpp.
| size_t Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getStride | ( | ) | const |
Stride between columns in the multivector.
This is only meaningful if isConstantStride() returns true.
Definition at line 409 of file Tpetra_MultiVector_def.hpp.
| bool Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::isConstantStride | ( | ) | const |
Whether this multivector has constant stride between columns.
Definition at line 391 of file Tpetra_MultiVector_def.hpp.
| std::string Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::description | ( | ) | const [virtual] |
A simple one-line description of this object.
Reimplemented from Tpetra::DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Reimplemented in Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 2194 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::describe | ( | Teuchos::FancyOStream & | out, |
| const Teuchos::EVerbosityLevel | verbLevel = Teuchos::Describable::verbLevel_default |
||
| ) | const [virtual] |
Print the object with the given verbosity level to a FancyOStream.
| out | [out] Output stream to which to print. For verbosity levels VERB_LOW and lower, only the process with rank 0 ("Proc 0") in the MultiVector's communicator prints. For verbosity levels strictly higher than VERB_LOW, all processes in the communicator need to be able to print to the output stream. |
| verbLevel | [in] Verbosity level. The default verbosity (verbLevel=VERB_DEFAULT) is VERB_LOW. |
The amount and content of what this method prints depends on the verbosity level. In the list below, each higher level includes all the content of the previous levels, as well as its own content.
description().isConstantStride()), and if so, what that stride is. (Stride may differ on different processes.)Reimplemented from Tpetra::DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Reimplemented in Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 2208 of file Tpetra_MultiVector_def.hpp.
| Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getSubArrayRCP | ( | ArrayRCP< T > | arr, |
| size_t | j | ||
| ) | const [protected] |
Persisting view of j-th column in the given ArrayRCP.
This method considers isConstantStride(). The ArrayRCP may correspond either to a compute buffer or a host view.
| bool Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::checkSizes | ( | const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > & | sourceObj | ) | [protected, virtual] |
Whether data redistribution between sourceObj and this object is legal.
This method is called in DistObject::doTransfer() to check whether data redistribution between the two objects is legal.
Implements Tpetra::DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 420 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::createViews | ( | ) | const [protected, virtual] |
Hook for creating a const view.
doTransfer() calls this on the source object. By default, it does nothing, but the source object can use this as a hint to fetch data from a compute buffer on an off-CPU device (such as a GPU) into host memory.
Reimplemented from Tpetra::DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 2282 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::createViewsNonConst | ( | Kokkos::ReadWriteOption | rwo | ) | [protected, virtual] |
Hook for creating a nonconst view.
doTransfer() calls this on the destination (*this) object. By default, it does nothing, but the destination object can use this as a hint to fetch data from a compute buffer on an off-CPU device (such as a GPU) into host memory.
| rwo | [in] Whether to create a write-only or a read-and-write view. For Kokkos Node types where compute buffers live in a separate memory space (e.g., in the device memory of a discrete accelerator like a GPU), a write-only view only requires copying from host memory to the compute buffer, whereas a read-and-write view requires copying both ways (once to read, from the compute buffer to host memory, and once to write, back to the compute buffer). |
Reimplemented from Tpetra::DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 2310 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::releaseViews | ( | ) | const [protected, virtual] |
Hook for releasing views.
doTransfer() calls this on both the source and destination objects, once it no longer needs to access that object's data. By default, this method does nothing. Implementations may use this as a hint to free host memory which is a view of a compute buffer, once the host memory view is no longer needed. Some implementations may prefer to mirror compute buffers in host memory; for these implementations, releaseViews() may do nothing.
Reimplemented from Tpetra::DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >.
Definition at line 2336 of file Tpetra_MultiVector_def.hpp.
| void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::doImport | ( | const DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node > & | source, |
| const Import< LocalOrdinal, GlobalOrdinal, Node > & | importer, | ||
| CombineMode | CM | ||
| ) | [inherited] |
Import using an Import object ("forward mode").
| void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::doImport | ( | const DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node > & | source, |
| const Export< LocalOrdinal, GlobalOrdinal, Node > & | exporter, | ||
| CombineMode | CM | ||
| ) | [inherited] |
Import using an Export object ("reverse mode").
| void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::doExport | ( | const DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node > & | dest, |
| const Export< LocalOrdinal, GlobalOrdinal, Node > & | exporter, | ||
| CombineMode | CM | ||
| ) | [inherited] |
Export using an Export object ("forward mode").
| void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::doExport | ( | const DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node > & | dest, |
| const Import< LocalOrdinal, GlobalOrdinal, Node > & | importer, | ||
| CombineMode | CM | ||
| ) | [inherited] |
Export using an Import object ("reverse mode").
| bool Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::isDistributed | ( | ) | const [inline, inherited] |
Whether this is a globally distributed object.
For a definition of "globally distributed" (and its opposite, "locally replicated"), see the documentation of Map's isDistributed() method.
| const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::getMap | ( | ) | const [inline, inherited] |
The Map with which this DistObject was constructed.
Definition at line 172 of file Tpetra_DistObject.hpp.
| void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::print | ( | std::ostream & | os | ) | const [inherited] |
Print this object to the given output stream.
We generally assume that all MPI processes can print to the given stream.
| virtual void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::doTransfer | ( | const DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node > & | source, |
| CombineMode | CM, | ||
| size_t | numSameIDs, | ||
| const Teuchos::ArrayView< const LocalOrdinal > & | permuteToLIDs, | ||
| const Teuchos::ArrayView< const LocalOrdinal > & | permuteFromLIDs, | ||
| const Teuchos::ArrayView< const LocalOrdinal > & | remoteLIDs, | ||
| const Teuchos::ArrayView< const LocalOrdinal > & | exportLIDs, | ||
| Distributor & | distor, | ||
| ReverseOption | revOp | ||
| ) | [protected, virtual, inherited] |
Redistribute data across memory images.
| source | [in] The source object, to redistribute into the destination object, which is *this object. |
| CM | [in] The combine mode that describes how to combine values that map to the same global ID on the same process. |
| permuteToLIDs | [in] See copyAndPermute(). |
| permuteFromLIDs | [in] See copyAndPermute(). |
| remoteLIDs | [in] List of entries (as local IDs) in the destination object to receive from other processes. |
| exportLIDs | [in] See packAndPrepare(). |
| distor | [in/out] The Distributor object that knows how to redistribute data. |
| revOp | [in] Whether to do a forward or reverse mode redistribution. |
| virtual void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::copyAndPermute | ( | const DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node > & | source, |
| size_t | numSameIDs, | ||
| const Teuchos::ArrayView< const LocalOrdinal > & | permuteToLIDs, | ||
| const Teuchos::ArrayView< const LocalOrdinal > & | permuteFromLIDs | ||
| ) | [protected, pure virtual, inherited] |
Perform copies and permutations that are local to this process.
| source | [in] On entry, the source object, from which we are distributing. We distribute to the destination object, which is *this object. |
| numSameIDs | [in] The umber of elements that are the same on the source and destination (this) objects. These elements are owned by the same process in both the source and destination objects. No permutation occurs. |
| numPermuteIDs | [in] The number of elements that are locally permuted between the source and destination objects. |
| permuteToLIDs | [in] List of the elements that are permuted. They are listed by their LID in the destination object. |
| permuteFromLIDs | [in] List of the elements that are permuted. They are listed by their LID in the source object. |
| virtual void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::packAndPrepare | ( | const DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node > & | source, |
| const Teuchos::ArrayView< const LocalOrdinal > & | exportLIDs, | ||
| Teuchos::Array< Scalar > & | exports, | ||
| const Teuchos::ArrayView< size_t > & | numPacketsPerLID, | ||
| size_t & | constantNumPackets, | ||
| Distributor & | distor | ||
| ) | [protected, pure virtual, inherited] |
Perform any packing or preparation required for communication.
| source | [in] Source object for the redistribution. |
| exportLIDs | [in] List of the entries (as local IDs in the source object) we will be sending to other images. |
| exports | [out] On exit, the buffer for data to send. |
| numPacketsPerLID | [out] On exit, numPacketsPerLID[i] contains the number of packets to be exported for exportLIDs[i]. If constantNumPackets is nonzero, you should use that instead, and not rely on numPacketsPerLID[i] being filled. |
| constantNumPackets | [out] On exit, 0 if numPacketsPerLID has variable contents (different size for each LID). If nonzero, then it is expected that num-packets-per-LID is constant, and constantNumPackets holds that value. |
| distor | [in] The Distributor object we are using. |
| virtual void Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::unpackAndCombine | ( | const Teuchos::ArrayView< const LocalOrdinal > & | importLIDs, |
| const Teuchos::ArrayView< const Scalar > & | imports, | ||
| const Teuchos::ArrayView< size_t > & | numPacketsPerLID, | ||
| size_t | constantNumPackets, | ||
| Distributor & | distor, | ||
| CombineMode | CM | ||
| ) | [protected, pure virtual, inherited] |
Perform any unpacking and combining after communication.
| importLIDs | [in] List of the entries (as LIDs in the destination object) we received from other images. |
| imports | [in] Buffer containing data we received. |
| numPacketsPerLID | [in] numPacketsPerLID[i] contains the number of packets imported for importLIDs[i]. |
| constantNumPackets | [in] If nonzero, then numPacketsPerLID is constant (same value in all entries) and constantNumPackets is that value. If zero, use numPacketsPerLID[i] instead. |
| distor | [in] The Distributor object we are using. |
| CM | [in] The combine mode to use when combining the imported entries with existing entries. |
| Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createMultiVector | ( | const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & | map, |
| size_t | numVectors | ||
| ) | [related] |
Nonmember MultiVector constructor: make a MultiVector from a given Map.
| map | [in] Map describing the distribution of rows of the resulting MultiVector. |
| numVectors | [in] Number of columns of the resulting MultiVector. |
Definition at line 922 of file Tpetra_MultiVector_decl.hpp.
KMV Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::lclMV_ [protected] |
The Kokkos::MultiVector containing the compute buffer of data.
Definition at line 792 of file Tpetra_MultiVector_decl.hpp.
Array<size_t> Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::whichVectors_ [protected] |
Indices of columns this multivector is viewing.
If this array has nonzero size, then this multivector is a view of another multivector (the "original" multivector). In that case, whichVectors_ contains the indices of the columns of the original multivector. Furthermore, isConstantStride() returns false in this case.
If this array has zero size, then this multivector is not a view of any other multivector. Furthermore, the stride between columns of this multivector is a constant: thus, isConstantStride() returns true.
Definition at line 806 of file Tpetra_MultiVector_decl.hpp.
ArrayRCP<Scalar> Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::ncview_ [mutable, protected] |
Nonconst host view created in createViewsNonConst().
Definition at line 894 of file Tpetra_MultiVector_decl.hpp.
ArrayRCP<const Scalar> Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::cview_ [mutable, protected] |
Const host view created in createViews().
Definition at line 897 of file Tpetra_MultiVector_decl.hpp.
bool Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::releaseViewsRaisedEfficiencyWarning_ [mutable, protected] |
Whether releaseViews() has yet raised an efficiency warning.
Definition at line 904 of file Tpetra_MultiVector_decl.hpp.
bool Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::createViewsRaisedEfficiencyWarning_ [mutable, protected] |
Whether createViews() has yet raised an efficiency warning.
Definition at line 906 of file Tpetra_MultiVector_decl.hpp.
bool Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::createViewsNonConstRaisedEfficiencyWarning_ [mutable, protected] |
Whether createViewsNonConst() has yet raised an efficiency warning.
Definition at line 908 of file Tpetra_MultiVector_decl.hpp.
Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > Tpetra::DistObject< Scalar , LocalOrdinal, GlobalOrdinal, Node >::map_ [protected, inherited] |
The Map over which this object is distributed.
Definition at line 390 of file Tpetra_DistObject.hpp.
1.7.6.1