45#ifndef TPETRA_MAP_DEF_HPP
46#define TPETRA_MAP_DEF_HPP
48#include "Tpetra_Directory.hpp"
50#include "Tpetra_Details_FixedHashTable.hpp"
55#include "Teuchos_as.hpp"
56#include "Teuchos_TypeNameTraits.hpp"
57#include "Teuchos_CommHelpers.hpp"
58#include "Tpetra_Details_mpiIsInitialized.hpp"
68 template<
class ExecutionSpace>
70 checkMapInputArray (
const char ctorName[],
71 const void* indexList,
72 const size_t indexListSize,
73 const ExecutionSpace& execSpace,
74 const Teuchos::Comm<int>*
const comm)
78 const bool debug = Behavior::debug(
"Map");
80 using Teuchos::outArg;
81 using Teuchos::REDUCE_MIN;
82 using Teuchos::reduceAll;
85 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
86 const bool verbose = Behavior::verbose(
"Map");
87 std::ostringstream lclErrStrm;
90 if (indexListSize != 0 && indexList ==
nullptr) {
93 lclErrStrm <<
"Proc " << myRank <<
": indexList is null, "
94 "but indexListSize=" << indexListSize <<
" != 0." << endl;
98 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
99 if (gblSuccess != 1) {
100 std::ostringstream gblErrStrm;
101 gblErrStrm <<
"Tpetra::Map constructor " << ctorName <<
102 " detected a problem with the input array "
103 "(raw array, Teuchos::ArrayView, or Kokkos::View) "
104 "of global indices." << endl;
106 using ::Tpetra::Details::gathervPrint;
109 TEUCHOS_TEST_FOR_EXCEPTION
110 (
true, std::invalid_argument, gblErrStrm.str ());
118 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
123 numGlobalElements_ (0),
124 numLocalElements_ (0),
133 distributed_ (
false),
140 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
151 using Teuchos::broadcast;
152 using Teuchos::outArg;
153 using Teuchos::reduceAll;
154 using Teuchos::REDUCE_MIN;
155 using Teuchos::REDUCE_MAX;
156 using Teuchos::typeName;
160 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
161 const char funcName[] =
"Map(gblNumInds,indexBase,comm,LG)";
163 "Tpetra::Map::Map(gblNumInds,indexBase,comm,LG): ";
167 std::unique_ptr<std::string>
prefix;
170 comm_.getRawPtr(),
"Map",
funcName);
171 std::ostringstream
os;
173 std::cerr <<
os.str();
191 std::invalid_argument,
exPfx <<
"All processes must "
192 "provide the same number of global elements. Process 0 set "
194 "calling process " << comm->getRank() <<
" set "
196 "and max values over all processes are "
208 std::invalid_argument,
exPfx <<
"All processes must "
209 "provide the same indexBase argument. Process 0 set "
211 << comm->getRank() <<
" set indexBase=" <<
indexBase
212 <<
". The min and max values over all processes are "
235 std::invalid_argument,
exPfx <<
"numGlobalElements (= "
240 "You provided numGlobalElements = Teuchos::OrdinalTraits<"
241 "Tpetra::global_size_t>::invalid(). This version of the "
242 "constructor requires a valid value of numGlobalElements. "
243 "You probably mistook this constructor for the \"contiguous "
244 "nonuniform\" constructor, which can compute the global "
245 "number of elements for you if you set numGlobalElements to "
246 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid().");
249 if (
lOrG == GloballyDistributed) {
265 const GST myRank =
static_cast<GST> (comm_->getRank ());
291 distributed_ =
false;
299 firstContiguousGID_ = minMyGID_;
300 lastContiguousGID_ = maxMyGID_;
307 std::ostringstream
os;
309 std::cerr <<
os.str();
314 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
319 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) :
325 using Teuchos::broadcast;
326 using Teuchos::outArg;
327 using Teuchos::reduceAll;
328 using Teuchos::REDUCE_MIN;
329 using Teuchos::REDUCE_MAX;
330 using Teuchos::REDUCE_SUM;
335 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
337 "Map(gblNumInds,lclNumInds,indexBase,comm)";
339 "Tpetra::Map::Map(gblNumInds,lclNumInds,indexBase,comm): ";
341 ". Please report this bug to the Tpetra developers.";
345 std::unique_ptr<std::string>
prefix;
348 comm_.getRawPtr(),
"Map",
funcName);
349 std::ostringstream
os;
351 std::cerr <<
os.str();
359 debugGlobalSum = initialNonuniformDebugCheck(exPfx,
360 numGlobalElements, numLocalElements, indexBase, comm);
375 scan<int, GO> (*comm, REDUCE_SUM, numLocalElements, outArg (scanResult));
386 const int numProcs = comm->getSize ();
391 numGlobalElements_ = globalSum;
395 TEUCHOS_TEST_FOR_EXCEPTION
396 (globalSum != debugGlobalSum, std::logic_error, exPfx <<
397 "globalSum = " << globalSum <<
" != debugGlobalSum = " <<
398 debugGlobalSum << suffix);
401 numLocalElements_ = numLocalElements;
402 indexBase_ = indexBase;
403 minAllGID_ = (numGlobalElements_ == 0) ?
404 std::numeric_limits<GO>::max () :
406 maxAllGID_ = (numGlobalElements_ == 0) ?
407 std::numeric_limits<GO>::lowest () :
408 indexBase + GO(numGlobalElements_) - GO(1);
409 minMyGID_ = (numLocalElements_ == 0) ?
410 std::numeric_limits<GO>::max () :
411 indexBase + GO(myOffset);
412 maxMyGID_ = (numLocalElements_ == 0) ?
413 std::numeric_limits<GO>::lowest () :
414 indexBase + myOffset + GO(numLocalElements) - GO(1);
415 firstContiguousGID_ = minMyGID_;
416 lastContiguousGID_ = maxMyGID_;
418 distributed_ = checkIsDist ();
424 std::ostringstream
os;
426 std::cerr <<
os.str();
430 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
432 Map<LocalOrdinal,GlobalOrdinal,Node>::
433 initialNonuniformDebugCheck(
434 const char errorMessagePrefix[],
436 const size_t numLocalElements,
437 const global_ordinal_type indexBase,
438 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
const
445 using Teuchos::broadcast;
446 using Teuchos::outArg;
448 using Teuchos::REDUCE_MAX;
449 using Teuchos::REDUCE_MIN;
450 using Teuchos::REDUCE_SUM;
451 using Teuchos::reduceAll;
452 using GO = global_ordinal_type;
454 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
464 GST debugGlobalSum = 0;
465 reduceAll<int, GST> (*comm, REDUCE_SUM,
static_cast<GST
> (numLocalElements),
466 outArg (debugGlobalSum));
482 "must provide the same number of global elements, even if "
484 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() "
485 "(which signals that the Map should compute the global "
486 "number of elements). Process 0 set numGlobalElements"
488 << comm->getRank() <<
" set numGlobalElements=" <<
502 "All processes must provide the same indexBase argument. "
504 "calling process " << comm->getRank() <<
" set indexBase="
505 <<
indexBase <<
". The min and max values over all "
517 "would like this constructor to compute numGlobalElements "
518 "for you, you may set numGlobalElements="
519 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() "
520 "on input. Please note that this is NOT necessarily -1.");
525 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
527 Map<LocalOrdinal,GlobalOrdinal,Node>::
528 initWithNonownedHostIndexList(
529 const char errorMessagePrefix[],
531 const Kokkos::View<
const global_ordinal_type*,
536 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
538 using Kokkos::LayoutLeft;
539 using Kokkos::subview;
541 using Kokkos::view_alloc;
542 using Kokkos::WithoutInitializing;
544 using Teuchos::broadcast;
545 using Teuchos::outArg;
547 using Teuchos::REDUCE_MAX;
548 using Teuchos::REDUCE_MIN;
549 using Teuchos::REDUCE_SUM;
550 using Teuchos::reduceAll;
554 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
558 (! Kokkos::is_initialized (), std::runtime_error,
560 << Teuchos::TypeNameTraits<execution_space>::name()
561 <<
" has not been initialized. "
562 "Please initialize it before creating a Map.")
594 outArg(numGlobalElements_));
620 numLocalElements_ = numLocalElements;
621 indexBase_ = indexBase;
623 minMyGID_ = indexBase_;
624 maxMyGID_ = indexBase_;
634 if (numLocalElements_ > 0) {
638 typename decltype (lgMap_)::non_const_type lgMap
639 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
641 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
649 firstContiguousGID_ = entryList_host[0];
650 lastContiguousGID_ = firstContiguousGID_+1;
658 lgMap_host[0] = firstContiguousGID_;
660 for ( ; i < numLocalElements_; ++i) {
661 const GO curGid = entryList_host[i];
662 const LO curLid = as<LO> (i);
664 if (lastContiguousGID_ != curGid)
break;
670 lgMap_host[curLid] = curGid;
671 ++lastContiguousGID_;
673 --lastContiguousGID_;
678 minMyGID_ = firstContiguousGID_;
679 maxMyGID_ = lastContiguousGID_;
689 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
690 "nonContigGids_host.extent(0) = "
692 <<
" != entryList_host.extent(0) - i = "
695 <<
". Please report this bug to the Tpetra developers.");
707 static_cast<LO
> (
i));
717 for ( ;
i < numLocalElements_; ++
i) {
719 const LO
curLid =
static_cast<LO
> (
i);
733 Kokkos::deep_copy (lgMap, lgMap_host);
738 lgMapHost_ = lgMap_host;
741 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
742 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
746 firstContiguousGID_ = indexBase_+1;
747 lastContiguousGID_ = indexBase_;
772 if (std::numeric_limits<GO>::is_signed) {
775 (
as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
790 distributed_ = (comm_->getSize () > 1 &&
globalDist == 1);
796 distributed_ = checkIsDist ();
802 minAllGID_ < indexBase_,
803 std::invalid_argument,
804 "Tpetra::Map constructor (noncontiguous): "
805 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
806 "less than the given indexBase = " << indexBase_ <<
".");
812 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
818 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
825 "Map(gblNumInds,indexList,indexListSize,indexBase,comm)";
831 comm_.getRawPtr(),
"Map",
funcName);
832 std::ostringstream
os;
834 std::cerr <<
os.str();
839 Kokkos::DefaultHostExecutionSpace (),
852 std::ostringstream
os;
854 std::cerr <<
os.str();
858 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
861 const Teuchos::ArrayView<const GlobalOrdinal>&
entryList,
863 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
870 "Map(gblNumInds,entryList(Teuchos::ArrayView),indexBase,comm)";
872 const bool verbose = Details::Behavior::verbose(
"Map");
873 std::unique_ptr<std::string>
prefix;
875 prefix = Details::createPrefix(
876 comm_.getRawPtr(),
"Map",
funcName);
877 std::ostringstream
os;
879 std::cerr <<
os.str();
885 Kokkos::DefaultHostExecutionSpace (),
899 std::ostringstream
os;
901 std::cerr <<
os.str();
905 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
908 const Kokkos::View<const GlobalOrdinal*, device_type>&
entryList,
910 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
915 using Kokkos::LayoutLeft;
916 using Kokkos::subview;
918 using Kokkos::view_alloc;
919 using Kokkos::WithoutInitializing;
921 using Teuchos::ArrayView;
923 using Teuchos::broadcast;
924 using Teuchos::outArg;
926 using Teuchos::REDUCE_MAX;
927 using Teuchos::REDUCE_MIN;
928 using Teuchos::REDUCE_SUM;
929 using Teuchos::reduceAll;
930 using Teuchos::typeName;
935 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
937 "Map(gblNumInds,entryList(Kokkos::View),indexBase,comm)";
940 std::unique_ptr<std::string>
prefix;
943 comm_.getRawPtr(),
"Map",
funcName);
944 std::ostringstream
os;
946 std::cerr <<
os.str();
984 outArg(numGlobalElements_));
1013 minMyGID_ = indexBase_;
1014 maxMyGID_ = indexBase_;
1024 if (numLocalElements_ > 0) {
1028 typename decltype (lgMap_)::non_const_type
lgMap
1031 Kokkos::create_mirror_view (Kokkos::HostSpace (),
lgMap);
1033 using array_layout =
1041 lastContiguousGID_ = firstContiguousGID_+1;
1051 for ( ;
i < numLocalElements_; ++
i) {
1055 if (lastContiguousGID_ !=
curGid)
break;
1062 ++lastContiguousGID_;
1064 --lastContiguousGID_;
1069 minMyGID_ = firstContiguousGID_;
1070 maxMyGID_ = lastContiguousGID_;
1079 static_cast<size_t> (
entryList.extent (0) -
i),
1080 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
1081 "nonContigGids.extent(0) = "
1083 <<
" != entryList.extent(0) - i = "
1086 <<
". Please report this bug to the Tpetra developers.");
1089 firstContiguousGID_,
1091 static_cast<LO
> (
i));
1101 for ( ;
i < numLocalElements_; ++
i) {
1103 const LO
curLid =
static_cast<LO
> (
i);
1108 if (
curGid < minMyGID_) {
1111 if (curGid > maxMyGID_) {
1117 Kokkos::deep_copy (lgMap, lgMap_host);
1122 lgMapHost_ = lgMap_host;
1125 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
1126 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
1130 firstContiguousGID_ = indexBase_+1;
1131 lastContiguousGID_ = indexBase_;
1156 if (std::numeric_limits<GO>::is_signed) {
1158 const GO localDist =
1159 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
1162 minMaxInput[0] = -minMyGID_;
1163 minMaxInput[1] = maxMyGID_;
1164 minMaxInput[2] = localDist;
1167 minMaxOutput[0] = 0;
1168 minMaxOutput[1] = 0;
1169 minMaxOutput[2] = 0;
1170 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
1171 minAllGID_ = -minMaxOutput[0];
1172 maxAllGID_ = minMaxOutput[1];
1173 const GO globalDist = minMaxOutput[2];
1174 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
1178 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
1179 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
1180 distributed_ = checkIsDist ();
1183 contiguous_ =
false;
1185 TEUCHOS_TEST_FOR_EXCEPTION(
1186 minAllGID_ < indexBase_,
1187 std::invalid_argument,
1188 "Tpetra::Map constructor (noncontiguous): "
1189 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
1190 "less than the given indexBase = " << indexBase_ <<
".");
1196 std::ostringstream os;
1197 os << *prefix <<
"Done" << endl;
1198 std::cerr << os.str();
1203 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1206 if (! Kokkos::is_initialized ()) {
1207 std::ostringstream
os;
1208 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1209 "Kokkos::finalize() has been called. This is user error! There are "
1210 "two likely causes: " << std::endl <<
1211 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1213 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1214 "of a Tpetra::Map) at the same scope in main() as Kokkos::finalize() "
1215 "or Tpetra::finalize()." << std::endl << std::endl <<
1216 "Don't do either of these! Please refer to GitHib Issue #2372."
1219 this->getComm ().getRawPtr ());
1222 using ::Tpetra::Details::mpiIsInitialized;
1223 using ::Tpetra::Details::mpiIsFinalized;
1224 using ::Tpetra::Details::teuchosCommIsAnMpiComm;
1226 Teuchos::RCP<const Teuchos::Comm<int> > comm = this->getComm ();
1227 if (! comm.is_null () && teuchosCommIsAnMpiComm (*comm) &&
1228 mpiIsInitialized () && mpiIsFinalized ()) {
1234 std::ostringstream
os;
1235 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1236 "MPI_Finalize() has been called. This is user error! There are "
1237 "two likely causes: " << std::endl <<
1238 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1240 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1241 "of a Tpetra::Map) at the same scope in main() as MPI_finalize() or "
1242 "Tpetra::finalize()." << std::endl << std::endl <<
1243 "Don't do either of these! Please refer to GitHib Issue #2372."
1253 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1258 getComm ().
is_null (), std::logic_error,
"Tpetra::Map::isOneToOne: "
1259 "getComm() returns null. Please report this bug to the Tpetra "
1264 return directory_->isOneToOne (*
this);
1267 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1272 if (isContiguous ()) {
1275 return Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1291 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1297 return Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
1299 if (isContiguous ()) {
1311 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1323 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1328 Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1331 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1336 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1342 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1348 getMinGlobalIndex (), getMaxGlobalIndex (),
1349 firstContiguousGID_, lastContiguousGID_,
1350 getNodeNumElements (), isContiguous ());
1353 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1358 using Teuchos::outArg;
1359 using Teuchos::REDUCE_MIN;
1360 using Teuchos::reduceAll;
1370 else if (getComm ()->getSize () !=
map.getComm ()->getSize ()) {
1376 else if (getGlobalNumElements () !=
map.getGlobalNumElements ()) {
1381 else if (isContiguous () && isUniform () &&
1382 map.isContiguous () &&
map.isUniform ()) {
1388 else if (! isContiguous () && !
map.isContiguous () &&
1389 lgMap_.extent (0) != 0 &&
map.lgMap_.extent (0) != 0 &&
1390 lgMap_.data () ==
map.lgMap_.data ()) {
1405 getGlobalNumElements () !=
map.getGlobalNumElements (), std::logic_error,
1406 "Tpetra::Map::isCompatible: There's a bug in this method. We've already "
1407 "checked that this condition is true above, but it's false here. "
1408 "Please report this bug to the Tpetra developers.");
1412 (getNodeNumElements () ==
map.getNodeNumElements ()) ? 1 : 0;
1419 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1424 using Teuchos::ArrayView;
1441 else if (getNodeNumElements () !=
map.getNodeNumElements ()) {
1444 else if (getMinGlobalIndex () !=
map.getMinGlobalIndex () ||
1445 getMaxGlobalIndex () !=
map.getMaxGlobalIndex ()) {
1449 if (isContiguous ()) {
1450 if (
map.isContiguous ()) {
1455 ! this->isContiguous () ||
map.isContiguous (), std::logic_error,
1456 "Tpetra::Map::locallySameAs: BUG");
1458 const GO
minLhsGid = this->getMinGlobalIndex ();
1469 else if (
map.isContiguous ()) {
1471 this->isContiguous () || !
map.isContiguous (), std::logic_error,
1472 "Tpetra::Map::locallySameAs: BUG");
1484 else if (this->lgMap_.data () ==
map.lgMap_.data ()) {
1487 return this->getNodeNumElements () ==
map.getNodeNumElements ();
1490 if (this->getNodeNumElements () !=
map.getNodeNumElements ()) {
1506 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1516 auto lmap2 = this->getLocalMap();
1526 if (
lmap1.isContiguous () &&
lmap2.isContiguous ()) {
1528 return ((
lmap1.getMinGlobalIndex () ==
lmap2.getMinGlobalIndex ()) &&
1529 (
lmap1.getMaxGlobalIndex () <=
lmap2.getMaxGlobalIndex ()));
1532 if (
lmap1.getMinGlobalIndex () <
lmap2.getMinGlobalIndex () ||
1533 lmap1.getMaxGlobalIndex () >
lmap2.getMaxGlobalIndex ()) {
1541 Kokkos::RangePolicy<LO, typename node_type::execution_space>;
1545 Kokkos::parallel_reduce(
1555 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1560 using Teuchos::outArg;
1561 using Teuchos::REDUCE_MIN;
1562 using Teuchos::reduceAll;
1572 else if (getComm ()->getSize () !=
map.getComm ()->getSize ()) {
1578 else if (getGlobalNumElements () !=
map.getGlobalNumElements ()) {
1583 else if (getMinAllGlobalIndex () !=
map.getMinAllGlobalIndex () ||
1584 getMaxAllGlobalIndex () !=
map.getMaxAllGlobalIndex () ||
1585 getIndexBase () !=
map.getIndexBase ()) {
1590 else if (isDistributed () !=
map.isDistributed ()) {
1595 else if (isContiguous () && isUniform () &&
1596 map.isContiguous () &&
map.isUniform ()) {
1625 template <
class LO,
class GO,
class DT>
1628 FillLgMap (
const Kokkos::View<GO*, DT>&
lgMap,
1632 Kokkos::RangePolicy<LO, typename DT::execution_space>
1633 range (
static_cast<LO
> (0),
static_cast<LO
> (
lgMap.size ()));
1634 Kokkos::parallel_for (
range, *
this);
1637 KOKKOS_INLINE_FUNCTION
void operator () (
const LO& lid)
const {
1638 lgMap_(lid) = startGid_ +
static_cast<GO
> (lid);
1642 const Kokkos::View<GO*, DT> lgMap_;
1649 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1650 typename Map<LocalOrdinal,GlobalOrdinal,Node>::global_indices_array_type
1657 using lg_view_type =
typename const_lg_view_type::non_const_type;
1661 std::unique_ptr<std::string>
prefix;
1664 comm_.getRawPtr(),
"Map",
"getMyGlobalIndices");
1665 std::ostringstream
os;
1667 std::cerr <<
os.str();
1674 lgMap_.extent (0) == 0 && numLocalElements_ > 0;
1678 std::ostringstream
os;
1680 std::cerr <<
os.str();
1686 (! isContiguous(), std::logic_error,
1687 "Tpetra::Map::getMyGlobalIndices: The local-to-global "
1688 "mapping (lgMap_) should have been set up already for a "
1689 "noncontiguous Map. Please report this bug to the Tpetra "
1692 const LO
numElts =
static_cast<LO
> (getNodeNumElements ());
1694 using Kokkos::view_alloc;
1695 using Kokkos::WithoutInitializing;
1698 std::ostringstream
os;
1700 std::cerr <<
os.str();
1705 std::ostringstream
os;
1707 std::cerr <<
os.str();
1711 Kokkos::create_mirror_view (Kokkos::HostSpace (),
lgMap);
1720 std::ostringstream
os;
1722 std::cerr <<
os.str();
1727 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1728 Teuchos::ArrayView<const GlobalOrdinal>
1736 (
void) this->getMyGlobalIndices ();
1743 return Teuchos::ArrayView<const GO>(
1745 lgMapHost_.extent (0),
1746 Teuchos::RCP_DISABLE_NODE_LOOKUP);
1749 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1751 return distributed_;
1754 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1756 using Teuchos::TypeNameTraits;
1757 std::ostringstream
os;
1759 os <<
"Tpetra::Map: {"
1766 os <<
", Global number of entries: " << getGlobalNumElements ()
1767 <<
", Number of processes: " << getComm ()->getSize ()
1768 <<
", Uniform: " << (isUniform () ?
"true" :
"false")
1769 <<
", Contiguous: " << (isContiguous () ?
"true" :
"false")
1770 <<
", Distributed: " << (isDistributed () ?
"true" :
"false")
1779 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1784 using LO = local_ordinal_type;
1788 if (
vl < Teuchos::VERB_HIGH) {
1789 return std::string ();
1791 auto outStringP = Teuchos::rcp (
new std::ostringstream ());
1792 Teuchos::RCP<Teuchos::FancyOStream> outp =
1793 Teuchos::getFancyOStream (outStringP);
1794 Teuchos::FancyOStream& out = *outp;
1796 auto comm = this->getComm ();
1797 const int myRank = comm->getRank ();
1798 const int numProcs = comm->getSize ();
1799 out <<
"Process " << myRank <<
" of " << numProcs <<
":" << endl;
1800 Teuchos::OSTab tab1 (out);
1802 const LO numEnt =
static_cast<LO
> (this->getNodeNumElements ());
1803 out <<
"My number of entries: " << numEnt << endl
1804 <<
"My minimum global index: " << this->getMinGlobalIndex () << endl
1805 <<
"My maximum global index: " << this->getMaxGlobalIndex () << endl;
1807 if (vl == Teuchos::VERB_EXTREME) {
1808 out <<
"My global indices: [";
1809 const LO minLclInd = this->getMinLocalIndex ();
1810 for (LO k = 0; k < numEnt; ++k) {
1811 out << minLclInd + this->getGlobalElement (k);
1812 if (k + 1 < numEnt) {
1820 return outStringP->str ();
1823 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1827 const Teuchos::EVerbosityLevel
verbLevel)
const
1829 using Teuchos::TypeNameTraits;
1830 using Teuchos::VERB_DEFAULT;
1831 using Teuchos::VERB_NONE;
1832 using Teuchos::VERB_LOW;
1833 using Teuchos::VERB_HIGH;
1837 const Teuchos::EVerbosityLevel
vl =
1847 auto comm = this->getComm ();
1848 if (comm.is_null ()) {
1851 const int myRank = comm->getRank ();
1852 const int numProcs = comm->getSize ();
1861 Teuchos::RCP<Teuchos::OSTab>
tab0,
tab1;
1867 tab0 = Teuchos::rcp (
new Teuchos::OSTab (
out));
1868 out <<
"\"Tpetra::Map\":" <<
endl;
1869 tab1 = Teuchos::rcp (
new Teuchos::OSTab (
out));
1871 out <<
"Template parameters:" <<
endl;
1881 out <<
"Global number of entries: " << getGlobalNumElements () <<
endl
1882 <<
"Minimum global index: " << getMinAllGlobalIndex () <<
endl
1883 <<
"Maximum global index: " << getMaxAllGlobalIndex () <<
endl
1884 <<
"Index base: " << getIndexBase () <<
endl
1886 <<
"Uniform: " << (isUniform () ?
"true" :
"false") <<
endl
1887 <<
"Contiguous: " << (isContiguous () ?
"true" :
"false") <<
endl
1888 <<
"Distributed: " << (isDistributed () ?
"true" :
"false") <<
endl;
1893 const std::string
lclStr = this->localDescribeToString (
vl);
1898 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1899 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1918 return Teuchos::null;
1920 else if (
newComm->getSize () == 1) {
1931 newMap->indexBase_ = this->indexBase_;
1932 newMap->numGlobalElements_ = this->numLocalElements_;
1933 newMap->numLocalElements_ = this->numLocalElements_;
1934 newMap->minMyGID_ = this->minMyGID_;
1935 newMap->maxMyGID_ = this->maxMyGID_;
1936 newMap->minAllGID_ = this->minMyGID_;
1937 newMap->maxAllGID_ = this->maxMyGID_;
1938 newMap->firstContiguousGID_ = this->firstContiguousGID_;
1939 newMap->lastContiguousGID_ = this->lastContiguousGID_;
1942 newMap->uniform_ = this->uniform_;
1943 newMap->contiguous_ = this->contiguous_;
1946 newMap->distributed_ =
false;
1947 newMap->lgMap_ = this->lgMap_;
1948 newMap->lgMapHost_ = this->lgMapHost_;
1949 newMap->glMap_ = this->glMap_;
1950 newMap->glMapHost_ = this->glMapHost_;
1971 const GST RECOMPUTE = Tpetra::Details::OrdinalTraits<GST>::invalid ();
1987 auto lgMap = this->getMyGlobalIndices ();
1989 typename std::decay<
decltype (
lgMap.extent (0)) >::type;
1991 static_cast<size_type
> (this->getNodeNumElements ());
1992 using Teuchos::TypeNameTraits;
1995 "Tpetra::Map::replaceCommWithSubset: Result of getMyGlobalIndices() "
1996 "has length " <<
lgMap.extent (0) <<
" (of type " <<
1998 " = " <<
this->getNodeNumElements () <<
". The latter, upon being "
2000 "becomes " <<
lclNumInds <<
". Please report this bug to the Tpetra "
2003 Teuchos::ArrayView<const GO>
lgMap = this->getNodeElementList ();
2006 const GO
indexBase = this->getIndexBase ();
2013 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2014 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
2018 using Teuchos::Comm;
2019 using Teuchos::null;
2020 using Teuchos::outArg;
2023 using Teuchos::REDUCE_MIN;
2024 using Teuchos::reduceAll;
2031 const int color = (numLocalElements_ == 0) ? 0 : 1;
2048 map->indexBase_ = indexBase_;
2049 map->numGlobalElements_ = numGlobalElements_;
2050 map->numLocalElements_ = numLocalElements_;
2051 map->minMyGID_ = minMyGID_;
2052 map->maxMyGID_ = maxMyGID_;
2053 map->minAllGID_ = minAllGID_;
2054 map->maxAllGID_ = maxAllGID_;
2055 map->firstContiguousGID_= firstContiguousGID_;
2056 map->lastContiguousGID_ = lastContiguousGID_;
2060 map->uniform_ = uniform_;
2061 map->contiguous_ = contiguous_;
2076 if (! distributed_ ||
newComm->getSize () == 1) {
2077 map->distributed_ =
false;
2079 const int iOwnAllGids = (numLocalElements_ == numGlobalElements_) ? 1 : 0;
2085 map->lgMap_ = lgMap_;
2086 map->lgMapHost_ = lgMapHost_;
2087 map->glMap_ = glMap_;
2088 map->glMapHost_ = glMapHost_;
2105 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2110 directory_.is_null (), std::logic_error,
"Tpetra::Map::setupDirectory: "
2111 "The Directory is null. "
2112 "Please report this bug to the Tpetra developers.");
2116 if (! directory_->initialized ()) {
2117 directory_->initialize (*
this);
2121 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2125 const Teuchos::ArrayView<int>&
PIDs,
2126 const Teuchos::ArrayView<LocalOrdinal>&
LIDs)
const
2128 using Tpetra::Details::OrdinalTraits;
2131 using size_type = Teuchos::ArrayView<int>::size_type;
2136 std::unique_ptr<std::string>
prefix;
2139 "Map",
"getRemoteIndexList(GIDs,PIDs,LIDs)");
2140 std::ostringstream
os;
2144 std::cerr <<
os.str();
2153 if (getGlobalNumElements () == 0) {
2154 if (
GIDs.size () == 0) {
2156 std::ostringstream
os;
2157 os << *
prefix <<
"Done; both Map & input are empty" <<
endl;
2158 std::cerr <<
os.str();
2164 std::ostringstream
os;
2165 os << *
prefix <<
"Done: Map is empty on all processes, "
2166 "so all output PIDs & LIDs are invalid (-1)." <<
endl;
2167 std::cerr <<
os.str();
2169 for (size_type
k = 0;
k <
PIDs.size (); ++
k) {
2172 for (size_type
k = 0;
k <
LIDs.size (); ++
k) {
2184 std::ostringstream
os;
2186 std::cerr <<
os.str();
2190 std::ostringstream
os;
2191 os << *
prefix <<
"Call directory_->getDirectoryEntries" <<
endl;
2192 std::cerr <<
os.str();
2195 directory_->getDirectoryEntries (*
this,
GIDs,
PIDs,
LIDs);
2197 std::ostringstream
os;
2198 os << *
prefix <<
"Done; getDirectoryEntries returned "
2205 std::cerr <<
os.str();
2210 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2214 const Teuchos::ArrayView<int> &
PIDs)
const
2222 std::unique_ptr<std::string>
prefix;
2225 "Map",
"getRemoteIndexList(GIDs,PIDs)");
2226 std::ostringstream
os;
2230 std::cerr <<
os.str();
2233 if (getGlobalNumElements () == 0) {
2234 if (
GIDs.size () == 0) {
2236 std::ostringstream
os;
2237 os << *
prefix <<
"Done; both Map & input are empty" <<
endl;
2238 std::cerr <<
os.str();
2244 std::ostringstream
os;
2245 os << *
prefix <<
"Done: Map is empty on all processes, "
2246 "so all output PIDs are invalid (-1)." <<
endl;
2247 std::cerr <<
os.str();
2249 for (Teuchos::ArrayView<int>::size_type
k = 0;
k <
PIDs.size (); ++
k) {
2250 PIDs[
k] = Tpetra::Details::OrdinalTraits<int>::invalid ();
2261 std::ostringstream
os;
2263 std::cerr <<
os.str();
2267 std::ostringstream
os;
2268 os << *
prefix <<
"Call directory_->getDirectoryEntries" <<
endl;
2269 std::cerr <<
os.str();
2272 directory_->getDirectoryEntries(*
this,
GIDs,
PIDs);
2274 std::ostringstream
os;
2275 os << *
prefix <<
"Done; getDirectoryEntries returned "
2280 std::cerr <<
os.str();
2285 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2286 Teuchos::RCP<const Teuchos::Comm<int> >
2291 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2297 using Teuchos::outArg;
2298 using Teuchos::REDUCE_MIN;
2299 using Teuchos::reduceAll;
2303 std::unique_ptr<std::string>
prefix;
2306 comm_.getRawPtr(),
"Map",
"checkIsDist");
2307 std::ostringstream
os;
2309 std::cerr <<
os.str();
2312 bool global =
false;
2313 if (comm_->getSize () > 1) {
2317 if (numGlobalElements_ == as<global_size_t> (numLocalElements_)) {
2330 reduceAll<int, int> (*comm_, REDUCE_MIN, localRep, outArg (allLocalRep));
2331 if (allLocalRep != 1) {
2341 std::ostringstream os;
2342 os << *prefix <<
"Done; global=" << (global ?
"true" :
"false")
2344 std::cerr << os.str();
2351template <
class LocalOrdinal,
class GlobalOrdinal>
2352Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2354 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2356 typedef LocalOrdinal LO;
2357 typedef GlobalOrdinal GO;
2358 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2359 return createLocalMapWithNode<LO, GO, NT> (numElements, comm);
2362template <
class LocalOrdinal,
class GlobalOrdinal>
2363Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2365 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2367 typedef LocalOrdinal LO;
2368 typedef GlobalOrdinal GO;
2369 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2370 return createUniformContigMapWithNode<LO, GO, NT> (numElements, comm);
2373template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2374Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2376 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2381 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2383 return rcp (
new map_type (numElements, indexBase, comm, GloballyDistributed));
2386template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2387Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2389 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2395 const GlobalOrdinal indexBase = 0;
2398 return rcp (
new map_type (globalNumElts, indexBase, comm, LocallyReplicated));
2401template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2402Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2404 const size_t localNumElements,
2405 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2410 const GlobalOrdinal indexBase = 0;
2412 return rcp (
new map_type (numElements, localNumElements, indexBase, comm));
2415template <
class LocalOrdinal,
class GlobalOrdinal>
2416Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2418 const size_t localNumElements,
2419 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2421 typedef LocalOrdinal LO;
2422 typedef GlobalOrdinal GO;
2428template <
class LocalOrdinal,
class GlobalOrdinal>
2429Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2431 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2433 typedef LocalOrdinal LO;
2434 typedef GlobalOrdinal GO;
2440template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2441Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2443 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2449 const GST INV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2453 const GlobalOrdinal indexBase = 0;
2455 return rcp (
new map_type (INV, elementList, indexBase, comm));
2458template<
class LO,
class GO,
class NT>
2459Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >
2462 using Details::verbosePrintArray;
2463 using Teuchos::Array;
2464 using Teuchos::ArrayView;
2472 const bool verbose = Details::Behavior::verbose(
"Map");
2473 std::unique_ptr<std::string> prefix;
2475 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2476 prefix = Details::createPrefix(
2477 comm.getRawPtr(),
"createOneToOne(Map)");
2478 std::ostringstream os;
2479 os << *prefix <<
"Start" << endl;
2482 const size_t maxNumToPrint = verbose ?
2483 Details::Behavior::verbosePrintCountThreshold() : size_t(0);
2484 const GST GINV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2485 const int myRank = M->getComm ()->getRank ();
2491 if (! M->isDistributed ()) {
2498 const GST numGlobalEntries = M->getGlobalNumElements ();
2499 if (M->isContiguous()) {
2500 const size_t numLocalEntries =
2501 (myRank == 0) ? as<size_t>(numGlobalEntries) : size_t(0);
2503 std::ostringstream os;
2504 os << *prefix <<
"Input is locally replicated & contiguous; "
2505 "numLocalEntries=" << numLocalEntries << endl;
2509 rcp(
new map_type(numGlobalEntries, numLocalEntries,
2510 M->getIndexBase(), M->getComm()));
2512 std::ostringstream os;
2513 os << *prefix <<
"Done" << endl;
2520 std::ostringstream os;
2521 os << *prefix <<
"Input is locally replicated & noncontiguous"
2525 ArrayView<const GO> myGids =
2526 (myRank == 0) ? M->getNodeElementList() : Teuchos::null;
2528 rcp(
new map_type(GINV, myGids(), M->getIndexBase(),
2531 std::ostringstream os;
2532 os << *prefix <<
"Done" << endl;
2538 else if (M->isContiguous ()) {
2540 std::ostringstream os;
2541 os << *prefix <<
"Input is distributed & contiguous" << endl;
2550 std::ostringstream os;
2551 os << *prefix <<
"Input is distributed & noncontiguous" << endl;
2555 const size_t numMyElems = M->getNodeNumElements ();
2556 ArrayView<const GO> myElems = M->getNodeElementList ();
2557 Array<int> owner_procs_vec (numMyElems);
2560 std::ostringstream os;
2561 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2566 directory.getDirectoryEntries (*M, myElems, owner_procs_vec ());
2568 std::ostringstream os;
2569 os << *prefix <<
"getDirectoryEntries result: ";
2575 Array<GO> myOwned_vec (numMyElems);
2576 size_t numMyOwnedElems = 0;
2577 for (
size_t i = 0; i < numMyElems; ++i) {
2578 const GO GID = myElems[i];
2579 const int owner = owner_procs_vec[i];
2581 if (myRank == owner) {
2582 myOwned_vec[numMyOwnedElems++] = GID;
2585 myOwned_vec.resize (numMyOwnedElems);
2588 std::ostringstream os;
2589 os << *prefix <<
"Create Map: ";
2594 auto retMap = rcp(
new map_type(GINV, myOwned_vec(),
2595 M->getIndexBase(), M->getComm()));
2597 std::ostringstream os;
2598 os << *prefix <<
"Done" << endl;
2605template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2606Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2610 using Details::Behavior;
2611 using Details::verbosePrintArray;
2612 using Teuchos::Array;
2613 using Teuchos::ArrayView;
2616 using Teuchos::toString;
2619 using LO = LocalOrdinal;
2620 using GO = GlobalOrdinal;
2623 const bool verbose = Behavior::verbose(
"Map");
2624 std::unique_ptr<std::string> prefix;
2626 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2627 prefix = Details::createPrefix(
2628 comm.getRawPtr(),
"createOneToOne(Map,TieBreak)");
2629 std::ostringstream os;
2630 os << *prefix <<
"Start" << endl;
2633 const size_t maxNumToPrint = verbose ?
2634 Behavior::verbosePrintCountThreshold() : size_t(0);
2641 std::ostringstream os;
2642 os << *prefix <<
"Initialize Directory" << endl;
2645 directory.initialize (*M, tie_break);
2647 std::ostringstream os;
2648 os << *prefix <<
"Done initializing Directory" << endl;
2651 size_t numMyElems = M->getNodeNumElements ();
2652 ArrayView<const GO> myElems = M->getNodeElementList ();
2653 Array<int> owner_procs_vec (numMyElems);
2655 std::ostringstream os;
2656 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2661 directory.getDirectoryEntries (*M, myElems, owner_procs_vec ());
2663 std::ostringstream os;
2664 os << *prefix <<
"getDirectoryEntries result: ";
2670 const int myRank = M->getComm()->getRank();
2671 Array<GO> myOwned_vec (numMyElems);
2672 size_t numMyOwnedElems = 0;
2673 for (
size_t i = 0; i < numMyElems; ++i) {
2674 const GO GID = myElems[i];
2675 const int owner = owner_procs_vec[i];
2676 if (myRank == owner) {
2677 myOwned_vec[numMyOwnedElems++] = GID;
2680 myOwned_vec.resize (numMyOwnedElems);
2685 Tpetra::Details::OrdinalTraits<global_size_t>::invalid ();
2687 std::ostringstream os;
2688 os << *prefix <<
"Create Map: ";
2693 RCP<const map_type> retMap
2694 (
new map_type (GINV, myOwned_vec (), M->getIndexBase (),
2697 std::ostringstream os;
2698 os << *prefix <<
"Done" << endl;
2712#define TPETRA_MAP_INSTANT(LO,GO,NODE) \
2714 template class Map< LO , GO , NODE >; \
2716 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2717 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \
2718 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2720 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2721 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2722 const size_t localNumElements, \
2723 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2725 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2726 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \
2727 const Teuchos::RCP<const Teuchos::Comm<int> > &comm); \
2729 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2730 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2731 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2733 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2734 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M); \
2736 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2737 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M, \
2738 const Tpetra::Details::TieBreak<LO,GO>& tie_break); \
2742#define TPETRA_MAP_INSTANT_DEFAULTNODE(LO,GO) \
2743 template Teuchos::RCP< const Map<LO,GO> > \
2744 createLocalMap<LO,GO>( const size_t, const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2746 template Teuchos::RCP< const Map<LO,GO> > \
2747 createContigMap<LO,GO>( global_size_t, size_t, \
2748 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2750 template Teuchos::RCP< const Map<LO,GO> > \
2751 createNonContigMap(const Teuchos::ArrayView<const GO> &, \
2752 const Teuchos::RCP<const Teuchos::Comm<int> > &); \
2754 template Teuchos::RCP< const Map<LO,GO> > \
2755 createUniformContigMap<LO,GO>( const global_size_t, \
2756 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
Functions for initializing and finalizing Tpetra.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Declaration of a function that prints strings from each process.
Declaration of Tpetra::Details::initializeKokkos.
Declaration of Tpetra::Details::printOnce.
Stand-alone utility functions and macros.
Struct that holds views of the contents of a CrsMatrix.
Description of Tpetra's behavior.
static bool debug()
Whether Tpetra is in debug mode.
static bool verbose()
Whether Tpetra is in verbose mode.
static size_t verbosePrintCountThreshold()
Number of entries below which arrays, lists, etc. will be printed in debug mode.
"Local" part of Map suitable for Kokkos kernels.
Interface for breaking ties in ownership.
Implement mapping from global ID to process ID and local ID.
A parallel distribution of indices over processes.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
bool isOneToOne() const
Whether the Map is one to one.
std::string description() const
Implementation of Teuchos::Describable.
global_ordinal_type getGlobalElement(local_ordinal_type localIndex) const
The global index corresponding to the given local index.
Node node_type
Legacy typedef that will go away at some point.
Map()
Default constructor (that does nothing).
GlobalOrdinal global_ordinal_type
The type of global indices.
Teuchos::ArrayView< const global_ordinal_type > getNodeElementList() const
Return a NONOWNING view of the global indices owned by this process.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const global_ordinal_type > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< local_ordinal_type > &LIDList) const
Return the process ranks and corresponding local indices for the given global indices.
bool isNodeLocalElement(local_ordinal_type localIndex) const
Whether the given local index is valid for this Map on the calling process.
bool isUniform() const
Whether the range of global indices is uniform.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
typename device_type::execution_space execution_space
The Kokkos execution space.
LO local_ordinal_type
The type of local indices.
Teuchos::RCP< const Map< local_ordinal_type, global_ordinal_type, Node > > removeEmptyProcesses() const
Advanced methods.
bool isCompatible(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is compatible with this Map.
bool locallySameAs(const Map< local_ordinal_type, global_ordinal_type, node_type > &map) const
Is this Map locally the same as the input Map?
bool isLocallyFitted(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is locally fitted to this Map.
virtual ~Map()
Destructor (virtual for memory safety of derived classes).
local_ordinal_type getLocalElement(global_ordinal_type globalIndex) const
The local index corresponding to the given global index.
Teuchos::RCP< const Map< local_ordinal_type, global_ordinal_type, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map's communicator with a subset communicator.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Describe this object in a human-readable way to the given output stream.
bool isNodeGlobalElement(global_ordinal_type globalIndex) const
Whether the given global index is owned by this Map on the calling process.
bool isSameAs(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is identical to this Map.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
global_indices_array_type getMyGlobalIndices() const
Return a view of the global indices owned by this process.
typename Node::device_type device_type
This class' Kokkos::Device specialization.
Implementation details of Tpetra.
void verbosePrintArray(std::ostream &out, const ArrayType &x, const char name[], const size_t maxNumToPrint)
Print min(x.size(), maxNumToPrint) entries of x.
void printOnce(std::ostream &out, const std::string &s, const Teuchos::Comm< int > *comm)
Print on one process of the given communicator, or at least try to do so (if MPI is not initialized).
std::unique_ptr< std::string > createPrefix(const int myRank, const char prefix[])
Create string prefix for each line of verbose output.
bool congruent(const Teuchos::Comm< int > &comm1, const Teuchos::Comm< int > &comm2)
Whether the two communicators are congruent.
void initializeKokkos()
Initialize Kokkos, using command-line arguments (if any) given to Teuchos::GlobalMPISession.
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.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createLocalMap(const size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a locally replicated Map with the default Kokkos Node.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createUniformContigMap(const global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with the default Kokkos Node.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createNonContigMap(const Teuchos::ArrayView< const GlobalOrdinal > &elementList, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a non-contiguous Map using the default Kokkos::Device type.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(const global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with a user-specified Kokkos Node.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createContigMap(const global_size_t numElements, const size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a (potentially) non-uniformly distributed, contiguous Map using the defaul...
size_t global_size_t
Global size_t object.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createOneToOne(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &M)
Nonmember constructor for a contiguous Map with user-defined weights and a user-specified,...
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(const size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a locally replicated Map with a specified Kokkos Node.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createNonContigMapWithNode(const Teuchos::ArrayView< const GlobalOrdinal > &elementList, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a noncontiguous Map with a user-specified, possibly nondefault Kokkos Node ...
LocalGlobal
Enum for local versus global allocation of Map entries.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(const global_size_t numElements, const size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a (potentially) nonuniformly distributed, contiguous Map for a user-specifi...