10#ifndef TPETRA_DETAILS_CHECKVIEW_HPP
11#define TPETRA_DETAILS_CHECKVIEW_HPP
21#include "Tpetra_Details_WrappedDualView.hpp"
22#include "Kokkos_DualView.hpp"
23#include "Teuchos_TypeNameTraits.hpp"
24#include "Teuchos_Comm.hpp"
25#include "Teuchos_CommHelpers.hpp"
31std::string memorySpaceName(
const void* ptr);
53template <
class DataType,
class... Properties>
56 const Kokkos::View<DataType, Properties...>& view) {
58 using Teuchos::TypeNameTraits;
61 if (view.size() == 0) {
66 auto ptr = view.data();
73 <<
viewName <<
" has nonzero size " << view.size()
74 <<
" but a null pointer." <<
endl;
89 const Kokkos::DualView<DataType, Args...>&
dv) {
99 using Teuchos::TypeNameTraits;
106 <<
dvName <<
" has one or more invalid Views. See "
107 "above error messages from this MPI process for details."
115bool checkGlobalDualViewValidity(std::ostream*
const gblErrStrm,
116 const Kokkos::DualView<DataType, Args...>&
dv,
118 const Teuchos::Comm<int>*
const comm) {
120 const int myRank = comm ==
nullptr ? 0 : comm->getRank();
128 }
catch (std::exception& e) {
129 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
130 "threw an exception: "
134 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
135 "threw an exception not a subclass of std::exception."
141 if (comm ==
nullptr) {
142 gblSuccess = lclSuccess;
144 using Teuchos::outArg;
145 using Teuchos::REDUCE_MIN;
146 using Teuchos::reduceAll;
147 reduceAll(*comm, REDUCE_MIN, lclSuccess, outArg(gblSuccess));
150 if (gblSuccess != 1 && gblErrStrm !=
nullptr) {
151 *gblErrStrm <<
"On at least one (MPI) process, the "
152 "Kokkos::DualView has "
153 "either the device or host pointer in the "
154 "DualView equal to null, but the DualView has a nonzero number of "
155 "rows. For more detailed information, please rerun with the "
156 "TPETRA_VERBOSE environment variable set to 1. ";
158 *gblErrStrm <<
" Here are error messages from all "
161 if (comm ==
nullptr) {
162 *gblErrStrm << lclErrStrm.str();
170 return gblSuccess == 1;
176template <
class DataType,
186 using Teuchos::TypeNameTraits;
193 <<
dvName <<
" has one or more invalid Views. See "
194 "above error messages from this MPI process for details."
202bool checkGlobalWrappedDualViewValidity(std::ostream*
const gblErrStrm,
205 const Teuchos::Comm<int>*
const comm) {
207 const int myRank = comm ==
nullptr ? 0 : comm->getRank();
215 }
catch (std::exception& e) {
216 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
217 "threw an exception: "
221 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
222 "threw an exception not a subclass of std::exception."
228 if (comm ==
nullptr) {
229 gblSuccess = lclSuccess;
231 using Teuchos::outArg;
232 using Teuchos::REDUCE_MIN;
233 using Teuchos::reduceAll;
234 reduceAll(*comm, REDUCE_MIN, lclSuccess, outArg(gblSuccess));
237 if (gblSuccess != 1 && gblErrStrm !=
nullptr) {
238 *gblErrStrm <<
"On at least one (MPI) process, the "
239 "Kokkos::DualView has "
240 "either the device or host pointer in the "
241 "DualView equal to null, but the DualView has a nonzero number of "
242 "rows. For more detailed information, please rerun with the "
243 "TPETRA_VERBOSE environment variable set to 1. ";
245 *gblErrStrm <<
" Here are error messages from all "
248 if (comm ==
nullptr) {
249 *gblErrStrm << lclErrStrm.str();
257 return gblSuccess == 1;
Declaration of a function that prints strings from each process.
Struct that holds views of the contents of a CrsMatrix.
A wrapper around Kokkos::DualView to safely manage data that might be replicated between host and dev...
Implementation details of Tpetra.
bool checkLocalDualViewValidity(std::ostream *const lclErrStrm, const int myMpiProcessRank, const Kokkos::DualView< DataType, Args... > &dv)
Is the given Kokkos::DualView valid?
bool checkLocalViewValidity(std::ostream *lclErrStrm, const int myMpiProcessRank, const Kokkos::View< DataType, Properties... > &view)
Is the given View valid?
bool checkLocalWrappedDualViewValidity(std::ostream *const lclErrStrm, const int myMpiProcessRank, const Tpetra::Details::WrappedDualView< Kokkos::DualView< DataType, Args... > > &dv)
Is the given Tpetra::WrappedDualView valid?
void gathervPrint(std::ostream &out, const std::string &s, const Teuchos::Comm< int > &comm)
On Process 0 in the given communicator, print strings from each process in that communicator,...
Namespace Tpetra contains the class and methods constituting the Tpetra library.