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>
119 comm_ (new Teuchos::SerialComm<int> ()),
121 numGlobalElements_ (0),
122 numLocalElements_ (0),
123 minMyGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
124 maxMyGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
125 minAllGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
126 maxAllGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
127 firstContiguousGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
128 lastContiguousGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
131 distributed_ (false),
132 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
138 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
146 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
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;
170 os << *prefix <<
"Start" << endl;
171 std::cerr << os.str();
178 GST proc0NumGlobalElements = numGlobalElements;
179 broadcast(*comm_, 0, outArg(proc0NumGlobalElements));
180 GST minNumGlobalElements = numGlobalElements;
181 GST maxNumGlobalElements = numGlobalElements;
182 reduceAll(*comm, REDUCE_MIN, numGlobalElements,
183 outArg(minNumGlobalElements));
184 reduceAll(*comm, REDUCE_MAX, numGlobalElements,
185 outArg(maxNumGlobalElements));
186 TEUCHOS_TEST_FOR_EXCEPTION
187 (minNumGlobalElements != maxNumGlobalElements ||
188 numGlobalElements != minNumGlobalElements,
189 std::invalid_argument, exPfx <<
"All processes must "
190 "provide the same number of global elements. Process 0 set "
191 "numGlobalElements="<< proc0NumGlobalElements <<
". The "
192 "calling process " << comm->getRank() <<
" set "
193 "numGlobalElements=" << numGlobalElements <<
". The min "
194 "and max values over all processes are "
195 << minNumGlobalElements <<
" resp. " << maxNumGlobalElements
198 GO proc0IndexBase = indexBase;
199 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
200 GO minIndexBase = indexBase;
201 GO maxIndexBase = indexBase;
202 reduceAll(*comm, REDUCE_MIN, indexBase, outArg(minIndexBase));
203 reduceAll(*comm, REDUCE_MAX, indexBase, outArg(maxIndexBase));
204 TEUCHOS_TEST_FOR_EXCEPTION
205 (minIndexBase != maxIndexBase || indexBase != minIndexBase,
206 std::invalid_argument, exPfx <<
"All processes must "
207 "provide the same indexBase argument. Process 0 set "
208 "indexBase=" << proc0IndexBase <<
". The calling process "
209 << comm->getRank() <<
" set indexBase=" << indexBase
210 <<
". The min and max values over all processes are "
211 << minIndexBase <<
" resp. " << maxIndexBase <<
".");
231 TEUCHOS_TEST_FOR_EXCEPTION(
232 (numGlobalElements < 1 && numGlobalElements != 0),
233 std::invalid_argument, exPfx <<
"numGlobalElements (= "
234 << numGlobalElements <<
") must be nonnegative.");
236 TEUCHOS_TEST_FOR_EXCEPTION
237 (numGlobalElements == GSTI, std::invalid_argument, exPfx <<
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().");
246 size_t numLocalElements = 0;
247 if (lOrG == GloballyDistributed) {
262 const GST numProcs =
static_cast<GST
> (comm_->getSize ());
263 const GST myRank =
static_cast<GST
> (comm_->getRank ());
264 const GST quotient = numGlobalElements / numProcs;
265 const GST remainder = numGlobalElements - quotient * numProcs;
268 if (myRank < remainder) {
269 numLocalElements =
static_cast<size_t> (1) + static_cast<size_t> (quotient);
272 startIndex = as<GO> (myRank) * as<GO> (numLocalElements);
274 numLocalElements = as<size_t> (quotient);
275 startIndex = as<GO> (myRank) * as<GO> (numLocalElements) +
279 minMyGID_ = indexBase + startIndex;
280 maxMyGID_ = indexBase + startIndex + numLocalElements - 1;
281 minAllGID_ = indexBase;
282 maxAllGID_ = indexBase + numGlobalElements - 1;
283 distributed_ = (numProcs > 1);
286 numLocalElements = as<size_t> (numGlobalElements);
287 minMyGID_ = indexBase;
288 maxMyGID_ = indexBase + numGlobalElements - 1;
289 distributed_ =
false;
292 minAllGID_ = indexBase;
293 maxAllGID_ = indexBase + numGlobalElements - 1;
294 indexBase_ = indexBase;
295 numGlobalElements_ = numGlobalElements;
296 numLocalElements_ = numLocalElements;
297 firstContiguousGID_ = minMyGID_;
298 lastContiguousGID_ = maxMyGID_;
305 std::ostringstream os;
306 os << *prefix <<
"Done" << endl;
307 std::cerr << os.str();
312 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
315 const size_t numLocalElements,
317 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) :
320 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
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 ();
334 const char funcName[] =
335 "Map(gblNumInds,lclNumInds,indexBase,comm)";
337 "Tpetra::Map::Map(gblNumInds,lclNumInds,indexBase,comm): ";
338 const char suffix[] =
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;
348 os << *prefix <<
"Start" << endl;
349 std::cerr << os.str();
355 GST debugGlobalSum {};
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;
376 if (numGlobalElements != GSTI) {
377 numGlobalElements_ = numGlobalElements;
384 const int numProcs = comm->getSize ();
385 GST globalSum = scanResult;
387 broadcast (*comm, numProcs - 1, outArg (globalSum));
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;
423 os << *prefix <<
"Done" << endl;
424 std::cerr << os.str();
428 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
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));
468 GST proc0NumGlobalElements = numGlobalElements;
469 broadcast<int, GST> (*comm_, 0, outArg (proc0NumGlobalElements));
470 GST minNumGlobalElements = numGlobalElements;
471 GST maxNumGlobalElements = numGlobalElements;
472 reduceAll<int, GST> (*comm, REDUCE_MIN, numGlobalElements,
473 outArg (minNumGlobalElements));
474 reduceAll<int, GST> (*comm, REDUCE_MAX, numGlobalElements,
475 outArg (maxNumGlobalElements));
476 TEUCHOS_TEST_FOR_EXCEPTION
477 (minNumGlobalElements != maxNumGlobalElements ||
478 numGlobalElements != minNumGlobalElements,
479 std::invalid_argument, errorMessagePrefix <<
"All processes "
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"
485 "=" << proc0NumGlobalElements <<
". The calling process "
486 << comm->getRank() <<
" set numGlobalElements=" <<
487 numGlobalElements <<
". The min and max values over all "
488 "processes are " << minNumGlobalElements <<
" resp. " <<
489 maxNumGlobalElements <<
".");
491 GO proc0IndexBase = indexBase;
492 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
493 GO minIndexBase = indexBase;
494 GO maxIndexBase = indexBase;
495 reduceAll<int, GO> (*comm, REDUCE_MIN, indexBase, outArg (minIndexBase));
496 reduceAll<int, GO> (*comm, REDUCE_MAX, indexBase, outArg (maxIndexBase));
497 TEUCHOS_TEST_FOR_EXCEPTION
498 (minIndexBase != maxIndexBase || indexBase != minIndexBase,
499 std::invalid_argument, errorMessagePrefix <<
500 "All processes must provide the same indexBase argument. "
501 "Process 0 set indexBase = " << proc0IndexBase <<
". The "
502 "calling process " << comm->getRank() <<
" set indexBase="
503 << indexBase <<
". The min and max values over all "
504 "processes are " << minIndexBase <<
" resp. " << maxIndexBase
509 TEUCHOS_TEST_FOR_EXCEPTION
510 (numGlobalElements != GSTI &&
511 debugGlobalSum != numGlobalElements, std::invalid_argument,
512 errorMessagePrefix <<
"The sum of each process' number of "
513 "indices over all processes, " << debugGlobalSum <<
", != "
514 <<
"numGlobalElements=" << numGlobalElements <<
". If you "
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.");
520 return debugGlobalSum;
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;
550 using GO = global_ordinal_type;
552 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
555 TEUCHOS_TEST_FOR_EXCEPTION
556 (! Kokkos::is_initialized (), std::runtime_error,
557 errorMessagePrefix <<
"The Kokkos execution space "
558 << Teuchos::TypeNameTraits<execution_space>::name()
559 <<
" has not been initialized. "
560 "Please initialize it before creating a Map.")
573 const
size_t numLocalElements(entryList_host.size());
575 initialNonuniformDebugCheck(errorMessagePrefix, numGlobalElements,
576 numLocalElements, indexBase, comm);
586 if (numGlobalElements != GSTI) {
587 numGlobalElements_ = numGlobalElements;
590 reduceAll(*comm, REDUCE_SUM,
591 static_cast<GST>(numLocalElements),
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_;
682 const std::pair<size_t, size_t> ncRange (i, entryList_host.extent (0));
683 auto nonContigGids_host = subview (entryList_host, ncRange);
684 TEUCHOS_TEST_FOR_EXCEPTION
685 (static_cast<size_t> (nonContigGids_host.extent (0)) !=
686 static_cast<size_t> (entryList_host.extent (0) - i),
687 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
688 "nonContigGids_host.extent(0) = "
689 << nonContigGids_host.extent (0)
690 <<
" != entryList_host.extent(0) - i = "
691 << (entryList_host.extent (0) - i) <<
" = "
692 << entryList_host.extent (0) <<
" - " << i
693 <<
". Please report this bug to the Tpetra developers.");
697 View<GO*, LayoutLeft, device_type>
698 nonContigGids (view_alloc (
"nonContigGids", WithoutInitializing),
699 nonContigGids_host.size ());
704 glMap_ = global_to_local_table_type(nonContigGids,
707 static_cast<LO> (i));
709 glMapHost_ = global_to_local_table_host_type(glMap_);
717 for ( ; i < numLocalElements_; ++i) {
718 const GO curGid = entryList_host[i];
719 const LO curLid =
static_cast<LO
> (i);
720 lgMap_host[curLid] = curGid;
724 if (curGid < minMyGID_) {
727 if (curGid > maxMyGID_) {
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;
779 minMaxInput[0] = -minMyGID_;
780 minMaxInput[1] = maxMyGID_;
781 minMaxInput[2] = localDist;
787 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
788 minAllGID_ = -minMaxOutput[0];
789 maxAllGID_ = minMaxOutput[1];
790 const GO globalDist = minMaxOutput[2];
791 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
795 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
796 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
797 distributed_ = checkIsDist ();
802 TEUCHOS_TEST_FOR_EXCEPTION(
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>
816 const GlobalOrdinal indexList[],
817 const LocalOrdinal indexListSize,
818 const GlobalOrdinal indexBase,
819 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
822 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
825 const char funcName[] =
826 "Map(gblNumInds,indexList,indexListSize,indexBase,comm)";
829 std::unique_ptr<std::string> prefix;
832 comm_.getRawPtr(),
"Map", funcName);
833 std::ostringstream os;
834 os << *prefix <<
"Start" << endl;
835 std::cerr << os.str();
838 checkMapInputArray (
"(GST, const GO[], LO, GO, comm)",
839 indexList, static_cast<size_t> (indexListSize),
844 const GlobalOrdinal*
const indsRaw = indexListSize == 0 ? NULL : indexList;
845 Kokkos::View<
const GlobalOrdinal*,
848 Kokkos::MemoryUnmanaged> inds (indsRaw, indexListSize);
849 initWithNonownedHostIndexList(funcName, numGlobalElements, inds,
852 std::ostringstream os;
853 os << *prefix <<
"Done" << endl;
854 std::cerr << os.str();
858 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
861 const Teuchos::ArrayView<const GlobalOrdinal>& entryList,
862 const GlobalOrdinal indexBase,
863 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
866 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
869 const char funcName[] =
870 "Map(gblNumInds,entryList(Teuchos::ArrayView),indexBase,comm)";
873 std::unique_ptr<std::string> prefix;
876 comm_.getRawPtr(),
"Map", funcName);
877 std::ostringstream os;
878 os << *prefix <<
"Start" << endl;
879 std::cerr << os.str();
882 const size_t numLclInds =
static_cast<size_t> (entryList.size ());
883 checkMapInputArray (
"(GST, ArrayView, GO, comm)",
884 entryList.getRawPtr (), numLclInds,
889 const GlobalOrdinal*
const indsRaw =
890 numLclInds == 0 ? NULL : entryList.getRawPtr ();
891 Kokkos::View<
const GlobalOrdinal*,
894 Kokkos::MemoryUnmanaged> inds (indsRaw, numLclInds);
895 initWithNonownedHostIndexList(funcName, numGlobalElements, inds,
898 std::ostringstream os;
899 os << *prefix <<
"Done" << endl;
900 std::cerr << os.str();
904 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
907 const Kokkos::View<const GlobalOrdinal*, device_type>& entryList,
908 const GlobalOrdinal indexBase,
909 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
912 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
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 ();
935 const char funcName[] =
936 "Map(gblNumInds,entryList(Kokkos::View),indexBase,comm)";
939 std::unique_ptr<std::string> prefix;
942 comm_.getRawPtr(),
"Map", funcName);
943 std::ostringstream os;
944 os << *prefix <<
"Start" << endl;
945 std::cerr << os.str();
948 checkMapInputArray (
"(GST, Kokkos::View, GO, comm)",
950 static_cast<size_t> (entryList.extent (0)),
964 const size_t numLocalElements(entryList.size());
966 initialNonuniformDebugCheck(funcName, numGlobalElements,
967 numLocalElements, indexBase, comm);
977 if (numGlobalElements != GSTI) {
978 numGlobalElements_ = numGlobalElements;
981 reduceAll(*comm, REDUCE_SUM,
982 static_cast<GST>(numLocalElements),
983 outArg(numGlobalElements_));
1009 numLocalElements_ = numLocalElements;
1010 indexBase_ = indexBase;
1012 minMyGID_ = indexBase_;
1013 maxMyGID_ = indexBase_;
1023 if (numLocalElements_ > 0) {
1027 typename decltype (lgMap_)::non_const_type lgMap
1028 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
1030 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
1032 using array_layout =
1033 typename View<const GO*, device_type>::array_layout;
1034 View<GO*, array_layout, Kokkos::HostSpace> entryList_host
1035 (view_alloc (
"entryList_host", WithoutInitializing),
1036 entryList.extent(0));
1040 firstContiguousGID_ = entryList_host[0];
1041 lastContiguousGID_ = firstContiguousGID_+1;
1049 lgMap_host[0] = firstContiguousGID_;
1051 for ( ; i < numLocalElements_; ++i) {
1052 const GO curGid = entryList_host[i];
1053 const LO curLid = as<LO> (i);
1055 if (lastContiguousGID_ != curGid)
break;
1061 lgMap_host[curLid] = curGid;
1062 ++lastContiguousGID_;
1064 --lastContiguousGID_;
1069 minMyGID_ = firstContiguousGID_;
1070 maxMyGID_ = lastContiguousGID_;
1075 const std::pair<size_t, size_t> ncRange (i, entryList.extent (0));
1076 auto nonContigGids = subview (entryList, ncRange);
1077 TEUCHOS_TEST_FOR_EXCEPTION
1078 (static_cast<size_t> (nonContigGids.extent (0)) !=
1079 static_cast<size_t> (entryList.extent (0) - i),
1080 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
1081 "nonContigGids.extent(0) = "
1082 << nonContigGids.extent (0)
1083 <<
" != entryList.extent(0) - i = "
1084 << (entryList.extent (0) - i) <<
" = "
1085 << 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) {
1102 const GO curGid = entryList_host[i];
1103 const LO curLid =
static_cast<LO
> (i);
1104 lgMap_host[curLid] = curGid;
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."
1219 ::Tpetra::Details::printOnce (std::cerr, os.str (),
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."
1246 ::Tpetra::Details::printOnce (std::cerr, os.str (), comm.getRawPtr ());
1254 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1258 TEUCHOS_TEST_FOR_EXCEPTION(
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 ()) {
1274 if (globalIndex < getMinGlobalIndex () ||
1275 globalIndex > getMaxGlobalIndex ()) {
1276 return Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1278 return static_cast<LocalOrdinal
> (globalIndex - getMinGlobalIndex ());
1280 else if (globalIndex >= firstContiguousGID_ &&
1281 globalIndex <= lastContiguousGID_) {
1282 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGID_);
1288 return glMapHost_.get (globalIndex);
1292 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1297 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
1298 return Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
1300 if (isContiguous ()) {
1301 return getMinGlobalIndex () + localIndex;
1308 return lgMapHost_[localIndex];
1312 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1317 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
1324 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1328 return this->getLocalElement (globalIndex) !=
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 ()) {
1382 else if (isContiguous () && isUniform () &&
1390 lgMap_.extent (0) != 0 && map.lgMap_.extent (0) != 0 &&
1391 lgMap_.data () == map.lgMap_.data ()) {
1405 TEUCHOS_TEST_FOR_EXCEPTION(
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.");
1412 const int locallyCompat =
1415 int globallyCompat = 0;
1416 reduceAll<int, int> (*comm_, REDUCE_MIN, locallyCompat, outArg (globallyCompat));
1417 return (globallyCompat == 1);
1420 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1425 using Teuchos::ArrayView;
1427 using size_type =
typename ArrayView<const GO>::size_type;
1450 if (isContiguous ()) {
1455 TEUCHOS_TEST_FOR_EXCEPTION(
1456 ! this->isContiguous () || map.
isContiguous (), std::logic_error,
1457 "Tpetra::Map::locallySameAs: BUG");
1459 const GO minLhsGid = this->getMinGlobalIndex ();
1460 const size_type numRhsElts = rhsElts.size ();
1461 for (size_type k = 0; k < numRhsElts; ++k) {
1462 const GO curLhsGid = minLhsGid +
static_cast<GO
> (k);
1463 if (curLhsGid != rhsElts[k]) {
1471 TEUCHOS_TEST_FOR_EXCEPTION(
1472 this->isContiguous () || ! map.
isContiguous (), std::logic_error,
1473 "Tpetra::Map::locallySameAs: BUG");
1474 ArrayView<const GO> lhsElts = this->getLocalElementList ();
1476 const size_type numLhsElts = lhsElts.size ();
1477 for (size_type k = 0; k < numLhsElts; ++k) {
1478 const GO curRhsGid = minRhsGid +
static_cast<GO
> (k);
1479 if (curRhsGid != lhsElts[k]) {
1485 else if (this->lgMap_.data () == map.lgMap_.data ()) {
1495 ArrayView<const GO> lhsElts = getLocalElementList ();
1501 return std::equal (lhsElts.begin (), lhsElts.end (), rhsElts.begin ());
1507 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1520 auto lmap2 = this->getLocalMap();
1522 auto numLocalElements1 = lmap1.getLocalNumElements();
1523 auto numLocalElements2 = lmap2.getLocalNumElements();
1525 if (numLocalElements1 > numLocalElements2) {
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(
1551 range_type(0, numLocalElements1),
1552 KOKKOS_LAMBDA (
const LO i, LO& diff) {
1553 diff += (lmap1.getGlobalElement(i) != lmap2.getGlobalElement(i));
1556 return (numDiff == 0);
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 ()) {
1599 else if (isContiguous () && isUniform () &&
1620 const int isSame_lcl = locallySameAs (map) ? 1 : 0;
1624 reduceAll<int, int> (*comm_, REDUCE_MIN, isSame_lcl, outArg (isSame_gbl));
1625 return isSame_gbl == 1;
1629 template <
class LO,
class GO,
class DT>
1632 FillLgMap (
const Kokkos::View<GO*, DT>& lgMap,
1633 const GO startGid) :
1634 lgMap_ (lgMap), startGid_ (startGid)
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
1660 using const_lg_view_type = decltype(lgMap_);
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;
1670 os << *prefix <<
"Start" << endl;
1671 std::cerr << os.str();
1677 const bool needToCreateLocalToGlobalMapping =
1678 lgMap_.extent (0) == 0 && numLocalElements_ > 0;
1680 if (needToCreateLocalToGlobalMapping) {
1682 std::ostringstream os;
1683 os << *prefix <<
"Need to create lgMap" << endl;
1684 std::cerr << os.str();
1689 TEUCHOS_TEST_FOR_EXCEPTION
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;
1700 lg_view_type lgMap (
"lgMap", numElts);
1702 std::ostringstream os;
1703 os << *prefix <<
"Fill lgMap" << endl;
1704 std::cerr << os.str();
1706 FillLgMap<LO, GO, no_uvm_device_type> fillIt (lgMap, minMyGID_);
1709 std::ostringstream os;
1710 os << *prefix <<
"Copy lgMap to lgMapHost" << endl;
1711 std::cerr << os.str();
1715 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
1721 lgMapHost_ = lgMapHost;
1725 std::ostringstream os;
1726 os << *prefix <<
"Done" << endl;
1727 std::cerr << os.str();
1732 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1733 Teuchos::ArrayView<const GlobalOrdinal>
1741 (void) this->getMyGlobalIndices ();
1744 const GO* lgMapHostRawPtr = lgMapHost_.data ();
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: {"
1765 <<
"LocalOrdinalType: " << TypeNameTraits<LocalOrdinal>::name ()
1766 <<
", GlobalOrdinalType: " << TypeNameTraits<GlobalOrdinal>::name ()
1767 <<
", NodeType: " << TypeNameTraits<Node>::name ();
1768 if (this->getObjectLabel () !=
"") {
1769 os <<
", Label: \"" << this->getObjectLabel () <<
"\"";
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 =
1843 (verbLevel == VERB_DEFAULT) ? VERB_LOW : verbLevel;
1845 if (vl == VERB_NONE) {
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;
1877 Teuchos::OSTab tab2 (out);
1878 out <<
"LocalOrdinal: " << TypeNameTraits<LO>::name () << endl
1879 <<
"GlobalOrdinal: " << TypeNameTraits<GO>::name () << endl
1880 <<
"Node: " << TypeNameTraits<Node>::name () << endl;
1882 const std::string label = this->getObjectLabel ();
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
1890 <<
"Number of processes: " << numProcs << endl
1891 <<
"Uniform: " << (isUniform () ?
"true" :
"false") << endl
1892 <<
"Contiguous: " << (isContiguous () ?
"true" :
"false") << endl
1893 <<
"Distributed: " << (isDistributed () ?
"true" :
"false") << endl;
1897 if (vl >= VERB_HIGH) {
1898 const std::string lclStr = this->localDescribeToString (vl);
1903 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1904 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1922 if (newComm.is_null () || newComm->getSize () < 1) {
1923 return Teuchos::null;
1925 else if (newComm->getSize () == 1) {
1930 RCP<map_type> newMap (
new map_type ());
1932 newMap->comm_ = newComm;
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;
1995 const size_type lclNumInds =
1996 static_cast<size_type
> (this->getLocalNumElements ());
1997 using Teuchos::TypeNameTraits;
1998 TEUCHOS_TEST_FOR_EXCEPTION
1999 (lgMap.extent (0) != lclNumInds, std::logic_error,
2000 "Tpetra::Map::replaceCommWithSubset: Result of getMyGlobalIndices() "
2001 "has length " << lgMap.extent (0) <<
" (of type " <<
2002 TypeNameTraits<size_type>::name () <<
") != this->getLocalNumElements()"
2003 " = " << this->getLocalNumElements () <<
". The latter, upon being "
2004 "cast to size_type = " << TypeNameTraits<size_type>::name () <<
", "
2005 "becomes " << lclNumInds <<
". Please report this bug to the Tpetra "
2008 Teuchos::ArrayView<const GO> lgMap = this->getLocalElementList ();
2011 const GO indexBase = this->getIndexBase ();
2013 auto lgMap_device = Kokkos::create_mirror_view_and_copy(
device_type(), lgMap);
2014 return rcp (
new map_type (RECOMPUTE, lgMap_device, indexBase, newComm));
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;
2041 RCP<const Comm<int> > newComm = comm_->split (color, 0);
2047 if (newComm.is_null ()) {
2050 RCP<Map> map = rcp (
new Map ());
2052 map->comm_ = newComm;
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;
2085 int allProcsOwnAllGids = 0;
2086 reduceAll<int, int> (*newComm, REDUCE_MIN, iOwnAllGids, outArg (allProcsOwnAllGids));
2087 map->distributed_ = (allProcsOwnAllGids == 1) ?
false :
true;
2090 map->lgMap_ = lgMap_;
2091 map->lgMapHost_ = lgMapHost_;
2092 map->glMap_ = glMap_;
2093 map->glMapHost_ = glMapHost_;
2110 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2114 TEUCHOS_TEST_FOR_EXCEPTION(
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;
2139 const size_t maxNumToPrint = verbose ?
2141 std::unique_ptr<std::string> prefix;
2144 "Map",
"getRemoteIndexList(GIDs,PIDs,LIDs)");
2145 std::ostringstream os;
2146 os << *prefix <<
"Start: ";
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) {
2175 PIDs[k] = OrdinalTraits<int>::invalid ();
2177 for (size_type k = 0; k < LIDs.size (); ++k) {
2178 LIDs[k] = OrdinalTraits<LocalOrdinal>::invalid ();
2189 std::ostringstream os;
2190 os << *prefix <<
"Call setupDirectory" << endl;
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 "
2204 << (retVal ==
IDNotPresent ?
"IDNotPresent" :
"AllIDsPresent")
2210 std::cerr << os.str();
2215 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2219 const Teuchos::ArrayView<int> & PIDs)
const
2225 const size_t maxNumToPrint = verbose ?
2227 std::unique_ptr<std::string> prefix;
2230 "Map",
"getRemoteIndexList(GIDs,PIDs)");
2231 std::ostringstream os;
2232 os << *prefix <<
"Start: ";
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;
2267 os << *prefix <<
"Call setupDirectory" << endl;
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 "
2281 << (retVal ==
IDNotPresent ?
"IDNotPresent" :
"AllIDsPresent")
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;
2313 os << *prefix <<
"Start" << endl;
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();
2356 template <
class LocalOrdinal,
class GlobalOrdinal>
2357 Teuchos::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);
2367 template <
class LocalOrdinal,
class GlobalOrdinal>
2368 Teuchos::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);
2378 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2379 Teuchos::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));
2391 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2392 Teuchos::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));
2406 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2407 Teuchos::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));
2420 template <
class LocalOrdinal,
class GlobalOrdinal>
2421 Teuchos::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;
2430 return Tpetra::createContigMapWithNode<LO, GO, NT> (numElements, localNumElements, comm);
2433 template <
class LocalOrdinal,
class GlobalOrdinal>
2434 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2436 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2438 typedef LocalOrdinal LO;
2439 typedef GlobalOrdinal GO;
2442 return Tpetra::createNonContigMapWithNode<LO, GO, NT> (elementList, comm);
2445 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2446 Teuchos::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));
2463 template<
class LO,
class GO,
class NT>
2464 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >
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: ";
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;
2610 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2611 Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2615 using Details::Behavior;
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;
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: ";
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 > > &); \
2763 #endif // TPETRA_MAP_DEF_HPP
Interface for breaking ties in ownership.
bool congruent(const Teuchos::Comm< int > &comm1, const Teuchos::Comm< int > &comm2)
Whether the two communicators are congruent.
global_ordinal_type getMaxGlobalIndex() const
The maximum global index owned by the calling process.
LocalOrdinal local_ordinal_type
The type of local indices.
virtual ~Map()
Destructor (virtual for memory safety of derived classes).
GlobalOrdinal global_ordinal_type
The type of global indices.
bool isSameAs(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is identical to this Map.
Declaration of Tpetra::Details::printOnce.
global_indices_array_type getMyGlobalIndices() const
Return a view of the global indices owned by this process.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
Declaration of a function that prints strings from each process.
size_t getLocalNumElements() const
The number of elements belonging to the calling process.
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.
bool isUniform() const
Whether the range of global indices is uniform.
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...
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
Teuchos::RCP< const Map< local_ordinal_type, global_ordinal_type, Node > > removeEmptyProcesses() const
Advanced methods.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
static bool debug()
Whether Tpetra is in debug mode.
void verbosePrintArray(std::ostream &out, const ArrayType &x, const char name[], const size_t maxNumToPrint)
Print min(x.size(), maxNumToPrint) entries of x.
int local_ordinal_type
Default value of Scalar template parameter.
"Local" part of Map suitable for Kokkos kernels.
Declaration of Tpetra::Details::initializeKokkos.
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, in rank order.
Teuchos::ArrayView< const global_ordinal_type > getLocalElementList() const
Return a NONOWNING view of the global indices owned by this process.
void initializeKokkos()
Initialize Kokkos, using command-line arguments (if any) given to Teuchos::GlobalMPISession.
size_t global_size_t
Global size_t object.
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
Copy the contents of the MultiVector src into dst.
bool isCompatible(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is compatible with this Map.
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, possibly nondefault Kokkos Node type.
global_ordinal_type getIndexBase() const
The index base for this Map.
global_ordinal_type getGlobalElement(local_ordinal_type localIndex) const
The global index corresponding to the given local index.
bool isNodeLocalElement(local_ordinal_type localIndex) const
Whether the given local index is valid for this Map on the calling process.
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.
Functions for initializing and finalizing Tpetra.
bool isNodeGlobalElement(global_ordinal_type globalIndex) const
Whether the given global index is owned by this Map on the calling process.
static bool verbose()
Whether Tpetra is in verbose mode.
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...
LookupStatus getDirectoryEntries(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs) const
Given a global ID list, return the list of their owning process IDs.
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...
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.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
global_ordinal_type getMinGlobalIndex() const
The minimum global index owned by the calling process.
typename device_type::execution_space execution_space
The Kokkos execution space.
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...
A parallel distribution of indices over processes.
global_ordinal_type getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
local_ordinal_type getLocalElement(global_ordinal_type globalIndex) const
The local index corresponding to the given global index.
Implement mapping from global ID to process ID and local ID.
Stand-alone utility functions and macros.
bool isOneToOne() const
Whether the Map is one to one.
void initialize(const map_type &map)
Initialize the Directory with its 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?
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.
static size_t verbosePrintCountThreshold()
Number of entries below which arrays, lists, etc. will be printed in debug mode.
typename Node::device_type device_type
This class' Kokkos::Device specialization.
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.
LocalGlobal
Enum for local versus global allocation of Map entries.
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.
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.
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 ...
Node node_type
Legacy typedef that will go away at some point.
global_ordinal_type getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
std::unique_ptr< std::string > createPrefix(const int myRank, const char prefix[])
Create string prefix for each line of verbose output.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
Description of Tpetra's behavior.
std::string description() const
Implementation of Teuchos::Describable.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Map()
Default constructor (that does nothing).