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);
1725 std::ostringstream
os;
1727 std::cerr <<
os.str();
1732 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1733 Teuchos::ArrayView<const GlobalOrdinal>
1741 (
void) this->getMyGlobalIndices ();
1748 return Teuchos::ArrayView<const GO>(
1750 lgMapHost_.extent (0),
1751 Teuchos::RCP_DISABLE_NODE_LOOKUP);
1754 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1756 return distributed_;
1759 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1761 using Teuchos::TypeNameTraits;
1762 std::ostringstream
os;
1764 os <<
"Tpetra::Map: {"
1771 os <<
", Global number of entries: " << getGlobalNumElements ()
1772 <<
", Number of processes: " << getComm ()->getSize ()
1773 <<
", Uniform: " << (isUniform () ?
"true" :
"false")
1774 <<
", Contiguous: " << (isContiguous () ?
"true" :
"false")
1775 <<
", Distributed: " << (isDistributed () ?
"true" :
"false")
1784 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1789 using LO = local_ordinal_type;
1793 if (
vl < Teuchos::VERB_HIGH) {
1794 return std::string ();
1796 auto outStringP = Teuchos::rcp (
new std::ostringstream ());
1797 Teuchos::RCP<Teuchos::FancyOStream> outp =
1798 Teuchos::getFancyOStream (outStringP);
1799 Teuchos::FancyOStream& out = *outp;
1801 auto comm = this->getComm ();
1802 const int myRank = comm->getRank ();
1803 const int numProcs = comm->getSize ();
1804 out <<
"Process " << myRank <<
" of " << numProcs <<
":" << endl;
1805 Teuchos::OSTab tab1 (out);
1807 const LO numEnt =
static_cast<LO
> (this->getLocalNumElements ());
1808 out <<
"My number of entries: " << numEnt << endl
1809 <<
"My minimum global index: " << this->getMinGlobalIndex () << endl
1810 <<
"My maximum global index: " << this->getMaxGlobalIndex () << endl;
1812 if (vl == Teuchos::VERB_EXTREME) {
1813 out <<
"My global indices: [";
1814 const LO minLclInd = this->getMinLocalIndex ();
1815 for (LO k = 0; k < numEnt; ++k) {
1816 out << minLclInd + this->getGlobalElement (k);
1817 if (k + 1 < numEnt) {
1825 return outStringP->str ();
1828 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1832 const Teuchos::EVerbosityLevel
verbLevel)
const
1834 using Teuchos::TypeNameTraits;
1835 using Teuchos::VERB_DEFAULT;
1836 using Teuchos::VERB_NONE;
1837 using Teuchos::VERB_LOW;
1838 using Teuchos::VERB_HIGH;
1842 const Teuchos::EVerbosityLevel
vl =
1852 auto comm = this->getComm ();
1853 if (comm.is_null ()) {
1856 const int myRank = comm->getRank ();
1857 const int numProcs = comm->getSize ();
1866 Teuchos::RCP<Teuchos::OSTab>
tab0,
tab1;
1872 tab0 = Teuchos::rcp (
new Teuchos::OSTab (
out));
1873 out <<
"\"Tpetra::Map\":" <<
endl;
1874 tab1 = Teuchos::rcp (
new Teuchos::OSTab (
out));
1876 out <<
"Template parameters:" <<
endl;
1884 out <<
"Label: \"" << label <<
"\"" <<
endl;
1886 out <<
"Global number of entries: " << getGlobalNumElements () <<
endl
1887 <<
"Minimum global index: " << getMinAllGlobalIndex () <<
endl
1888 <<
"Maximum global index: " << getMaxAllGlobalIndex () <<
endl
1889 <<
"Index base: " << getIndexBase () <<
endl
1891 <<
"Uniform: " << (isUniform () ?
"true" :
"false") <<
endl
1892 <<
"Contiguous: " << (isContiguous () ?
"true" :
"false") <<
endl
1893 <<
"Distributed: " << (isDistributed () ?
"true" :
"false") <<
endl;
1898 const std::string
lclStr = this->localDescribeToString (
vl);
1903 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1904 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1923 return Teuchos::null;
1925 else if (
newComm->getSize () == 1) {
1936 newMap->indexBase_ = this->indexBase_;
1937 newMap->numGlobalElements_ = this->numLocalElements_;
1938 newMap->numLocalElements_ = this->numLocalElements_;
1939 newMap->minMyGID_ = this->minMyGID_;
1940 newMap->maxMyGID_ = this->maxMyGID_;
1941 newMap->minAllGID_ = this->minMyGID_;
1942 newMap->maxAllGID_ = this->maxMyGID_;
1943 newMap->firstContiguousGID_ = this->firstContiguousGID_;
1944 newMap->lastContiguousGID_ = this->lastContiguousGID_;
1947 newMap->uniform_ = this->uniform_;
1948 newMap->contiguous_ = this->contiguous_;
1951 newMap->distributed_ =
false;
1952 newMap->lgMap_ = this->lgMap_;
1953 newMap->lgMapHost_ = this->lgMapHost_;
1954 newMap->glMap_ = this->glMap_;
1955 newMap->glMapHost_ = this->glMapHost_;
1976 const GST RECOMPUTE = Tpetra::Details::OrdinalTraits<GST>::invalid ();
1992 auto lgMap = this->getMyGlobalIndices ();
1994 typename std::decay<
decltype (
lgMap.extent (0)) >::type;
1996 static_cast<size_type
> (this->getLocalNumElements ());
1997 using Teuchos::TypeNameTraits;
2000 "Tpetra::Map::replaceCommWithSubset: Result of getMyGlobalIndices() "
2001 "has length " <<
lgMap.extent (0) <<
" (of type " <<
2003 " = " <<
this->getLocalNumElements () <<
". The latter, upon being "
2005 "becomes " <<
lclNumInds <<
". Please report this bug to the Tpetra "
2008 Teuchos::ArrayView<const GO>
lgMap = this->getLocalElementList ();
2011 const GO
indexBase = this->getIndexBase ();
2018 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2019 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
2023 using Teuchos::Comm;
2024 using Teuchos::null;
2025 using Teuchos::outArg;
2028 using Teuchos::REDUCE_MIN;
2029 using Teuchos::reduceAll;
2036 const int color = (numLocalElements_ == 0) ? 0 : 1;
2053 map->indexBase_ = indexBase_;
2054 map->numGlobalElements_ = numGlobalElements_;
2055 map->numLocalElements_ = numLocalElements_;
2056 map->minMyGID_ = minMyGID_;
2057 map->maxMyGID_ = maxMyGID_;
2058 map->minAllGID_ = minAllGID_;
2059 map->maxAllGID_ = maxAllGID_;
2060 map->firstContiguousGID_= firstContiguousGID_;
2061 map->lastContiguousGID_ = lastContiguousGID_;
2065 map->uniform_ = uniform_;
2066 map->contiguous_ = contiguous_;
2081 if (! distributed_ ||
newComm->getSize () == 1) {
2082 map->distributed_ =
false;
2084 const int iOwnAllGids = (numLocalElements_ == numGlobalElements_) ? 1 : 0;
2090 map->lgMap_ = lgMap_;
2091 map->lgMapHost_ = lgMapHost_;
2092 map->glMap_ = glMap_;
2093 map->glMapHost_ = glMapHost_;
2110 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2115 directory_.is_null (), std::logic_error,
"Tpetra::Map::setupDirectory: "
2116 "The Directory is null. "
2117 "Please report this bug to the Tpetra developers.");
2121 if (! directory_->initialized ()) {
2122 directory_->initialize (*
this);
2126 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2130 const Teuchos::ArrayView<int>&
PIDs,
2131 const Teuchos::ArrayView<LocalOrdinal>&
LIDs)
const
2133 using Tpetra::Details::OrdinalTraits;
2136 using size_type = Teuchos::ArrayView<int>::size_type;
2141 std::unique_ptr<std::string>
prefix;
2144 "Map",
"getRemoteIndexList(GIDs,PIDs,LIDs)");
2145 std::ostringstream
os;
2149 std::cerr <<
os.str();
2158 if (getGlobalNumElements () == 0) {
2159 if (
GIDs.size () == 0) {
2161 std::ostringstream
os;
2162 os << *
prefix <<
"Done; both Map & input are empty" <<
endl;
2163 std::cerr <<
os.str();
2169 std::ostringstream
os;
2170 os << *
prefix <<
"Done: Map is empty on all processes, "
2171 "so all output PIDs & LIDs are invalid (-1)." <<
endl;
2172 std::cerr <<
os.str();
2174 for (size_type
k = 0;
k <
PIDs.size (); ++
k) {
2177 for (size_type
k = 0;
k <
LIDs.size (); ++
k) {
2189 std::ostringstream
os;
2191 std::cerr <<
os.str();
2195 std::ostringstream
os;
2196 os << *
prefix <<
"Call directory_->getDirectoryEntries" <<
endl;
2197 std::cerr <<
os.str();
2200 directory_->getDirectoryEntries (*
this,
GIDs,
PIDs,
LIDs);
2202 std::ostringstream
os;
2203 os << *
prefix <<
"Done; getDirectoryEntries returned "
2210 std::cerr <<
os.str();
2215 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2219 const Teuchos::ArrayView<int> &
PIDs)
const
2227 std::unique_ptr<std::string>
prefix;
2230 "Map",
"getRemoteIndexList(GIDs,PIDs)");
2231 std::ostringstream
os;
2235 std::cerr <<
os.str();
2238 if (getGlobalNumElements () == 0) {
2239 if (
GIDs.size () == 0) {
2241 std::ostringstream
os;
2242 os << *
prefix <<
"Done; both Map & input are empty" <<
endl;
2243 std::cerr <<
os.str();
2249 std::ostringstream
os;
2250 os << *
prefix <<
"Done: Map is empty on all processes, "
2251 "so all output PIDs are invalid (-1)." <<
endl;
2252 std::cerr <<
os.str();
2254 for (Teuchos::ArrayView<int>::size_type
k = 0;
k <
PIDs.size (); ++
k) {
2255 PIDs[
k] = Tpetra::Details::OrdinalTraits<int>::invalid ();
2266 std::ostringstream
os;
2268 std::cerr <<
os.str();
2272 std::ostringstream
os;
2273 os << *
prefix <<
"Call directory_->getDirectoryEntries" <<
endl;
2274 std::cerr <<
os.str();
2277 directory_->getDirectoryEntries(*
this,
GIDs,
PIDs);
2279 std::ostringstream
os;
2280 os << *
prefix <<
"Done; getDirectoryEntries returned "
2285 std::cerr <<
os.str();
2290 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2291 Teuchos::RCP<const Teuchos::Comm<int> >
2296 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2302 using Teuchos::outArg;
2303 using Teuchos::REDUCE_MIN;
2304 using Teuchos::reduceAll;
2308 std::unique_ptr<std::string>
prefix;
2311 comm_.getRawPtr(),
"Map",
"checkIsDist");
2312 std::ostringstream
os;
2314 std::cerr <<
os.str();
2317 bool global =
false;
2318 if (comm_->getSize () > 1) {
2322 if (numGlobalElements_ == as<global_size_t> (numLocalElements_)) {
2335 reduceAll<int, int> (*comm_, REDUCE_MIN, localRep, outArg (allLocalRep));
2336 if (allLocalRep != 1) {
2346 std::ostringstream os;
2347 os << *prefix <<
"Done; global=" << (global ?
"true" :
"false")
2349 std::cerr << os.str();
2356template <
class LocalOrdinal,
class GlobalOrdinal>
2357Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2359 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2361 typedef LocalOrdinal LO;
2362 typedef GlobalOrdinal GO;
2363 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2364 return createLocalMapWithNode<LO, GO, NT> (numElements, comm);
2367template <
class LocalOrdinal,
class GlobalOrdinal>
2368Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2370 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2372 typedef LocalOrdinal LO;
2373 typedef GlobalOrdinal GO;
2374 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2375 return createUniformContigMapWithNode<LO, GO, NT> (numElements, comm);
2378template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2379Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2381 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2386 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2388 return rcp (
new map_type (numElements, indexBase, comm, GloballyDistributed));
2391template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2392Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2394 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2400 const GlobalOrdinal indexBase = 0;
2403 return rcp (
new map_type (globalNumElts, indexBase, comm, LocallyReplicated));
2406template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2407Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2409 const size_t localNumElements,
2410 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2415 const GlobalOrdinal indexBase = 0;
2417 return rcp (
new map_type (numElements, localNumElements, indexBase, comm));
2420template <
class LocalOrdinal,
class GlobalOrdinal>
2421Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2423 const size_t localNumElements,
2424 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2426 typedef LocalOrdinal LO;
2427 typedef GlobalOrdinal GO;
2433template <
class LocalOrdinal,
class GlobalOrdinal>
2434Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2436 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2438 typedef LocalOrdinal LO;
2439 typedef GlobalOrdinal GO;
2445template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2446Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2448 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2454 const GST INV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2458 const GlobalOrdinal indexBase = 0;
2460 return rcp (
new map_type (INV, elementList, indexBase, comm));
2463template<
class LO,
class GO,
class NT>
2464Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >
2467 using Details::verbosePrintArray;
2468 using Teuchos::Array;
2469 using Teuchos::ArrayView;
2477 const bool verbose = Details::Behavior::verbose(
"Map");
2478 std::unique_ptr<std::string> prefix;
2480 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2481 prefix = Details::createPrefix(
2482 comm.getRawPtr(),
"createOneToOne(Map)");
2483 std::ostringstream os;
2484 os << *prefix <<
"Start" << endl;
2487 const size_t maxNumToPrint = verbose ?
2488 Details::Behavior::verbosePrintCountThreshold() : size_t(0);
2489 const GST GINV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2490 const int myRank = M->getComm ()->getRank ();
2496 if (! M->isDistributed ()) {
2503 const GST numGlobalEntries = M->getGlobalNumElements ();
2504 if (M->isContiguous()) {
2505 const size_t numLocalEntries =
2506 (myRank == 0) ? as<size_t>(numGlobalEntries) : size_t(0);
2508 std::ostringstream os;
2509 os << *prefix <<
"Input is locally replicated & contiguous; "
2510 "numLocalEntries=" << numLocalEntries << endl;
2514 rcp(
new map_type(numGlobalEntries, numLocalEntries,
2515 M->getIndexBase(), M->getComm()));
2517 std::ostringstream os;
2518 os << *prefix <<
"Done" << endl;
2525 std::ostringstream os;
2526 os << *prefix <<
"Input is locally replicated & noncontiguous"
2530 ArrayView<const GO> myGids =
2531 (myRank == 0) ? M->getLocalElementList() : Teuchos::null;
2533 rcp(
new map_type(GINV, myGids(), M->getIndexBase(),
2536 std::ostringstream os;
2537 os << *prefix <<
"Done" << endl;
2543 else if (M->isContiguous ()) {
2545 std::ostringstream os;
2546 os << *prefix <<
"Input is distributed & contiguous" << endl;
2555 std::ostringstream os;
2556 os << *prefix <<
"Input is distributed & noncontiguous" << endl;
2560 const size_t numMyElems = M->getLocalNumElements ();
2561 ArrayView<const GO> myElems = M->getLocalElementList ();
2562 Array<int> owner_procs_vec (numMyElems);
2565 std::ostringstream os;
2566 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2571 directory.getDirectoryEntries (*M, myElems, owner_procs_vec ());
2573 std::ostringstream os;
2574 os << *prefix <<
"getDirectoryEntries result: ";
2580 Array<GO> myOwned_vec (numMyElems);
2581 size_t numMyOwnedElems = 0;
2582 for (
size_t i = 0; i < numMyElems; ++i) {
2583 const GO GID = myElems[i];
2584 const int owner = owner_procs_vec[i];
2586 if (myRank == owner) {
2587 myOwned_vec[numMyOwnedElems++] = GID;
2590 myOwned_vec.resize (numMyOwnedElems);
2593 std::ostringstream os;
2594 os << *prefix <<
"Create Map: ";
2599 auto retMap = rcp(
new map_type(GINV, myOwned_vec(),
2600 M->getIndexBase(), M->getComm()));
2602 std::ostringstream os;
2603 os << *prefix <<
"Done" << endl;
2610template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2611Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2615 using Details::Behavior;
2616 using Details::verbosePrintArray;
2617 using Teuchos::Array;
2618 using Teuchos::ArrayView;
2621 using Teuchos::toString;
2624 using LO = LocalOrdinal;
2625 using GO = GlobalOrdinal;
2628 const bool verbose = Behavior::verbose(
"Map");
2629 std::unique_ptr<std::string> prefix;
2631 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2632 prefix = Details::createPrefix(
2633 comm.getRawPtr(),
"createOneToOne(Map,TieBreak)");
2634 std::ostringstream os;
2635 os << *prefix <<
"Start" << endl;
2638 const size_t maxNumToPrint = verbose ?
2639 Behavior::verbosePrintCountThreshold() : size_t(0);
2646 std::ostringstream os;
2647 os << *prefix <<
"Initialize Directory" << endl;
2650 directory.initialize (*M, tie_break);
2652 std::ostringstream os;
2653 os << *prefix <<
"Done initializing Directory" << endl;
2656 size_t numMyElems = M->getLocalNumElements ();
2657 ArrayView<const GO> myElems = M->getLocalElementList ();
2658 Array<int> owner_procs_vec (numMyElems);
2660 std::ostringstream os;
2661 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2666 directory.getDirectoryEntries (*M, myElems, owner_procs_vec ());
2668 std::ostringstream os;
2669 os << *prefix <<
"getDirectoryEntries result: ";
2675 const int myRank = M->getComm()->getRank();
2676 Array<GO> myOwned_vec (numMyElems);
2677 size_t numMyOwnedElems = 0;
2678 for (
size_t i = 0; i < numMyElems; ++i) {
2679 const GO GID = myElems[i];
2680 const int owner = owner_procs_vec[i];
2681 if (myRank == owner) {
2682 myOwned_vec[numMyOwnedElems++] = GID;
2685 myOwned_vec.resize (numMyOwnedElems);
2690 Tpetra::Details::OrdinalTraits<global_size_t>::invalid ();
2692 std::ostringstream os;
2693 os << *prefix <<
"Create Map: ";
2698 RCP<const map_type> retMap
2699 (
new map_type (GINV, myOwned_vec (), M->getIndexBase (),
2702 std::ostringstream os;
2703 os << *prefix <<
"Done" << endl;
2717#define TPETRA_MAP_INSTANT(LO,GO,NODE) \
2719 template class Map< LO , GO , NODE >; \
2721 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2722 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \
2723 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2725 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2726 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2727 const size_t localNumElements, \
2728 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2730 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2731 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \
2732 const Teuchos::RCP<const Teuchos::Comm<int> > &comm); \
2734 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2735 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2736 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2738 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2739 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M); \
2741 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2742 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M, \
2743 const Tpetra::Details::TieBreak<LO,GO>& tie_break); \
2747#define TPETRA_MAP_INSTANT_DEFAULTNODE(LO,GO) \
2748 template Teuchos::RCP< const Map<LO,GO> > \
2749 createLocalMap<LO,GO>( const size_t, const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2751 template Teuchos::RCP< const Map<LO,GO> > \
2752 createContigMap<LO,GO>( global_size_t, size_t, \
2753 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2755 template Teuchos::RCP< const Map<LO,GO> > \
2756 createNonContigMap(const Teuchos::ArrayView<const GO> &, \
2757 const Teuchos::RCP<const Teuchos::Comm<int> > &); \
2759 template Teuchos::RCP< const Map<LO,GO> > \
2760 createUniformContigMap<LO,GO>( const global_size_t, \
2761 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...