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;
125 const Kokkos::DualView<DataType, Args...>&
dv)
135 using Teuchos::TypeNameTraits;
142 "of type " <<
dvName <<
" has one or more invalid Views. See "
143 "above error messages from this MPI process for details." <<
endl;
151checkGlobalDualViewValidity
153 const Kokkos::DualView<DataType, Args...>&
dv,
155 const Teuchos::Comm<int>*
const comm)
158 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
167 catch (std::exception& e) {
168 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
169 "threw an exception: " << e.what () << endl;
173 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
174 "threw an exception not a subclass of std::exception." << endl;
179 if (comm ==
nullptr) {
180 gblSuccess = lclSuccess;
183 using Teuchos::outArg;
184 using Teuchos::REDUCE_MIN;
185 using Teuchos::reduceAll;
186 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
189 if (gblSuccess != 1 && gblErrStrm !=
nullptr) {
190 *gblErrStrm <<
"On at least one (MPI) process, the "
191 "Kokkos::DualView has "
192 "either the device or host pointer in the "
193 "DualView equal to null, but the DualView has a nonzero number of "
194 "rows. For more detailed information, please rerun with the "
195 "TPETRA_VERBOSE environment variable set to 1. ";
197 *gblErrStrm <<
" Here are error messages from all "
198 "processes:" << endl;
199 if (comm ==
nullptr) {
200 *gblErrStrm << lclErrStrm.str ();
209 return gblSuccess == 1;
216template<
class DataType ,
228 using Teuchos::TypeNameTraits;
235 "of type " <<
dvName <<
" has one or more invalid Views. See "
236 "above error messages from this MPI process for details." <<
endl;
244checkGlobalWrappedDualViewValidity
248 const Teuchos::Comm<int>*
const comm)
251 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
260 catch (std::exception& e) {
261 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
262 "threw an exception: " << e.what () << endl;
266 lclErrStrm <<
"Proc " << myRank <<
": checkLocalDualViewValidity "
267 "threw an exception not a subclass of std::exception." << endl;
272 if (comm ==
nullptr) {
273 gblSuccess = lclSuccess;
276 using Teuchos::outArg;
277 using Teuchos::REDUCE_MIN;
278 using Teuchos::reduceAll;
279 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
282 if (gblSuccess != 1 && gblErrStrm !=
nullptr) {
283 *gblErrStrm <<
"On at least one (MPI) process, the "
284 "Kokkos::DualView has "
285 "either the device or host pointer in the "
286 "DualView equal to null, but the DualView has a nonzero number of "
287 "rows. For more detailed information, please rerun with the "
288 "TPETRA_VERBOSE environment variable set to 1. ";
290 *gblErrStrm <<
" Here are error messages from all "
291 "processes:" << endl;
292 if (comm ==
nullptr) {
293 *gblErrStrm << lclErrStrm.str ();
302 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.