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"
69 checkMapInputArray (
const char ctorName[],
70 const void* indexList,
71 const size_t indexListSize,
72 const Teuchos::Comm<int>*
const comm)
76 const bool debug = Behavior::debug(
"Map");
78 using Teuchos::outArg;
79 using Teuchos::REDUCE_MIN;
80 using Teuchos::reduceAll;
83 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
84 const bool verbose = Behavior::verbose(
"Map");
85 std::ostringstream lclErrStrm;
88 if (indexListSize != 0 && indexList ==
nullptr) {
91 lclErrStrm <<
"Proc " << myRank <<
": indexList is null, "
92 "but indexListSize=" << indexListSize <<
" != 0." << endl;
96 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
97 if (gblSuccess != 1) {
98 std::ostringstream gblErrStrm;
99 gblErrStrm <<
"Tpetra::Map constructor " << ctorName <<
100 " detected a problem with the input array "
101 "(raw array, Teuchos::ArrayView, or Kokkos::View) "
102 "of global indices." << endl;
104 using ::Tpetra::Details::gathervPrint;
107 TEUCHOS_TEST_FOR_EXCEPTION
108 (
true, std::invalid_argument, gblErrStrm.str ());
116 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121 numGlobalElements_ (0),
122 numLocalElements_ (0),
131 distributed_ (
false),
138 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
149 using Teuchos::broadcast;
150 using Teuchos::outArg;
151 using Teuchos::reduceAll;
152 using Teuchos::REDUCE_MIN;
153 using Teuchos::REDUCE_MAX;
154 using Teuchos::typeName;
158 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
159 const char funcName[] =
"Map(gblNumInds,indexBase,comm,LG)";
161 "Tpetra::Map::Map(gblNumInds,indexBase,comm,LG): ";
165 std::unique_ptr<std::string>
prefix;
168 comm_.getRawPtr(),
"Map",
funcName);
169 std::ostringstream
os;
171 std::cerr <<
os.str();
189 std::invalid_argument,
exPfx <<
"All processes must "
190 "provide the same number of global elements. Process 0 set "
192 "calling process " << comm->getRank() <<
" set "
194 "and max values over all processes are "
206 std::invalid_argument,
exPfx <<
"All processes must "
207 "provide the same indexBase argument. Process 0 set "
209 << comm->getRank() <<
" set indexBase=" <<
indexBase
210 <<
". The min and max values over all processes are "
233 std::invalid_argument,
exPfx <<
"numGlobalElements (= "
238 "You provided numGlobalElements = Teuchos::OrdinalTraits<"
239 "Tpetra::global_size_t>::invalid(). This version of the "
240 "constructor requires a valid value of numGlobalElements. "
241 "You probably mistook this constructor for the \"contiguous "
242 "nonuniform\" constructor, which can compute the global "
243 "number of elements for you if you set numGlobalElements to "
244 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid().");
247 if (
lOrG == GloballyDistributed) {
263 const GST myRank =
static_cast<GST> (comm_->getRank ());
289 distributed_ =
false;
297 firstContiguousGID_ = minMyGID_;
298 lastContiguousGID_ = maxMyGID_;
305 std::ostringstream
os;
307 std::cerr <<
os.str();
312 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
317 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) :
323 using Teuchos::broadcast;
324 using Teuchos::outArg;
325 using Teuchos::reduceAll;
326 using Teuchos::REDUCE_MIN;
327 using Teuchos::REDUCE_MAX;
328 using Teuchos::REDUCE_SUM;
333 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
335 "Map(gblNumInds,lclNumInds,indexBase,comm)";
337 "Tpetra::Map::Map(gblNumInds,lclNumInds,indexBase,comm): ";
339 ". Please report this bug to the Tpetra developers.";
343 std::unique_ptr<std::string>
prefix;
346 comm_.getRawPtr(),
"Map",
funcName);
347 std::ostringstream
os;
349 std::cerr <<
os.str();
357 debugGlobalSum = initialNonuniformDebugCheck(exPfx,
358 numGlobalElements, numLocalElements, indexBase, comm);
373 scan<int, GO> (*comm, REDUCE_SUM, numLocalElements, outArg (scanResult));
374 const GO myOffset = scanResult - numLocalElements;
384 const int numProcs = comm->getSize ();
389 numGlobalElements_ = globalSum;
393 TEUCHOS_TEST_FOR_EXCEPTION
394 (globalSum != debugGlobalSum, std::logic_error, exPfx <<
395 "globalSum = " << globalSum <<
" != debugGlobalSum = " <<
396 debugGlobalSum << suffix);
399 numLocalElements_ = numLocalElements;
400 indexBase_ = indexBase;
401 minAllGID_ = (numGlobalElements_ == 0) ?
402 std::numeric_limits<GO>::max () :
404 maxAllGID_ = (numGlobalElements_ == 0) ?
405 std::numeric_limits<GO>::lowest () :
406 indexBase + GO(numGlobalElements_) - GO(1);
407 minMyGID_ = (numLocalElements_ == 0) ?
408 std::numeric_limits<GO>::max () :
409 indexBase + GO(myOffset);
410 maxMyGID_ = (numLocalElements_ == 0) ?
411 std::numeric_limits<GO>::lowest () :
412 indexBase + myOffset + GO(numLocalElements) - GO(1);
413 firstContiguousGID_ = minMyGID_;
414 lastContiguousGID_ = maxMyGID_;
416 distributed_ = checkIsDist ();
422 std::ostringstream
os;
424 std::cerr <<
os.str();
428 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
430 Map<LocalOrdinal,GlobalOrdinal,Node>::
431 initialNonuniformDebugCheck(
432 const char errorMessagePrefix[],
434 const size_t numLocalElements,
435 const global_ordinal_type indexBase,
436 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
const
443 using Teuchos::broadcast;
444 using Teuchos::outArg;
446 using Teuchos::REDUCE_MAX;
447 using Teuchos::REDUCE_MIN;
448 using Teuchos::REDUCE_SUM;
449 using Teuchos::reduceAll;
450 using GO = global_ordinal_type;
452 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
462 GST debugGlobalSum = 0;
463 reduceAll<int, GST> (*comm, REDUCE_SUM,
static_cast<GST
> (numLocalElements),
464 outArg (debugGlobalSum));
480 "must provide the same number of global elements, even if "
482 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() "
483 "(which signals that the Map should compute the global "
484 "number of elements). Process 0 set numGlobalElements"
486 << comm->getRank() <<
" set numGlobalElements=" <<
500 "All processes must provide the same indexBase argument. "
502 "calling process " << comm->getRank() <<
" set indexBase="
503 <<
indexBase <<
". The min and max values over all "
515 "would like this constructor to compute numGlobalElements "
516 "for you, you may set numGlobalElements="
517 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() "
518 "on input. Please note that this is NOT necessarily -1.");
523 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
525 Map<LocalOrdinal,GlobalOrdinal,Node>::
526 initWithNonownedHostIndexList(
527 const char errorMessagePrefix[],
529 const Kokkos::View<
const global_ordinal_type*,
532 Kokkos::MemoryUnmanaged>& entryList_host,
533 const global_ordinal_type indexBase,
534 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
536 using Kokkos::LayoutLeft;
537 using Kokkos::subview;
539 using Kokkos::view_alloc;
540 using Kokkos::WithoutInitializing;
542 using Teuchos::broadcast;
543 using Teuchos::outArg;
545 using Teuchos::REDUCE_MAX;
546 using Teuchos::REDUCE_MIN;
547 using Teuchos::REDUCE_SUM;
548 using Teuchos::reduceAll;
552 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
556 (! Kokkos::is_initialized (), std::runtime_error,
558 << Teuchos::TypeNameTraits<execution_space>::name()
559 <<
" has not been initialized. "
560 "Please initialize it before creating a Map.")
592 outArg(numGlobalElements_));
618 numLocalElements_ = numLocalElements;
619 indexBase_ = indexBase;
621 minMyGID_ = indexBase_;
622 maxMyGID_ = indexBase_;
632 if (numLocalElements_ > 0) {
636 typename decltype (lgMap_)::non_const_type lgMap
637 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
639 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
647 firstContiguousGID_ = entryList_host[0];
648 lastContiguousGID_ = firstContiguousGID_+1;
656 lgMap_host[0] = firstContiguousGID_;
658 for ( ; i < numLocalElements_; ++i) {
659 const GO curGid = entryList_host[i];
660 const LO curLid = as<LO> (i);
662 if (lastContiguousGID_ != curGid)
break;
668 lgMap_host[curLid] = curGid;
669 ++lastContiguousGID_;
671 --lastContiguousGID_;
676 minMyGID_ = firstContiguousGID_;
677 maxMyGID_ = lastContiguousGID_;
687 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
688 "nonContigGids_host.extent(0) = "
690 <<
" != entryList_host.extent(0) - i = "
693 <<
". 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);
734 Kokkos::deep_copy (execution_space(), lgMap, lgMap_host);
739 lgMapHost_ = lgMap_host;
742 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
743 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
747 firstContiguousGID_ = indexBase_+1;
748 lastContiguousGID_ = indexBase_;
773 if (std::numeric_limits<GO>::is_signed) {
776 (
as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
791 distributed_ = (comm_->getSize () > 1 &&
globalDist == 1);
797 distributed_ = checkIsDist ();
803 minAllGID_ < indexBase_,
804 std::invalid_argument,
805 "Tpetra::Map constructor (noncontiguous): "
806 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
807 "less than the given indexBase = " << indexBase_ <<
".");
813 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
819 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
826 "Map(gblNumInds,indexList,indexListSize,indexBase,comm)";
829 std::unique_ptr<std::string>
prefix;
832 comm_.getRawPtr(),
"Map",
funcName);
833 std::ostringstream
os;
835 std::cerr <<
os.str();
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();
898 std::ostringstream
os;
900 std::cerr <<
os.str();
904 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
907 const Kokkos::View<const GlobalOrdinal*, device_type>&
entryList,
909 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
914 using Kokkos::LayoutLeft;
915 using Kokkos::subview;
917 using Kokkos::view_alloc;
918 using Kokkos::WithoutInitializing;
920 using Teuchos::ArrayView;
922 using Teuchos::broadcast;
923 using Teuchos::outArg;
925 using Teuchos::REDUCE_MAX;
926 using Teuchos::REDUCE_MIN;
927 using Teuchos::REDUCE_SUM;
928 using Teuchos::reduceAll;
929 using Teuchos::typeName;
934 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
936 "Map(gblNumInds,entryList(Kokkos::View),indexBase,comm)";
939 std::unique_ptr<std::string>
prefix;
942 comm_.getRawPtr(),
"Map",
funcName);
943 std::ostringstream
os;
945 std::cerr <<
os.str();
950 static_cast<size_t> (
entryList.extent (0)),
1012 minMyGID_ = indexBase_;
1013 maxMyGID_ = indexBase_;
1023 if (numLocalElements_ > 0) {
1027 typename decltype (lgMap_)::non_const_type
lgMap
1030 Kokkos::create_mirror_view (Kokkos::HostSpace (),
lgMap);
1032 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_) {
1123 lgMapHost_ = lgMap_host;
1126 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
1127 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
1131 firstContiguousGID_ = indexBase_+1;
1132 lastContiguousGID_ = indexBase_;
1157 if (std::numeric_limits<GO>::is_signed) {
1159 const GO localDist =
1160 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
1163 minMaxInput[0] = -minMyGID_;
1164 minMaxInput[1] = maxMyGID_;
1165 minMaxInput[2] = localDist;
1168 minMaxOutput[0] = 0;
1169 minMaxOutput[1] = 0;
1170 minMaxOutput[2] = 0;
1171 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
1172 minAllGID_ = -minMaxOutput[0];
1173 maxAllGID_ = minMaxOutput[1];
1174 const GO globalDist = minMaxOutput[2];
1175 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
1179 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
1180 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
1181 distributed_ = checkIsDist ();
1184 contiguous_ =
false;
1186 TEUCHOS_TEST_FOR_EXCEPTION(
1187 minAllGID_ < indexBase_,
1188 std::invalid_argument,
1189 "Tpetra::Map constructor (noncontiguous): "
1190 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
1191 "less than the given indexBase = " << indexBase_ <<
".");
1197 std::ostringstream os;
1198 os << *prefix <<
"Done" << endl;
1199 std::cerr << os.str();
1204 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1207 if (! Kokkos::is_initialized ()) {
1208 std::ostringstream
os;
1209 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1210 "Kokkos::finalize() has been called. This is user error! There are "
1211 "two likely causes: " << std::endl <<
1212 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1214 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1215 "of a Tpetra::Map) at the same scope in main() as Kokkos::finalize() "
1216 "or Tpetra::finalize()." << std::endl << std::endl <<
1217 "Don't do either of these! Please refer to GitHib Issue #2372."
1220 this->getComm ().getRawPtr ());
1223 using ::Tpetra::Details::mpiIsInitialized;
1224 using ::Tpetra::Details::mpiIsFinalized;
1225 using ::Tpetra::Details::teuchosCommIsAnMpiComm;
1227 Teuchos::RCP<const Teuchos::Comm<int> > comm = this->getComm ();
1228 if (! comm.is_null () && teuchosCommIsAnMpiComm (*comm) &&
1229 mpiIsInitialized () && mpiIsFinalized ()) {
1235 std::ostringstream
os;
1236 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1237 "MPI_Finalize() has been called. This is user error! There are "
1238 "two likely causes: " << std::endl <<
1239 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1241 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1242 "of a Tpetra::Map) at the same scope in main() as MPI_finalize() or "
1243 "Tpetra::finalize()." << std::endl << std::endl <<
1244 "Don't do either of these! Please refer to GitHib Issue #2372."
1254 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1259 getComm ().
is_null (), std::logic_error,
"Tpetra::Map::isOneToOne: "
1260 "getComm() returns null. Please report this bug to the Tpetra "
1265 return directory_->isOneToOne (*
this);
1268 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1273 if (isContiguous ()) {
1276 return Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1292 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1298 return Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
1300 if (isContiguous ()) {
1312 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1324 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1329 Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1332 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1337 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1343 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1349 getMinGlobalIndex (), getMaxGlobalIndex (),
1350 firstContiguousGID_, lastContiguousGID_,
1351 getLocalNumElements (), isContiguous ());
1354 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1359 using Teuchos::outArg;
1360 using Teuchos::REDUCE_MIN;
1361 using Teuchos::reduceAll;
1371 else if (getComm ()->getSize () !=
map.getComm ()->getSize ()) {
1377 else if (getGlobalNumElements () !=
map.getGlobalNumElements ()) {
1382 else if (isContiguous () && isUniform () &&
1383 map.isContiguous () &&
map.isUniform ()) {
1389 else if (! isContiguous () && !
map.isContiguous () &&
1390 lgMap_.extent (0) != 0 &&
map.lgMap_.extent (0) != 0 &&
1391 lgMap_.data () ==
map.lgMap_.data ()) {
1406 getGlobalNumElements () !=
map.getGlobalNumElements (), std::logic_error,
1407 "Tpetra::Map::isCompatible: There's a bug in this method. We've already "
1408 "checked that this condition is true above, but it's false here. "
1409 "Please report this bug to the Tpetra developers.");
1413 (getLocalNumElements () ==
map.getLocalNumElements ()) ? 1 : 0;
1420 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1425 using Teuchos::ArrayView;
1442 else if (getLocalNumElements () !=
map.getLocalNumElements ()) {
1445 else if (getMinGlobalIndex () !=
map.getMinGlobalIndex () ||
1446 getMaxGlobalIndex () !=
map.getMaxGlobalIndex ()) {
1450 if (isContiguous ()) {
1451 if (
map.isContiguous ()) {
1456 ! this->isContiguous () ||
map.isContiguous (), std::logic_error,
1457 "Tpetra::Map::locallySameAs: BUG");
1459 const GO
minLhsGid = this->getMinGlobalIndex ();
1470 else if (
map.isContiguous ()) {
1472 this->isContiguous () || !
map.isContiguous (), std::logic_error,
1473 "Tpetra::Map::locallySameAs: BUG");
1485 else if (this->lgMap_.data () ==
map.lgMap_.data ()) {
1488 return this->getLocalNumElements () ==
map.getLocalNumElements ();
1491 if (this->getLocalNumElements () !=
map.getLocalNumElements ()) {
1507 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1520 auto lmap2 = this->getLocalMap();
1530 if (
lmap1.isContiguous () &&
lmap2.isContiguous ()) {
1532 return ((
lmap1.getMinGlobalIndex () ==
lmap2.getMinGlobalIndex ()) &&
1533 (
lmap1.getMaxGlobalIndex () <=
lmap2.getMaxGlobalIndex ()));
1536 if (
lmap1.getMinGlobalIndex () <
lmap2.getMinGlobalIndex () ||
1537 lmap1.getMaxGlobalIndex () >
lmap2.getMaxGlobalIndex ()) {
1545 Kokkos::RangePolicy<LO, typename node_type::execution_space>;
1549 Kokkos::parallel_reduce(
1559 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1564 using Teuchos::outArg;
1565 using Teuchos::REDUCE_MIN;
1566 using Teuchos::reduceAll;
1576 else if (getComm ()->getSize () !=
map.getComm ()->getSize ()) {
1582 else if (getGlobalNumElements () !=
map.getGlobalNumElements ()) {
1587 else if (getMinAllGlobalIndex () !=
map.getMinAllGlobalIndex () ||
1588 getMaxAllGlobalIndex () !=
map.getMaxAllGlobalIndex () ||
1589 getIndexBase () !=
map.getIndexBase ()) {
1594 else if (isDistributed () !=
map.isDistributed ()) {
1599 else if (isContiguous () && isUniform () &&
1600 map.isContiguous () &&
map.isUniform ()) {
1629 template <
class LO,
class GO,
class DT>
1632 FillLgMap (
const Kokkos::View<GO*, DT>&
lgMap,
1636 Kokkos::RangePolicy<LO, typename DT::execution_space>
1637 range (
static_cast<LO
> (0),
static_cast<LO
> (
lgMap.size ()));
1638 Kokkos::parallel_for (
range, *
this);
1641 KOKKOS_INLINE_FUNCTION
void operator () (
const LO& lid)
const {
1642 lgMap_(lid) = startGid_ +
static_cast<GO
> (lid);
1646 const Kokkos::View<GO*, DT> lgMap_;
1653 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1654 typename Map<LocalOrdinal,GlobalOrdinal,Node>::global_indices_array_type
1661 using lg_view_type =
typename const_lg_view_type::non_const_type;
1665 std::unique_ptr<std::string>
prefix;
1668 comm_.getRawPtr(),
"Map",
"getMyGlobalIndices");
1669 std::ostringstream
os;
1671 std::cerr <<
os.str();
1678 lgMap_.extent (0) == 0 && numLocalElements_ > 0;
1682 std::ostringstream
os;
1684 std::cerr <<
os.str();
1690 (! isContiguous(), std::logic_error,
1691 "Tpetra::Map::getMyGlobalIndices: The local-to-global "
1692 "mapping (lgMap_) should have been set up already for a "
1693 "noncontiguous Map. Please report this bug to the Tpetra "
1696 const LO
numElts =
static_cast<LO
> (getLocalNumElements ());
1698 using Kokkos::view_alloc;
1699 using Kokkos::WithoutInitializing;
1702 std::ostringstream
os;
1704 std::cerr <<
os.str();
1709 std::ostringstream
os;
1711 std::cerr <<
os.str();
1715 Kokkos::create_mirror_view (Kokkos::HostSpace (),
lgMap);
1730 std::ostringstream
os;
1732 std::cerr <<
os.str();
1737 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1738 Teuchos::ArrayView<const GlobalOrdinal>
1746 (
void) this->getMyGlobalIndices ();
1753 return Teuchos::ArrayView<const GO>(
1755 lgMapHost_.extent (0),
1756 Teuchos::RCP_DISABLE_NODE_LOOKUP);
1759 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1761 return distributed_;
1764 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1766 using Teuchos::TypeNameTraits;
1767 std::ostringstream
os;
1769 os <<
"Tpetra::Map: {"
1776 os <<
", Global number of entries: " << getGlobalNumElements ()
1777 <<
", Number of processes: " << getComm ()->getSize ()
1778 <<
", Uniform: " << (isUniform () ?
"true" :
"false")
1779 <<
", Contiguous: " << (isContiguous () ?
"true" :
"false")
1780 <<
", Distributed: " << (isDistributed () ?
"true" :
"false")
1789 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1794 using LO = local_ordinal_type;
1798 if (
vl < Teuchos::VERB_HIGH) {
1799 return std::string ();
1801 auto outStringP = Teuchos::rcp (
new std::ostringstream ());
1802 Teuchos::RCP<Teuchos::FancyOStream> outp =
1803 Teuchos::getFancyOStream (outStringP);
1804 Teuchos::FancyOStream& out = *outp;
1806 auto comm = this->getComm ();
1807 const int myRank = comm->getRank ();
1808 const int numProcs = comm->getSize ();
1809 out <<
"Process " << myRank <<
" of " << numProcs <<
":" << endl;
1810 Teuchos::OSTab tab1 (out);
1812 const LO numEnt =
static_cast<LO
> (this->getLocalNumElements ());
1813 out <<
"My number of entries: " << numEnt << endl
1814 <<
"My minimum global index: " << this->getMinGlobalIndex () << endl
1815 <<
"My maximum global index: " << this->getMaxGlobalIndex () << endl;
1817 if (vl == Teuchos::VERB_EXTREME) {
1818 out <<
"My global indices: [";
1819 const LO minLclInd = this->getMinLocalIndex ();
1820 for (LO k = 0; k < numEnt; ++k) {
1821 out << minLclInd + this->getGlobalElement (k);
1822 if (k + 1 < numEnt) {
1830 return outStringP->str ();
1833 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1837 const Teuchos::EVerbosityLevel
verbLevel)
const
1839 using Teuchos::TypeNameTraits;
1840 using Teuchos::VERB_DEFAULT;
1841 using Teuchos::VERB_NONE;
1842 using Teuchos::VERB_LOW;
1843 using Teuchos::VERB_HIGH;
1847 const Teuchos::EVerbosityLevel
vl =
1857 auto comm = this->getComm ();
1858 if (comm.is_null ()) {
1861 const int myRank = comm->getRank ();
1862 const int numProcs = comm->getSize ();
1871 Teuchos::RCP<Teuchos::OSTab>
tab0,
tab1;
1877 tab0 = Teuchos::rcp (
new Teuchos::OSTab (
out));
1878 out <<
"\"Tpetra::Map\":" <<
endl;
1879 tab1 = Teuchos::rcp (
new Teuchos::OSTab (
out));
1881 out <<
"Template parameters:" <<
endl;
1889 out <<
"Label: \"" << label <<
"\"" <<
endl;
1891 out <<
"Global number of entries: " << getGlobalNumElements () <<
endl
1892 <<
"Minimum global index: " << getMinAllGlobalIndex () <<
endl
1893 <<
"Maximum global index: " << getMaxAllGlobalIndex () <<
endl
1894 <<
"Index base: " << getIndexBase () <<
endl
1896 <<
"Uniform: " << (isUniform () ?
"true" :
"false") <<
endl
1897 <<
"Contiguous: " << (isContiguous () ?
"true" :
"false") <<
endl
1898 <<
"Distributed: " << (isDistributed () ?
"true" :
"false") <<
endl;
1903 const std::string
lclStr = this->localDescribeToString (
vl);
1908 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1909 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1928 return Teuchos::null;
1930 else if (
newComm->getSize () == 1) {
1941 newMap->indexBase_ = this->indexBase_;
1942 newMap->numGlobalElements_ = this->numLocalElements_;
1943 newMap->numLocalElements_ = this->numLocalElements_;
1944 newMap->minMyGID_ = this->minMyGID_;
1945 newMap->maxMyGID_ = this->maxMyGID_;
1946 newMap->minAllGID_ = this->minMyGID_;
1947 newMap->maxAllGID_ = this->maxMyGID_;
1948 newMap->firstContiguousGID_ = this->firstContiguousGID_;
1949 newMap->lastContiguousGID_ = this->lastContiguousGID_;
1952 newMap->uniform_ = this->uniform_;
1953 newMap->contiguous_ = this->contiguous_;
1956 newMap->distributed_ =
false;
1957 newMap->lgMap_ = this->lgMap_;
1958 newMap->lgMapHost_ = this->lgMapHost_;
1959 newMap->glMap_ = this->glMap_;
1960 newMap->glMapHost_ = this->glMapHost_;
1981 const GST RECOMPUTE = Tpetra::Details::OrdinalTraits<GST>::invalid ();
1997 auto lgMap = this->getMyGlobalIndices ();
1999 typename std::decay<
decltype (
lgMap.extent (0)) >::type;
2001 static_cast<size_type
> (this->getLocalNumElements ());
2002 using Teuchos::TypeNameTraits;
2005 "Tpetra::Map::replaceCommWithSubset: Result of getMyGlobalIndices() "
2006 "has length " <<
lgMap.extent (0) <<
" (of type " <<
2008 " = " <<
this->getLocalNumElements () <<
". The latter, upon being "
2010 "becomes " <<
lclNumInds <<
". Please report this bug to the Tpetra "
2013 Teuchos::ArrayView<const GO>
lgMap = this->getLocalElementList ();
2016 const GO
indexBase = this->getIndexBase ();
2023 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2024 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
2028 using Teuchos::Comm;
2029 using Teuchos::null;
2030 using Teuchos::outArg;
2033 using Teuchos::REDUCE_MIN;
2034 using Teuchos::reduceAll;
2041 const int color = (numLocalElements_ == 0) ? 0 : 1;
2058 map->indexBase_ = indexBase_;
2059 map->numGlobalElements_ = numGlobalElements_;
2060 map->numLocalElements_ = numLocalElements_;
2061 map->minMyGID_ = minMyGID_;
2062 map->maxMyGID_ = maxMyGID_;
2063 map->minAllGID_ = minAllGID_;
2064 map->maxAllGID_ = maxAllGID_;
2065 map->firstContiguousGID_= firstContiguousGID_;
2066 map->lastContiguousGID_ = lastContiguousGID_;
2070 map->uniform_ = uniform_;
2071 map->contiguous_ = contiguous_;
2086 if (! distributed_ ||
newComm->getSize () == 1) {
2087 map->distributed_ =
false;
2089 const int iOwnAllGids = (numLocalElements_ == numGlobalElements_) ? 1 : 0;
2095 map->lgMap_ = lgMap_;
2096 map->lgMapHost_ = lgMapHost_;
2097 map->glMap_ = glMap_;
2098 map->glMapHost_ = glMapHost_;
2115 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2120 directory_.is_null (), std::logic_error,
"Tpetra::Map::setupDirectory: "
2121 "The Directory is null. "
2122 "Please report this bug to the Tpetra developers.");
2126 if (! directory_->initialized ()) {
2127 directory_->initialize (*
this);
2131 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2135 const Teuchos::ArrayView<int>&
PIDs,
2136 const Teuchos::ArrayView<LocalOrdinal>&
LIDs)
const
2138 using Tpetra::Details::OrdinalTraits;
2141 using size_type = Teuchos::ArrayView<int>::size_type;
2146 std::unique_ptr<std::string>
prefix;
2149 "Map",
"getRemoteIndexList(GIDs,PIDs,LIDs)");
2150 std::ostringstream
os;
2154 std::cerr <<
os.str();
2163 if (getGlobalNumElements () == 0) {
2164 if (
GIDs.size () == 0) {
2166 std::ostringstream
os;
2167 os << *
prefix <<
"Done; both Map & input are empty" <<
endl;
2168 std::cerr <<
os.str();
2174 std::ostringstream
os;
2175 os << *
prefix <<
"Done: Map is empty on all processes, "
2176 "so all output PIDs & LIDs are invalid (-1)." <<
endl;
2177 std::cerr <<
os.str();
2179 for (size_type
k = 0;
k <
PIDs.size (); ++
k) {
2182 for (size_type
k = 0;
k <
LIDs.size (); ++
k) {
2194 std::ostringstream
os;
2196 std::cerr <<
os.str();
2200 std::ostringstream
os;
2201 os << *
prefix <<
"Call directory_->getDirectoryEntries" <<
endl;
2202 std::cerr <<
os.str();
2205 directory_->getDirectoryEntries (*
this,
GIDs,
PIDs,
LIDs);
2207 std::ostringstream
os;
2208 os << *
prefix <<
"Done; getDirectoryEntries returned "
2215 std::cerr <<
os.str();
2220 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2224 const Teuchos::ArrayView<int> &
PIDs)
const
2232 std::unique_ptr<std::string>
prefix;
2235 "Map",
"getRemoteIndexList(GIDs,PIDs)");
2236 std::ostringstream
os;
2240 std::cerr <<
os.str();
2243 if (getGlobalNumElements () == 0) {
2244 if (
GIDs.size () == 0) {
2246 std::ostringstream
os;
2247 os << *
prefix <<
"Done; both Map & input are empty" <<
endl;
2248 std::cerr <<
os.str();
2254 std::ostringstream
os;
2255 os << *
prefix <<
"Done: Map is empty on all processes, "
2256 "so all output PIDs are invalid (-1)." <<
endl;
2257 std::cerr <<
os.str();
2259 for (Teuchos::ArrayView<int>::size_type
k = 0;
k <
PIDs.size (); ++
k) {
2260 PIDs[
k] = Tpetra::Details::OrdinalTraits<int>::invalid ();
2271 std::ostringstream
os;
2273 std::cerr <<
os.str();
2277 std::ostringstream
os;
2278 os << *
prefix <<
"Call directory_->getDirectoryEntries" <<
endl;
2279 std::cerr <<
os.str();
2282 directory_->getDirectoryEntries(*
this,
GIDs,
PIDs);
2284 std::ostringstream
os;
2285 os << *
prefix <<
"Done; getDirectoryEntries returned "
2290 std::cerr <<
os.str();
2295 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2296 Teuchos::RCP<const Teuchos::Comm<int> >
2301 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2307 using Teuchos::outArg;
2308 using Teuchos::REDUCE_MIN;
2309 using Teuchos::reduceAll;
2313 std::unique_ptr<std::string>
prefix;
2316 comm_.getRawPtr(),
"Map",
"checkIsDist");
2317 std::ostringstream
os;
2319 std::cerr <<
os.str();
2322 bool global =
false;
2323 if (comm_->getSize () > 1) {
2327 if (numGlobalElements_ == as<global_size_t> (numLocalElements_)) {
2340 reduceAll<int, int> (*comm_, REDUCE_MIN, localRep, outArg (allLocalRep));
2341 if (allLocalRep != 1) {
2351 std::ostringstream os;
2352 os << *prefix <<
"Done; global=" << (global ?
"true" :
"false")
2354 std::cerr << os.str();
2361template <
class LocalOrdinal,
class GlobalOrdinal>
2362Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2364 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2366 typedef LocalOrdinal LO;
2367 typedef GlobalOrdinal GO;
2368 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2369 return createLocalMapWithNode<LO, GO, NT> (numElements, comm);
2372template <
class LocalOrdinal,
class GlobalOrdinal>
2373Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2375 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2377 typedef LocalOrdinal LO;
2378 typedef GlobalOrdinal GO;
2379 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2380 return createUniformContigMapWithNode<LO, GO, NT> (numElements, comm);
2383template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2384Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2386 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2391 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2393 return rcp (
new map_type (numElements, indexBase, comm, GloballyDistributed));
2396template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2397Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2399 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2405 const GlobalOrdinal indexBase = 0;
2408 return rcp (
new map_type (globalNumElts, indexBase, comm, LocallyReplicated));
2411template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2412Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2414 const size_t localNumElements,
2415 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2420 const GlobalOrdinal indexBase = 0;
2422 return rcp (
new map_type (numElements, localNumElements, indexBase, comm));
2425template <
class LocalOrdinal,
class GlobalOrdinal>
2426Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2428 const size_t localNumElements,
2429 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2431 typedef LocalOrdinal LO;
2432 typedef GlobalOrdinal GO;
2438template <
class LocalOrdinal,
class GlobalOrdinal>
2439Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2441 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2443 typedef LocalOrdinal LO;
2444 typedef GlobalOrdinal GO;
2450template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2451Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2453 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2459 const GST INV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2463 const GlobalOrdinal indexBase = 0;
2465 return rcp (
new map_type (INV, elementList, indexBase, comm));
2468template<
class LO,
class GO,
class NT>
2469Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >
2472 using Details::verbosePrintArray;
2473 using Teuchos::Array;
2474 using Teuchos::ArrayView;
2482 const bool verbose = Details::Behavior::verbose(
"Map");
2483 std::unique_ptr<std::string> prefix;
2485 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2486 prefix = Details::createPrefix(
2487 comm.getRawPtr(),
"createOneToOne(Map)");
2488 std::ostringstream os;
2489 os << *prefix <<
"Start" << endl;
2492 const size_t maxNumToPrint = verbose ?
2493 Details::Behavior::verbosePrintCountThreshold() : size_t(0);
2494 const GST GINV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2495 const int myRank = M->getComm ()->getRank ();
2501 if (! M->isDistributed ()) {
2508 const GST numGlobalEntries = M->getGlobalNumElements ();
2509 if (M->isContiguous()) {
2510 const size_t numLocalEntries =
2511 (myRank == 0) ? as<size_t>(numGlobalEntries) : size_t(0);
2513 std::ostringstream os;
2514 os << *prefix <<
"Input is locally replicated & contiguous; "
2515 "numLocalEntries=" << numLocalEntries << endl;
2519 rcp(
new map_type(numGlobalEntries, numLocalEntries,
2520 M->getIndexBase(), M->getComm()));
2522 std::ostringstream os;
2523 os << *prefix <<
"Done" << endl;
2530 std::ostringstream os;
2531 os << *prefix <<
"Input is locally replicated & noncontiguous"
2535 ArrayView<const GO> myGids =
2536 (myRank == 0) ? M->getLocalElementList() : Teuchos::null;
2538 rcp(
new map_type(GINV, myGids(), M->getIndexBase(),
2541 std::ostringstream os;
2542 os << *prefix <<
"Done" << endl;
2548 else if (M->isContiguous ()) {
2550 std::ostringstream os;
2551 os << *prefix <<
"Input is distributed & contiguous" << endl;
2560 std::ostringstream os;
2561 os << *prefix <<
"Input is distributed & noncontiguous" << endl;
2565 const size_t numMyElems = M->getLocalNumElements ();
2566 ArrayView<const GO> myElems = M->getLocalElementList ();
2567 Array<int> owner_procs_vec (numMyElems);
2570 std::ostringstream os;
2571 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2576 directory.getDirectoryEntries (*M, myElems, owner_procs_vec ());
2578 std::ostringstream os;
2579 os << *prefix <<
"getDirectoryEntries result: ";
2585 Array<GO> myOwned_vec (numMyElems);
2586 size_t numMyOwnedElems = 0;
2587 for (
size_t i = 0; i < numMyElems; ++i) {
2588 const GO GID = myElems[i];
2589 const int owner = owner_procs_vec[i];
2591 if (myRank == owner) {
2592 myOwned_vec[numMyOwnedElems++] = GID;
2595 myOwned_vec.resize (numMyOwnedElems);
2598 std::ostringstream os;
2599 os << *prefix <<
"Create Map: ";
2604 auto retMap = rcp(
new map_type(GINV, myOwned_vec(),
2605 M->getIndexBase(), M->getComm()));
2607 std::ostringstream os;
2608 os << *prefix <<
"Done" << endl;
2615template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2616Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2620 using Details::Behavior;
2621 using Details::verbosePrintArray;
2622 using Teuchos::Array;
2623 using Teuchos::ArrayView;
2626 using Teuchos::toString;
2629 using LO = LocalOrdinal;
2630 using GO = GlobalOrdinal;
2633 const bool verbose = Behavior::verbose(
"Map");
2634 std::unique_ptr<std::string> prefix;
2636 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2637 prefix = Details::createPrefix(
2638 comm.getRawPtr(),
"createOneToOne(Map,TieBreak)");
2639 std::ostringstream os;
2640 os << *prefix <<
"Start" << endl;
2643 const size_t maxNumToPrint = verbose ?
2644 Behavior::verbosePrintCountThreshold() : size_t(0);
2651 std::ostringstream os;
2652 os << *prefix <<
"Initialize Directory" << endl;
2655 directory.initialize (*M, tie_break);
2657 std::ostringstream os;
2658 os << *prefix <<
"Done initializing Directory" << endl;
2661 size_t numMyElems = M->getLocalNumElements ();
2662 ArrayView<const GO> myElems = M->getLocalElementList ();
2663 Array<int> owner_procs_vec (numMyElems);
2665 std::ostringstream os;
2666 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2671 directory.getDirectoryEntries (*M, myElems, owner_procs_vec ());
2673 std::ostringstream os;
2674 os << *prefix <<
"getDirectoryEntries result: ";
2680 const int myRank = M->getComm()->getRank();
2681 Array<GO> myOwned_vec (numMyElems);
2682 size_t numMyOwnedElems = 0;
2683 for (
size_t i = 0; i < numMyElems; ++i) {
2684 const GO GID = myElems[i];
2685 const int owner = owner_procs_vec[i];
2686 if (myRank == owner) {
2687 myOwned_vec[numMyOwnedElems++] = GID;
2690 myOwned_vec.resize (numMyOwnedElems);
2695 Tpetra::Details::OrdinalTraits<global_size_t>::invalid ();
2697 std::ostringstream os;
2698 os << *prefix <<
"Create Map: ";
2703 RCP<const map_type> retMap
2704 (
new map_type (GINV, myOwned_vec (), M->getIndexBase (),
2707 std::ostringstream os;
2708 os << *prefix <<
"Done" << endl;
2722#define TPETRA_MAP_INSTANT(LO,GO,NODE) \
2724 template class Map< LO , GO , NODE >; \
2726 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2727 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \
2728 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2730 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2731 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2732 const size_t localNumElements, \
2733 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2735 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2736 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \
2737 const Teuchos::RCP<const Teuchos::Comm<int> > &comm); \
2739 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2740 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2741 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2743 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2744 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M); \
2746 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2747 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M, \
2748 const Tpetra::Details::TieBreak<LO,GO>& tie_break); \
2752#define TPETRA_MAP_INSTANT_DEFAULTNODE(LO,GO) \
2753 template Teuchos::RCP< const Map<LO,GO> > \
2754 createLocalMap<LO,GO>( const size_t, const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2756 template Teuchos::RCP< const Map<LO,GO> > \
2757 createContigMap<LO,GO>( global_size_t, size_t, \
2758 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2760 template Teuchos::RCP< const Map<LO,GO> > \
2761 createNonContigMap(const Teuchos::ArrayView<const GO> &, \
2762 const Teuchos::RCP<const Teuchos::Comm<int> > &); \
2764 template Teuchos::RCP< const Map<LO,GO> > \
2765 createUniformContigMap<LO,GO>( const global_size_t, \
2766 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.
Teuchos::ArrayView< const global_ordinal_type > getLocalElementList() const
Return a NONOWNING view of the global indices owned by this process.
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.
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...