40#ifndef TPETRA_DETAILS_CHECKVIEW_HPP
41#define TPETRA_DETAILS_CHECKVIEW_HPP
51#include "Tpetra_Details_WrappedDualView.hpp"
52#include "Kokkos_DualView.hpp"
53#include "Teuchos_TypeNameTraits.hpp"
54#include "Teuchos_Comm.hpp"
55#include "Teuchos_CommHelpers.hpp"
61std::string memorySpaceName (
const void* ptr);
83template<
class DataType,
class ... Properties>
88 const Kokkos::View<DataType, Properties...>& view)
90 using Teuchos::TypeNameTraits;
94 if (view.size () == 0) {
100 auto ptr = view.data ();
102 if (
ptr ==
nullptr) {
106 "of type " <<
viewName <<
" has nonzero size " << view.size ()
107 <<
" but a null pointer." <<
endl;
127 const Kokkos::DualView<DataType, Arg1Type, Arg2Type, Arg3Type>&
dv)
137 using Teuchos::TypeNameTraits;
140 Kokkos::DualView<DataType, Arg1Type, Arg2Type, Arg3Type>;
144 "of type " <<
dvName <<
" has one or more invalid Views. See "
145 "above error messages from this MPI process for details." <<
endl;
155checkGlobalDualViewValidity
157 const Kokkos::DualView<DataType, Arg1Type, Arg2Type, Arg3Type>&
dv,
159 const Teuchos::Comm<int>*
const comm)
162 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
171 catch (std::exception& e) {
172 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
173 "threw an exception: " << e.what () << endl;
177 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
178 "threw an exception not a subclass of std::exception." << endl;
183 if (comm ==
nullptr) {
184 gblSuccess = lclSuccess;
187 using Teuchos::outArg;
188 using Teuchos::REDUCE_MIN;
189 using Teuchos::reduceAll;
190 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
193 if (gblSuccess != 1 && gblErrStrm !=
nullptr) {
194 *gblErrStrm <<
"On at least one (MPI) process, the "
195 "Kokkos::DualView has "
196 "either the device or host pointer in the "
197 "DualView equal to null, but the DualView has a nonzero number of "
198 "rows. For more detailed information, please rerun with the "
199 "TPETRA_VERBOSE environment variable set to 1. ";
201 *gblErrStrm <<
" Here are error messages from all "
202 "processes:" << endl;
203 if (comm ==
nullptr) {
204 *gblErrStrm << lclErrStrm.str ();
213 return gblSuccess == 1;
220template<
class DataType ,
221 class Arg1Type = void ,
222 class Arg2Type = void ,
223 class Arg3Type =
void>
228 const Tpetra::Details::WrappedDualView<Kokkos::DualView<DataType, Arg1Type, Arg2Type, Arg3Type> >&
dv)
234 using Teuchos::TypeNameTraits;
237 Tpetra::Details::WrappedDualView<Kokkos::DualView<DataType, Arg1Type, Arg2Type, Arg3Type> >;
241 "of type " <<
dvName <<
" has one or more invalid Views. See "
242 "above error messages from this MPI process for details." <<
endl;
252checkGlobalWrappedDualViewValidity
254 const Tpetra::Details::WrappedDualView<Kokkos::DualView<DataType, Arg1Type, Arg2Type, Arg3Type> >&
dv,
256 const Teuchos::Comm<int>*
const comm)
259 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
268 catch (std::exception& e) {
269 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
270 "threw an exception: " << e.what () << endl;
274 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
275 "threw an exception not a subclass of std::exception." << endl;
280 if (comm ==
nullptr) {
281 gblSuccess = lclSuccess;
284 using Teuchos::outArg;
285 using Teuchos::REDUCE_MIN;
286 using Teuchos::reduceAll;
287 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
290 if (gblSuccess != 1 && gblErrStrm !=
nullptr) {
291 *gblErrStrm <<
"On at least one (MPI) process, the "
292 "Kokkos::DualView has "
293 "either the device or host pointer in the "
294 "DualView equal to null, but the DualView has a nonzero number of "
295 "rows. For more detailed information, please rerun with the "
296 "TPETRA_VERBOSE environment variable set to 1. ";
298 *gblErrStrm <<
" Here are error messages from all "
299 "processes:" << endl;
300 if (comm ==
nullptr) {
301 *gblErrStrm << lclErrStrm.str ();
310 return gblSuccess == 1;
Declaration of a function that prints strings from each process.
Struct that holds views of the contents of a CrsMatrix.
Implementation details of Tpetra.
bool checkLocalDualViewValidity(std::ostream *const lclErrStrm, const int myMpiProcessRank, const Kokkos::DualView< DataType, Arg1Type, Arg2Type, Arg3Type > &dv)
Is the given Kokkos::DualView valid?
bool checkLocalWrappedDualViewValidity(std::ostream *const lclErrStrm, const int myMpiProcessRank, const Tpetra::Details::WrappedDualView< Kokkos::DualView< DataType, Arg1Type, Arg2Type, Arg3Type > > &dv)
Is the given Tpetra::WrappedDualView valid?
bool checkLocalViewValidity(std::ostream *lclErrStrm, const int myMpiProcessRank, const Kokkos::View< DataType, Properties... > &view)
Is the given View 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.