45 #ifndef TPETRA_MAP_DEF_HPP
46 #define TPETRA_MAP_DEF_HPP
48 #include "Tpetra_Directory.hpp"
50 #include "Tpetra_Details_FixedHashTable.hpp"
55 #include "Teuchos_as.hpp"
56 #include "Teuchos_TypeNameTraits.hpp"
57 #include "Teuchos_CommHelpers.hpp"
58 #include "Tpetra_Details_mpiIsInitialized.hpp"
68 template<
class ExecutionSpace>
70 checkMapInputArray (
const char ctorName[],
71 const void* indexList,
72 const size_t indexListSize,
73 const ExecutionSpace& execSpace,
74 const Teuchos::Comm<int>*
const comm)
78 const bool debug = Behavior::debug(
"Map");
80 using Teuchos::outArg;
81 using Teuchos::REDUCE_MIN;
82 using Teuchos::reduceAll;
85 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
86 const bool verbose = Behavior::verbose(
"Map");
87 std::ostringstream lclErrStrm;
90 if (indexListSize != 0 && indexList ==
nullptr) {
93 lclErrStrm <<
"Proc " << myRank <<
": indexList is null, "
94 "but indexListSize=" << indexListSize <<
" != 0." << endl;
98 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
99 if (gblSuccess != 1) {
100 std::ostringstream gblErrStrm;
101 gblErrStrm <<
"Tpetra::Map constructor " << ctorName <<
102 " detected a problem with the input array "
103 "(raw array, Teuchos::ArrayView, or Kokkos::View) "
104 "of global indices." << endl;
106 using ::Tpetra::Details::gathervPrint;
109 TEUCHOS_TEST_FOR_EXCEPTION
110 (
true, std::invalid_argument, gblErrStrm.str ());
118 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121 comm_ (new Teuchos::SerialComm<int> ()),
123 numGlobalElements_ (0),
124 numLocalElements_ (0),
125 minMyGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
126 maxMyGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
127 minAllGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
128 maxAllGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
129 firstContiguousGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
130 lastContiguousGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
133 distributed_ (false),
134 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
140 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
148 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
151 using Teuchos::broadcast;
152 using Teuchos::outArg;
153 using Teuchos::reduceAll;
154 using Teuchos::REDUCE_MIN;
155 using Teuchos::REDUCE_MAX;
156 using Teuchos::typeName;
160 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
161 const char funcName[] =
"Map(gblNumInds,indexBase,comm,LG)";
163 "Tpetra::Map::Map(gblNumInds,indexBase,comm,LG): ";
167 std::unique_ptr<std::string> prefix;
170 comm_.getRawPtr(),
"Map", funcName);
171 std::ostringstream os;
172 os << *prefix <<
"Start" << endl;
173 std::cerr << os.str();
180 GST proc0NumGlobalElements = numGlobalElements;
181 broadcast(*comm_, 0, outArg(proc0NumGlobalElements));
182 GST minNumGlobalElements = numGlobalElements;
183 GST maxNumGlobalElements = numGlobalElements;
184 reduceAll(*comm, REDUCE_MIN, numGlobalElements,
185 outArg(minNumGlobalElements));
186 reduceAll(*comm, REDUCE_MAX, numGlobalElements,
187 outArg(maxNumGlobalElements));
188 TEUCHOS_TEST_FOR_EXCEPTION
189 (minNumGlobalElements != maxNumGlobalElements ||
190 numGlobalElements != minNumGlobalElements,
191 std::invalid_argument, exPfx <<
"All processes must "
192 "provide the same number of global elements. Process 0 set "
193 "numGlobalElements="<< proc0NumGlobalElements <<
". The "
194 "calling process " << comm->getRank() <<
" set "
195 "numGlobalElements=" << numGlobalElements <<
". The min "
196 "and max values over all processes are "
197 << minNumGlobalElements <<
" resp. " << maxNumGlobalElements
200 GO proc0IndexBase = indexBase;
201 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
202 GO minIndexBase = indexBase;
203 GO maxIndexBase = indexBase;
204 reduceAll(*comm, REDUCE_MIN, indexBase, outArg(minIndexBase));
205 reduceAll(*comm, REDUCE_MAX, indexBase, outArg(maxIndexBase));
206 TEUCHOS_TEST_FOR_EXCEPTION
207 (minIndexBase != maxIndexBase || indexBase != minIndexBase,
208 std::invalid_argument, exPfx <<
"All processes must "
209 "provide the same indexBase argument. Process 0 set "
210 "indexBase=" << proc0IndexBase <<
". The calling process "
211 << comm->getRank() <<
" set indexBase=" << indexBase
212 <<
". The min and max values over all processes are "
213 << minIndexBase <<
" resp. " << maxIndexBase <<
".");
233 TEUCHOS_TEST_FOR_EXCEPTION(
234 (numGlobalElements < 1 && numGlobalElements != 0),
235 std::invalid_argument, exPfx <<
"numGlobalElements (= "
236 << numGlobalElements <<
") must be nonnegative.");
238 TEUCHOS_TEST_FOR_EXCEPTION
239 (numGlobalElements == GSTI, std::invalid_argument, exPfx <<
240 "You provided numGlobalElements = Teuchos::OrdinalTraits<"
241 "Tpetra::global_size_t>::invalid(). This version of the "
242 "constructor requires a valid value of numGlobalElements. "
243 "You probably mistook this constructor for the \"contiguous "
244 "nonuniform\" constructor, which can compute the global "
245 "number of elements for you if you set numGlobalElements to "
246 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid().");
248 size_t numLocalElements = 0;
249 if (lOrG == GloballyDistributed) {
264 const GST numProcs =
static_cast<GST
> (comm_->getSize ());
265 const GST myRank =
static_cast<GST
> (comm_->getRank ());
266 const GST quotient = numGlobalElements / numProcs;
267 const GST remainder = numGlobalElements - quotient * numProcs;
270 if (myRank < remainder) {
271 numLocalElements =
static_cast<size_t> (1) + static_cast<size_t> (quotient);
274 startIndex = as<GO> (myRank) * as<GO> (numLocalElements);
276 numLocalElements = as<size_t> (quotient);
277 startIndex = as<GO> (myRank) * as<GO> (numLocalElements) +
281 minMyGID_ = indexBase + startIndex;
282 maxMyGID_ = indexBase + startIndex + numLocalElements - 1;
283 minAllGID_ = indexBase;
284 maxAllGID_ = indexBase + numGlobalElements - 1;
285 distributed_ = (numProcs > 1);
288 numLocalElements = as<size_t> (numGlobalElements);
289 minMyGID_ = indexBase;
290 maxMyGID_ = indexBase + numGlobalElements - 1;
291 distributed_ =
false;
294 minAllGID_ = indexBase;
295 maxAllGID_ = indexBase + numGlobalElements - 1;
296 indexBase_ = indexBase;
297 numGlobalElements_ = numGlobalElements;
298 numLocalElements_ = numLocalElements;
299 firstContiguousGID_ = minMyGID_;
300 lastContiguousGID_ = maxMyGID_;
307 std::ostringstream os;
308 os << *prefix <<
"Done" << endl;
309 std::cerr << os.str();
314 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
317 const size_t numLocalElements,
319 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) :
322 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
325 using Teuchos::broadcast;
326 using Teuchos::outArg;
327 using Teuchos::reduceAll;
328 using Teuchos::REDUCE_MIN;
329 using Teuchos::REDUCE_MAX;
330 using Teuchos::REDUCE_SUM;
335 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
336 const char funcName[] =
337 "Map(gblNumInds,lclNumInds,indexBase,comm)";
339 "Tpetra::Map::Map(gblNumInds,lclNumInds,indexBase,comm): ";
340 const char suffix[] =
341 ". Please report this bug to the Tpetra developers.";
345 std::unique_ptr<std::string> prefix;
348 comm_.getRawPtr(),
"Map", funcName);
349 std::ostringstream os;
350 os << *prefix <<
"Start" << endl;
351 std::cerr << os.str();
357 GST debugGlobalSum {};
359 debugGlobalSum = initialNonuniformDebugCheck(exPfx,
360 numGlobalElements, numLocalElements, indexBase, comm);
375 scan<int, GO> (*comm, REDUCE_SUM, numLocalElements, outArg (scanResult));
376 const GO myOffset = scanResult - numLocalElements;
378 if (numGlobalElements != GSTI) {
379 numGlobalElements_ = numGlobalElements;
386 const int numProcs = comm->getSize ();
387 GST globalSum = scanResult;
389 broadcast (*comm, numProcs - 1, outArg (globalSum));
391 numGlobalElements_ = globalSum;
395 TEUCHOS_TEST_FOR_EXCEPTION
396 (globalSum != debugGlobalSum, std::logic_error, exPfx <<
397 "globalSum = " << globalSum <<
" != debugGlobalSum = " <<
398 debugGlobalSum << suffix);
401 numLocalElements_ = numLocalElements;
402 indexBase_ = indexBase;
403 minAllGID_ = (numGlobalElements_ == 0) ?
404 std::numeric_limits<GO>::max () :
406 maxAllGID_ = (numGlobalElements_ == 0) ?
407 std::numeric_limits<GO>::lowest () :
408 indexBase + GO(numGlobalElements_) - GO(1);
409 minMyGID_ = (numLocalElements_ == 0) ?
410 std::numeric_limits<GO>::max () :
411 indexBase + GO(myOffset);
412 maxMyGID_ = (numLocalElements_ == 0) ?
413 std::numeric_limits<GO>::lowest () :
414 indexBase + myOffset + GO(numLocalElements) - GO(1);
415 firstContiguousGID_ = minMyGID_;
416 lastContiguousGID_ = maxMyGID_;
418 distributed_ = checkIsDist ();
424 std::ostringstream os;
425 os << *prefix <<
"Done" << endl;
426 std::cerr << os.str();
430 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
434 const char errorMessagePrefix[],
436 const size_t numLocalElements,
437 const global_ordinal_type indexBase,
438 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
const
445 using Teuchos::broadcast;
446 using Teuchos::outArg;
448 using Teuchos::REDUCE_MAX;
449 using Teuchos::REDUCE_MIN;
450 using Teuchos::REDUCE_SUM;
451 using Teuchos::reduceAll;
452 using GO = global_ordinal_type;
454 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
464 GST debugGlobalSum = 0;
465 reduceAll<int, GST> (*comm, REDUCE_SUM,
static_cast<GST
> (numLocalElements),
466 outArg (debugGlobalSum));
470 GST proc0NumGlobalElements = numGlobalElements;
471 broadcast<int, GST> (*comm_, 0, outArg (proc0NumGlobalElements));
472 GST minNumGlobalElements = numGlobalElements;
473 GST maxNumGlobalElements = numGlobalElements;
474 reduceAll<int, GST> (*comm, REDUCE_MIN, numGlobalElements,
475 outArg (minNumGlobalElements));
476 reduceAll<int, GST> (*comm, REDUCE_MAX, numGlobalElements,
477 outArg (maxNumGlobalElements));
478 TEUCHOS_TEST_FOR_EXCEPTION
479 (minNumGlobalElements != maxNumGlobalElements ||
480 numGlobalElements != minNumGlobalElements,
481 std::invalid_argument, errorMessagePrefix <<
"All processes "
482 "must provide the same number of global elements, even if "
484 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() "
485 "(which signals that the Map should compute the global "
486 "number of elements). Process 0 set numGlobalElements"
487 "=" << proc0NumGlobalElements <<
". The calling process "
488 << comm->getRank() <<
" set numGlobalElements=" <<
489 numGlobalElements <<
". The min and max values over all "
490 "processes are " << minNumGlobalElements <<
" resp. " <<
491 maxNumGlobalElements <<
".");
493 GO proc0IndexBase = indexBase;
494 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
495 GO minIndexBase = indexBase;
496 GO maxIndexBase = indexBase;
497 reduceAll<int, GO> (*comm, REDUCE_MIN, indexBase, outArg (minIndexBase));
498 reduceAll<int, GO> (*comm, REDUCE_MAX, indexBase, outArg (maxIndexBase));
499 TEUCHOS_TEST_FOR_EXCEPTION
500 (minIndexBase != maxIndexBase || indexBase != minIndexBase,
501 std::invalid_argument, errorMessagePrefix <<
502 "All processes must provide the same indexBase argument. "
503 "Process 0 set indexBase = " << proc0IndexBase <<
". The "
504 "calling process " << comm->getRank() <<
" set indexBase="
505 << indexBase <<
". The min and max values over all "
506 "processes are " << minIndexBase <<
" resp. " << maxIndexBase
511 TEUCHOS_TEST_FOR_EXCEPTION
512 (numGlobalElements != GSTI &&
513 debugGlobalSum != numGlobalElements, std::invalid_argument,
514 errorMessagePrefix <<
"The sum of each process' number of "
515 "indices over all processes, " << debugGlobalSum <<
", != "
516 <<
"numGlobalElements=" << numGlobalElements <<
". If you "
517 "would like this constructor to compute numGlobalElements "
518 "for you, you may set numGlobalElements="
519 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() "
520 "on input. Please note that this is NOT necessarily -1.");
522 return debugGlobalSum;
525 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
527 Map<LocalOrdinal,GlobalOrdinal,Node>::
528 initWithNonownedHostIndexList(
529 const char errorMessagePrefix[],
531 const Kokkos::View<
const global_ordinal_type*,
534 Kokkos::MemoryUnmanaged>& entryList_host,
535 const global_ordinal_type indexBase,
536 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
538 using Kokkos::LayoutLeft;
539 using Kokkos::subview;
541 using Kokkos::view_alloc;
542 using Kokkos::WithoutInitializing;
544 using Teuchos::broadcast;
545 using Teuchos::outArg;
547 using Teuchos::REDUCE_MAX;
548 using Teuchos::REDUCE_MIN;
549 using Teuchos::REDUCE_SUM;
550 using Teuchos::reduceAll;
552 using GO = global_ordinal_type;
554 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
557 TEUCHOS_TEST_FOR_EXCEPTION
558 (! Kokkos::is_initialized (), std::runtime_error,
559 errorMessagePrefix <<
"The Kokkos execution space "
560 << Teuchos::TypeNameTraits<execution_space>::name()
561 <<
" has not been initialized. "
562 "Please initialize it before creating a Map.")
575 const
size_t numLocalElements(entryList_host.size());
577 initialNonuniformDebugCheck(errorMessagePrefix, numGlobalElements,
578 numLocalElements, indexBase, comm);
588 if (numGlobalElements != GSTI) {
589 numGlobalElements_ = numGlobalElements;
592 reduceAll(*comm, REDUCE_SUM,
593 static_cast<GST>(numLocalElements),
594 outArg(numGlobalElements_));
620 numLocalElements_ = numLocalElements;
621 indexBase_ = indexBase;
623 minMyGID_ = indexBase_;
624 maxMyGID_ = indexBase_;
634 if (numLocalElements_ > 0) {
638 typename decltype (lgMap_)::non_const_type lgMap
639 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
641 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
649 firstContiguousGID_ = entryList_host[0];
650 lastContiguousGID_ = firstContiguousGID_+1;
658 lgMap_host[0] = firstContiguousGID_;
660 for ( ; i < numLocalElements_; ++i) {
661 const GO curGid = entryList_host[i];
662 const LO curLid = as<LO> (i);
664 if (lastContiguousGID_ != curGid)
break;
670 lgMap_host[curLid] = curGid;
671 ++lastContiguousGID_;
673 --lastContiguousGID_;
678 minMyGID_ = firstContiguousGID_;
679 maxMyGID_ = lastContiguousGID_;
684 const std::pair<size_t, size_t> ncRange (i, entryList_host.extent (0));
685 auto nonContigGids_host = subview (entryList_host, ncRange);
686 TEUCHOS_TEST_FOR_EXCEPTION
687 (static_cast<size_t> (nonContigGids_host.extent (0)) !=
688 static_cast<size_t> (entryList_host.extent (0) - i),
689 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
690 "nonContigGids_host.extent(0) = "
691 << nonContigGids_host.extent (0)
692 <<
" != entryList_host.extent(0) - i = "
693 << (entryList_host.extent (0) - i) <<
" = "
694 << entryList_host.extent (0) <<
" - " << i
695 <<
". Please report this bug to the Tpetra developers.");
699 View<GO*, LayoutLeft, device_type>
700 nonContigGids (view_alloc (
"nonContigGids", WithoutInitializing),
701 nonContigGids_host.size ());
706 glMap_ = global_to_local_table_type(nonContigGids,
709 static_cast<LO> (i));
711 glMapHost_ = global_to_local_table_host_type(glMap_);
719 for ( ; i < numLocalElements_; ++i) {
720 const GO curGid = entryList_host[i];
721 const LO curLid =
static_cast<LO
> (i);
722 lgMap_host[curLid] = curGid;
726 if (curGid < minMyGID_) {
729 if (curGid > maxMyGID_) {
741 lgMapHost_ = lgMap_host;
744 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
745 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
749 firstContiguousGID_ = indexBase_+1;
750 lastContiguousGID_ = indexBase_;
775 if (std::numeric_limits<GO>::is_signed) {
778 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
781 minMaxInput[0] = -minMyGID_;
782 minMaxInput[1] = maxMyGID_;
783 minMaxInput[2] = localDist;
789 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
790 minAllGID_ = -minMaxOutput[0];
791 maxAllGID_ = minMaxOutput[1];
792 const GO globalDist = minMaxOutput[2];
793 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
797 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
798 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
799 distributed_ = checkIsDist ();
804 TEUCHOS_TEST_FOR_EXCEPTION(
805 minAllGID_ < indexBase_,
806 std::invalid_argument,
807 "Tpetra::Map constructor (noncontiguous): "
808 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
809 "less than the given indexBase = " << indexBase_ <<
".");
815 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
818 const GlobalOrdinal indexList[],
819 const LocalOrdinal indexListSize,
820 const GlobalOrdinal indexBase,
821 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
824 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
827 const char funcName[] =
828 "Map(gblNumInds,indexList,indexListSize,indexBase,comm)";
831 std::unique_ptr<std::string> prefix;
834 comm_.getRawPtr(),
"Map", funcName);
835 std::ostringstream os;
836 os << *prefix <<
"Start" << endl;
837 std::cerr << os.str();
840 checkMapInputArray (
"(GST, const GO[], LO, GO, comm)",
841 indexList, static_cast<size_t> (indexListSize),
842 Kokkos::DefaultHostExecutionSpace (),
847 const GlobalOrdinal*
const indsRaw = indexListSize == 0 ? NULL : indexList;
848 Kokkos::View<
const GlobalOrdinal*,
851 Kokkos::MemoryUnmanaged> inds (indsRaw, indexListSize);
852 initWithNonownedHostIndexList(funcName, numGlobalElements, inds,
855 std::ostringstream os;
856 os << *prefix <<
"Done" << endl;
857 std::cerr << os.str();
861 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
864 const Teuchos::ArrayView<const GlobalOrdinal>& entryList,
865 const GlobalOrdinal indexBase,
866 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
869 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
872 const char funcName[] =
873 "Map(gblNumInds,entryList(Teuchos::ArrayView),indexBase,comm)";
876 std::unique_ptr<std::string> prefix;
879 comm_.getRawPtr(),
"Map", funcName);
880 std::ostringstream os;
881 os << *prefix <<
"Start" << endl;
882 std::cerr << os.str();
885 const size_t numLclInds =
static_cast<size_t> (entryList.size ());
886 checkMapInputArray (
"(GST, ArrayView, GO, comm)",
887 entryList.getRawPtr (), numLclInds,
888 Kokkos::DefaultHostExecutionSpace (),
893 const GlobalOrdinal*
const indsRaw =
894 numLclInds == 0 ? NULL : entryList.getRawPtr ();
895 Kokkos::View<
const GlobalOrdinal*,
898 Kokkos::MemoryUnmanaged> inds (indsRaw, numLclInds);
899 initWithNonownedHostIndexList(funcName, numGlobalElements, inds,
902 std::ostringstream os;
903 os << *prefix <<
"Done" << endl;
904 std::cerr << os.str();
908 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
911 const Kokkos::View<const GlobalOrdinal*, device_type>& entryList,
912 const GlobalOrdinal indexBase,
913 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
916 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
918 using Kokkos::LayoutLeft;
919 using Kokkos::subview;
921 using Kokkos::view_alloc;
922 using Kokkos::WithoutInitializing;
924 using Teuchos::ArrayView;
926 using Teuchos::broadcast;
927 using Teuchos::outArg;
929 using Teuchos::REDUCE_MAX;
930 using Teuchos::REDUCE_MIN;
931 using Teuchos::REDUCE_SUM;
932 using Teuchos::reduceAll;
933 using Teuchos::typeName;
938 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
939 const char funcName[] =
940 "Map(gblNumInds,entryList(Kokkos::View),indexBase,comm)";
943 std::unique_ptr<std::string> prefix;
946 comm_.getRawPtr(),
"Map", funcName);
947 std::ostringstream os;
948 os << *prefix <<
"Start" << endl;
949 std::cerr << os.str();
952 checkMapInputArray (
"(GST, Kokkos::View, GO, comm)",
954 static_cast<size_t> (entryList.extent (0)),
968 const size_t numLocalElements(entryList.size());
970 initialNonuniformDebugCheck(funcName, numGlobalElements,
971 numLocalElements, indexBase, comm);
981 if (numGlobalElements != GSTI) {
982 numGlobalElements_ = numGlobalElements;
985 reduceAll(*comm, REDUCE_SUM,
986 static_cast<GST>(numLocalElements),
987 outArg(numGlobalElements_));
1013 numLocalElements_ = numLocalElements;
1014 indexBase_ = indexBase;
1016 minMyGID_ = indexBase_;
1017 maxMyGID_ = indexBase_;
1027 if (numLocalElements_ > 0) {
1031 typename decltype (lgMap_)::non_const_type lgMap
1032 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
1034 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
1036 using array_layout =
1037 typename View<const GO*, device_type>::array_layout;
1038 View<GO*, array_layout, Kokkos::HostSpace> entryList_host
1039 (view_alloc (
"entryList_host", WithoutInitializing),
1040 entryList.extent(0));
1044 firstContiguousGID_ = entryList_host[0];
1045 lastContiguousGID_ = firstContiguousGID_+1;
1053 lgMap_host[0] = firstContiguousGID_;
1055 for ( ; i < numLocalElements_; ++i) {
1056 const GO curGid = entryList_host[i];
1057 const LO curLid = as<LO> (i);
1059 if (lastContiguousGID_ != curGid)
break;
1065 lgMap_host[curLid] = curGid;
1066 ++lastContiguousGID_;
1068 --lastContiguousGID_;
1073 minMyGID_ = firstContiguousGID_;
1074 maxMyGID_ = lastContiguousGID_;
1079 const std::pair<size_t, size_t> ncRange (i, entryList.extent (0));
1080 auto nonContigGids = subview (entryList, ncRange);
1081 TEUCHOS_TEST_FOR_EXCEPTION
1082 (static_cast<size_t> (nonContigGids.extent (0)) !=
1083 static_cast<size_t> (entryList.extent (0) - i),
1084 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
1085 "nonContigGids.extent(0) = "
1086 << nonContigGids.extent (0)
1087 <<
" != entryList.extent(0) - i = "
1088 << (entryList.extent (0) - i) <<
" = "
1089 << entryList.extent (0) <<
" - " << i
1090 <<
". Please report this bug to the Tpetra developers.");
1093 firstContiguousGID_,
1095 static_cast<LO> (i));
1105 for ( ; i < numLocalElements_; ++i) {
1106 const GO curGid = entryList_host[i];
1107 const LO curLid =
static_cast<LO
> (i);
1108 lgMap_host[curLid] = curGid;
1112 if (curGid < minMyGID_) {
1115 if (curGid > maxMyGID_) {
1127 lgMapHost_ = lgMap_host;
1130 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
1131 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
1135 firstContiguousGID_ = indexBase_+1;
1136 lastContiguousGID_ = indexBase_;
1161 if (std::numeric_limits<GO>::is_signed) {
1163 const GO localDist =
1164 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
1167 minMaxInput[0] = -minMyGID_;
1168 minMaxInput[1] = maxMyGID_;
1169 minMaxInput[2] = localDist;
1172 minMaxOutput[0] = 0;
1173 minMaxOutput[1] = 0;
1174 minMaxOutput[2] = 0;
1175 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
1176 minAllGID_ = -minMaxOutput[0];
1177 maxAllGID_ = minMaxOutput[1];
1178 const GO globalDist = minMaxOutput[2];
1179 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
1183 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
1184 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
1185 distributed_ = checkIsDist ();
1188 contiguous_ =
false;
1190 TEUCHOS_TEST_FOR_EXCEPTION(
1191 minAllGID_ < indexBase_,
1192 std::invalid_argument,
1193 "Tpetra::Map constructor (noncontiguous): "
1194 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
1195 "less than the given indexBase = " << indexBase_ <<
".");
1201 std::ostringstream os;
1202 os << *prefix <<
"Done" << endl;
1203 std::cerr << os.str();
1208 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1211 if (! Kokkos::is_initialized ()) {
1212 std::ostringstream os;
1213 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1214 "Kokkos::finalize() has been called. This is user error! There are "
1215 "two likely causes: " << std::endl <<
1216 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1218 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1219 "of a Tpetra::Map) at the same scope in main() as Kokkos::finalize() "
1220 "or Tpetra::finalize()." << std::endl << std::endl <<
1221 "Don't do either of these! Please refer to GitHib Issue #2372."
1223 ::Tpetra::Details::printOnce (std::cerr, os.str (),
1224 this->getComm ().getRawPtr ());
1227 using ::Tpetra::Details::mpiIsInitialized;
1228 using ::Tpetra::Details::mpiIsFinalized;
1229 using ::Tpetra::Details::teuchosCommIsAnMpiComm;
1231 Teuchos::RCP<const Teuchos::Comm<int> > comm = this->getComm ();
1232 if (! comm.is_null () && teuchosCommIsAnMpiComm (*comm) &&
1233 mpiIsInitialized () && mpiIsFinalized ()) {
1239 std::ostringstream os;
1240 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1241 "MPI_Finalize() has been called. This is user error! There are "
1242 "two likely causes: " << std::endl <<
1243 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1245 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1246 "of a Tpetra::Map) at the same scope in main() as MPI_finalize() or "
1247 "Tpetra::finalize()." << std::endl << std::endl <<
1248 "Don't do either of these! Please refer to GitHib Issue #2372."
1250 ::Tpetra::Details::printOnce (std::cerr, os.str (), comm.getRawPtr ());
1258 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1262 TEUCHOS_TEST_FOR_EXCEPTION(
1263 getComm ().is_null (), std::logic_error,
"Tpetra::Map::isOneToOne: "
1264 "getComm() returns null. Please report this bug to the Tpetra "
1269 return directory_->isOneToOne (*
this);
1272 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1277 if (isContiguous ()) {
1278 if (globalIndex < getMinGlobalIndex () ||
1279 globalIndex > getMaxGlobalIndex ()) {
1280 return Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1282 return static_cast<LocalOrdinal
> (globalIndex - getMinGlobalIndex ());
1284 else if (globalIndex >= firstContiguousGID_ &&
1285 globalIndex <= lastContiguousGID_) {
1286 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGID_);
1292 return glMapHost_.get (globalIndex);
1296 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1301 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
1302 return Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
1304 if (isContiguous ()) {
1305 return getMinGlobalIndex () + localIndex;
1312 return lgMapHost_[localIndex];
1316 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1321 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
1328 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1332 return this->getLocalElement (globalIndex) !=
1333 Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1336 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1341 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1347 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1353 getMinGlobalIndex (), getMaxGlobalIndex (),
1354 firstContiguousGID_, lastContiguousGID_,
1355 getLocalNumElements (), isContiguous ());
1358 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1363 using Teuchos::outArg;
1364 using Teuchos::REDUCE_MIN;
1365 using Teuchos::reduceAll;
1375 else if (getComm ()->getSize () != map.
getComm ()->getSize ()) {
1386 else if (isContiguous () && isUniform () &&
1394 lgMap_.extent (0) != 0 && map.lgMap_.extent (0) != 0 &&
1395 lgMap_.data () == map.lgMap_.data ()) {
1409 TEUCHOS_TEST_FOR_EXCEPTION(
1411 "Tpetra::Map::isCompatible: There's a bug in this method. We've already "
1412 "checked that this condition is true above, but it's false here. "
1413 "Please report this bug to the Tpetra developers.");
1416 const int locallyCompat =
1419 int globallyCompat = 0;
1420 reduceAll<int, int> (*comm_, REDUCE_MIN, locallyCompat, outArg (globallyCompat));
1421 return (globallyCompat == 1);
1424 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1429 using Teuchos::ArrayView;
1431 using size_type =
typename ArrayView<const GO>::size_type;
1454 if (isContiguous ()) {
1459 TEUCHOS_TEST_FOR_EXCEPTION(
1460 ! this->isContiguous () || map.
isContiguous (), std::logic_error,
1461 "Tpetra::Map::locallySameAs: BUG");
1463 const GO minLhsGid = this->getMinGlobalIndex ();
1464 const size_type numRhsElts = rhsElts.size ();
1465 for (size_type k = 0; k < numRhsElts; ++k) {
1466 const GO curLhsGid = minLhsGid +
static_cast<GO
> (k);
1467 if (curLhsGid != rhsElts[k]) {
1475 TEUCHOS_TEST_FOR_EXCEPTION(
1476 this->isContiguous () || ! map.
isContiguous (), std::logic_error,
1477 "Tpetra::Map::locallySameAs: BUG");
1478 ArrayView<const GO> lhsElts = this->getLocalElementList ();
1480 const size_type numLhsElts = lhsElts.size ();
1481 for (size_type k = 0; k < numLhsElts; ++k) {
1482 const GO curRhsGid = minRhsGid +
static_cast<GO
> (k);
1483 if (curRhsGid != lhsElts[k]) {
1489 else if (this->lgMap_.data () == map.lgMap_.data ()) {
1499 ArrayView<const GO> lhsElts = getLocalElementList ();
1505 return std::equal (lhsElts.begin (), lhsElts.end (), rhsElts.begin ());
1511 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1524 auto lmap2 = this->getLocalMap();
1526 auto numLocalElements1 = lmap1.getLocalNumElements();
1527 auto numLocalElements2 = lmap2.getLocalNumElements();
1529 if (numLocalElements1 > numLocalElements2) {
1534 if (lmap1.isContiguous () && lmap2.isContiguous ()) {
1536 return ((lmap1.getMinGlobalIndex () == lmap2.getMinGlobalIndex ()) &&
1537 (lmap1.getMaxGlobalIndex () <= lmap2.getMaxGlobalIndex ()));
1540 if (lmap1.getMinGlobalIndex () < lmap2.getMinGlobalIndex () ||
1541 lmap1.getMaxGlobalIndex () > lmap2.getMaxGlobalIndex ()) {
1549 Kokkos::RangePolicy<LO, typename node_type::execution_space>;
1553 Kokkos::parallel_reduce(
1555 range_type(0, numLocalElements1),
1556 KOKKOS_LAMBDA (
const LO i, LO& diff) {
1557 diff += (lmap1.getGlobalElement(i) != lmap2.getGlobalElement(i));
1560 return (numDiff == 0);
1563 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1568 using Teuchos::outArg;
1569 using Teuchos::REDUCE_MIN;
1570 using Teuchos::reduceAll;
1580 else if (getComm ()->getSize () != map.
getComm ()->getSize ()) {
1603 else if (isContiguous () && isUniform () &&
1624 const int isSame_lcl = locallySameAs (map) ? 1 : 0;
1628 reduceAll<int, int> (*comm_, REDUCE_MIN, isSame_lcl, outArg (isSame_gbl));
1629 return isSame_gbl == 1;
1633 template <
class LO,
class GO,
class DT>
1636 FillLgMap (
const Kokkos::View<GO*, DT>& lgMap,
1637 const GO startGid) :
1638 lgMap_ (lgMap), startGid_ (startGid)
1640 Kokkos::RangePolicy<LO, typename DT::execution_space>
1641 range (static_cast<LO> (0), static_cast<LO> (lgMap.size ()));
1642 Kokkos::parallel_for (range, *
this);
1645 KOKKOS_INLINE_FUNCTION
void operator () (
const LO& lid)
const {
1646 lgMap_(lid) = startGid_ +
static_cast<GO
> (lid);
1650 const Kokkos::View<GO*, DT> lgMap_;
1657 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1658 typename Map<LocalOrdinal,GlobalOrdinal,Node>::global_indices_array_type
1664 using const_lg_view_type = decltype(lgMap_);
1665 using lg_view_type =
typename const_lg_view_type::non_const_type;
1669 std::unique_ptr<std::string> prefix;
1672 comm_.getRawPtr(),
"Map",
"getMyGlobalIndices");
1673 std::ostringstream os;
1674 os << *prefix <<
"Start" << endl;
1675 std::cerr << os.str();
1681 const bool needToCreateLocalToGlobalMapping =
1682 lgMap_.extent (0) == 0 && numLocalElements_ > 0;
1684 if (needToCreateLocalToGlobalMapping) {
1686 std::ostringstream os;
1687 os << *prefix <<
"Need to create lgMap" << endl;
1688 std::cerr << os.str();
1693 TEUCHOS_TEST_FOR_EXCEPTION
1694 (! isContiguous(), std::logic_error,
1695 "Tpetra::Map::getMyGlobalIndices: The local-to-global "
1696 "mapping (lgMap_) should have been set up already for a "
1697 "noncontiguous Map. Please report this bug to the Tpetra "
1700 const LO numElts =
static_cast<LO
> (getLocalNumElements ());
1702 using Kokkos::view_alloc;
1703 using Kokkos::WithoutInitializing;
1704 lg_view_type lgMap (
"lgMap", numElts);
1706 std::ostringstream os;
1707 os << *prefix <<
"Fill lgMap" << endl;
1708 std::cerr << os.str();
1710 FillLgMap<LO, GO, no_uvm_device_type> fillIt (lgMap, minMyGID_);
1713 std::ostringstream os;
1714 os << *prefix <<
"Copy lgMap to lgMapHost" << endl;
1715 std::cerr << os.str();
1719 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
1725 lgMapHost_ = lgMapHost;
1729 std::ostringstream os;
1730 os << *prefix <<
"Done" << endl;
1731 std::cerr << os.str();
1736 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1737 Teuchos::ArrayView<const GlobalOrdinal>
1745 (void) this->getMyGlobalIndices ();
1748 const GO* lgMapHostRawPtr = lgMapHost_.data ();
1752 return Teuchos::ArrayView<const GO>(
1754 lgMapHost_.extent (0),
1755 Teuchos::RCP_DISABLE_NODE_LOOKUP);
1758 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1760 return distributed_;
1763 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1765 using Teuchos::TypeNameTraits;
1766 std::ostringstream os;
1768 os <<
"Tpetra::Map: {"
1769 <<
"LocalOrdinalType: " << TypeNameTraits<LocalOrdinal>::name ()
1770 <<
", GlobalOrdinalType: " << TypeNameTraits<GlobalOrdinal>::name ()
1771 <<
", NodeType: " << TypeNameTraits<Node>::name ();
1772 if (this->getObjectLabel () !=
"") {
1773 os <<
", Label: \"" << this->getObjectLabel () <<
"\"";
1775 os <<
", Global number of entries: " << getGlobalNumElements ()
1776 <<
", Number of processes: " << getComm ()->getSize ()
1777 <<
", Uniform: " << (isUniform () ?
"true" :
"false")
1778 <<
", Contiguous: " << (isContiguous () ?
"true" :
"false")
1779 <<
", Distributed: " << (isDistributed () ?
"true" :
"false")
1788 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1793 using LO = local_ordinal_type;
1797 if (vl < Teuchos::VERB_HIGH) {
1798 return std::string ();
1800 auto outStringP = Teuchos::rcp (
new std::ostringstream ());
1801 Teuchos::RCP<Teuchos::FancyOStream> outp =
1802 Teuchos::getFancyOStream (outStringP);
1803 Teuchos::FancyOStream& out = *outp;
1805 auto comm = this->getComm ();
1806 const int myRank = comm->getRank ();
1807 const int numProcs = comm->getSize ();
1808 out <<
"Process " << myRank <<
" of " << numProcs <<
":" << endl;
1809 Teuchos::OSTab tab1 (out);
1811 const LO numEnt =
static_cast<LO
> (this->getLocalNumElements ());
1812 out <<
"My number of entries: " << numEnt << endl
1813 <<
"My minimum global index: " << this->getMinGlobalIndex () << endl
1814 <<
"My maximum global index: " << this->getMaxGlobalIndex () << endl;
1816 if (vl == Teuchos::VERB_EXTREME) {
1817 out <<
"My global indices: [";
1818 const LO minLclInd = this->getMinLocalIndex ();
1819 for (LO k = 0; k < numEnt; ++k) {
1820 out << minLclInd + this->getGlobalElement (k);
1821 if (k + 1 < numEnt) {
1829 return outStringP->str ();
1832 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1836 const Teuchos::EVerbosityLevel verbLevel)
const
1838 using Teuchos::TypeNameTraits;
1839 using Teuchos::VERB_DEFAULT;
1840 using Teuchos::VERB_NONE;
1841 using Teuchos::VERB_LOW;
1842 using Teuchos::VERB_HIGH;
1846 const Teuchos::EVerbosityLevel vl =
1847 (verbLevel == VERB_DEFAULT) ? VERB_LOW : verbLevel;
1849 if (vl == VERB_NONE) {
1856 auto comm = this->getComm ();
1857 if (comm.is_null ()) {
1860 const int myRank = comm->getRank ();
1861 const int numProcs = comm->getSize ();
1870 Teuchos::RCP<Teuchos::OSTab> tab0, tab1;
1876 tab0 = Teuchos::rcp (
new Teuchos::OSTab (out));
1877 out <<
"\"Tpetra::Map\":" << endl;
1878 tab1 = Teuchos::rcp (
new Teuchos::OSTab (out));
1880 out <<
"Template parameters:" << endl;
1881 Teuchos::OSTab tab2 (out);
1882 out <<
"LocalOrdinal: " << TypeNameTraits<LO>::name () << endl
1883 <<
"GlobalOrdinal: " << TypeNameTraits<GO>::name () << endl
1884 <<
"Node: " << TypeNameTraits<Node>::name () << endl;
1886 const std::string label = this->getObjectLabel ();
1888 out <<
"Label: \"" << label <<
"\"" << endl;
1890 out <<
"Global number of entries: " << getGlobalNumElements () << endl
1891 <<
"Minimum global index: " << getMinAllGlobalIndex () << endl
1892 <<
"Maximum global index: " << getMaxAllGlobalIndex () << endl
1893 <<
"Index base: " << getIndexBase () << endl
1894 <<
"Number of processes: " << numProcs << endl
1895 <<
"Uniform: " << (isUniform () ?
"true" :
"false") << endl
1896 <<
"Contiguous: " << (isContiguous () ?
"true" :
"false") << endl
1897 <<
"Distributed: " << (isDistributed () ?
"true" :
"false") << endl;
1901 if (vl >= VERB_HIGH) {
1902 const std::string lclStr = this->localDescribeToString (vl);
1907 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1908 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1926 if (newComm.is_null () || newComm->getSize () < 1) {
1927 return Teuchos::null;
1929 else if (newComm->getSize () == 1) {
1934 RCP<map_type> newMap (
new map_type ());
1936 newMap->comm_ = newComm;
1940 newMap->indexBase_ = this->indexBase_;
1941 newMap->numGlobalElements_ = this->numLocalElements_;
1942 newMap->numLocalElements_ = this->numLocalElements_;
1943 newMap->minMyGID_ = this->minMyGID_;
1944 newMap->maxMyGID_ = this->maxMyGID_;
1945 newMap->minAllGID_ = this->minMyGID_;
1946 newMap->maxAllGID_ = this->maxMyGID_;
1947 newMap->firstContiguousGID_ = this->firstContiguousGID_;
1948 newMap->lastContiguousGID_ = this->lastContiguousGID_;
1951 newMap->uniform_ = this->uniform_;
1952 newMap->contiguous_ = this->contiguous_;
1955 newMap->distributed_ =
false;
1956 newMap->lgMap_ = this->lgMap_;
1957 newMap->lgMapHost_ = this->lgMapHost_;
1958 newMap->glMap_ = this->glMap_;
1959 newMap->glMapHost_ = this->glMapHost_;
1980 const GST RECOMPUTE = Tpetra::Details::OrdinalTraits<GST>::invalid ();
1996 auto lgMap = this->getMyGlobalIndices ();
1998 typename std::decay<decltype (lgMap.extent (0)) >::type;
1999 const size_type lclNumInds =
2000 static_cast<size_type
> (this->getLocalNumElements ());
2001 using Teuchos::TypeNameTraits;
2002 TEUCHOS_TEST_FOR_EXCEPTION
2003 (lgMap.extent (0) != lclNumInds, std::logic_error,
2004 "Tpetra::Map::replaceCommWithSubset: Result of getMyGlobalIndices() "
2005 "has length " << lgMap.extent (0) <<
" (of type " <<
2006 TypeNameTraits<size_type>::name () <<
") != this->getLocalNumElements()"
2007 " = " << this->getLocalNumElements () <<
". The latter, upon being "
2008 "cast to size_type = " << TypeNameTraits<size_type>::name () <<
", "
2009 "becomes " << lclNumInds <<
". Please report this bug to the Tpetra "
2012 Teuchos::ArrayView<const GO> lgMap = this->getLocalElementList ();
2015 const GO indexBase = this->getIndexBase ();
2017 auto lgMap_device = Kokkos::create_mirror_view_and_copy(
device_type(), lgMap);
2018 return rcp (
new map_type (RECOMPUTE, lgMap_device, indexBase, newComm));
2022 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2023 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
2027 using Teuchos::Comm;
2028 using Teuchos::null;
2029 using Teuchos::outArg;
2032 using Teuchos::REDUCE_MIN;
2033 using Teuchos::reduceAll;
2040 const int color = (numLocalElements_ == 0) ? 0 : 1;
2045 RCP<const Comm<int> > newComm = comm_->split (color, 0);
2051 if (newComm.is_null ()) {
2054 RCP<Map> map = rcp (
new Map ());
2056 map->comm_ = newComm;
2057 map->indexBase_ = indexBase_;
2058 map->numGlobalElements_ = numGlobalElements_;
2059 map->numLocalElements_ = numLocalElements_;
2060 map->minMyGID_ = minMyGID_;
2061 map->maxMyGID_ = maxMyGID_;
2062 map->minAllGID_ = minAllGID_;
2063 map->maxAllGID_ = maxAllGID_;
2064 map->firstContiguousGID_= firstContiguousGID_;
2065 map->lastContiguousGID_ = lastContiguousGID_;
2069 map->uniform_ = uniform_;
2070 map->contiguous_ = contiguous_;
2085 if (! distributed_ || newComm->getSize () == 1) {
2086 map->distributed_ =
false;
2088 const int iOwnAllGids = (numLocalElements_ == numGlobalElements_) ? 1 : 0;
2089 int allProcsOwnAllGids = 0;
2090 reduceAll<int, int> (*newComm, REDUCE_MIN, iOwnAllGids, outArg (allProcsOwnAllGids));
2091 map->distributed_ = (allProcsOwnAllGids == 1) ?
false :
true;
2094 map->lgMap_ = lgMap_;
2095 map->lgMapHost_ = lgMapHost_;
2096 map->glMap_ = glMap_;
2097 map->glMapHost_ = glMapHost_;
2114 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2118 TEUCHOS_TEST_FOR_EXCEPTION(
2119 directory_.is_null (), std::logic_error,
"Tpetra::Map::setupDirectory: "
2120 "The Directory is null. "
2121 "Please report this bug to the Tpetra developers.");
2125 if (! directory_->initialized ()) {
2126 directory_->initialize (*
this);
2130 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2134 const Teuchos::ArrayView<int>& PIDs,
2135 const Teuchos::ArrayView<LocalOrdinal>& LIDs)
const
2137 using Tpetra::Details::OrdinalTraits;
2140 using size_type = Teuchos::ArrayView<int>::size_type;
2143 const size_t maxNumToPrint = verbose ?
2145 std::unique_ptr<std::string> prefix;
2148 "Map",
"getRemoteIndexList(GIDs,PIDs,LIDs)");
2149 std::ostringstream os;
2150 os << *prefix <<
"Start: ";
2153 std::cerr << os.str();
2162 if (getGlobalNumElements () == 0) {
2163 if (GIDs.size () == 0) {
2165 std::ostringstream os;
2166 os << *prefix <<
"Done; both Map & input are empty" << endl;
2167 std::cerr << os.str();
2173 std::ostringstream os;
2174 os << *prefix <<
"Done: Map is empty on all processes, "
2175 "so all output PIDs & LIDs are invalid (-1)." << endl;
2176 std::cerr << os.str();
2178 for (size_type k = 0; k < PIDs.size (); ++k) {
2179 PIDs[k] = OrdinalTraits<int>::invalid ();
2181 for (size_type k = 0; k < LIDs.size (); ++k) {
2182 LIDs[k] = OrdinalTraits<LocalOrdinal>::invalid ();
2193 std::ostringstream os;
2194 os << *prefix <<
"Call setupDirectory" << endl;
2195 std::cerr << os.str();
2199 std::ostringstream os;
2200 os << *prefix <<
"Call directory_->getDirectoryEntries" << endl;
2201 std::cerr << os.str();
2204 directory_->getDirectoryEntries (*
this, GIDs, PIDs, LIDs);
2206 std::ostringstream os;
2207 os << *prefix <<
"Done; getDirectoryEntries returned "
2208 << (retVal ==
IDNotPresent ?
"IDNotPresent" :
"AllIDsPresent")
2214 std::cerr << os.str();
2219 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2223 const Teuchos::ArrayView<int> & PIDs)
const
2229 const size_t maxNumToPrint = verbose ?
2231 std::unique_ptr<std::string> prefix;
2234 "Map",
"getRemoteIndexList(GIDs,PIDs)");
2235 std::ostringstream os;
2236 os << *prefix <<
"Start: ";
2239 std::cerr << os.str();
2242 if (getGlobalNumElements () == 0) {
2243 if (GIDs.size () == 0) {
2245 std::ostringstream os;
2246 os << *prefix <<
"Done; both Map & input are empty" << endl;
2247 std::cerr << os.str();
2253 std::ostringstream os;
2254 os << *prefix <<
"Done: Map is empty on all processes, "
2255 "so all output PIDs are invalid (-1)." << endl;
2256 std::cerr << os.str();
2258 for (Teuchos::ArrayView<int>::size_type k = 0; k < PIDs.size (); ++k) {
2259 PIDs[k] = Tpetra::Details::OrdinalTraits<int>::invalid ();
2270 std::ostringstream os;
2271 os << *prefix <<
"Call setupDirectory" << endl;
2272 std::cerr << os.str();
2276 std::ostringstream os;
2277 os << *prefix <<
"Call directory_->getDirectoryEntries" << endl;
2278 std::cerr << os.str();
2281 directory_->getDirectoryEntries(*
this, GIDs, PIDs);
2283 std::ostringstream os;
2284 os << *prefix <<
"Done; getDirectoryEntries returned "
2285 << (retVal ==
IDNotPresent ?
"IDNotPresent" :
"AllIDsPresent")
2289 std::cerr << os.str();
2294 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2295 Teuchos::RCP<const Teuchos::Comm<int> >
2300 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2306 using Teuchos::outArg;
2307 using Teuchos::REDUCE_MIN;
2308 using Teuchos::reduceAll;
2312 std::unique_ptr<std::string> prefix;
2315 comm_.getRawPtr(),
"Map",
"checkIsDist");
2316 std::ostringstream os;
2317 os << *prefix <<
"Start" << endl;
2318 std::cerr << os.str();
2321 bool global =
false;
2322 if (comm_->getSize () > 1) {
2326 if (numGlobalElements_ == as<global_size_t> (numLocalElements_)) {
2339 reduceAll<int, int> (*comm_, REDUCE_MIN, localRep, outArg (allLocalRep));
2340 if (allLocalRep != 1) {
2350 std::ostringstream os;
2351 os << *prefix <<
"Done; global=" << (global ?
"true" :
"false")
2353 std::cerr << os.str();
2360 template <
class LocalOrdinal,
class GlobalOrdinal>
2361 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2363 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2365 typedef LocalOrdinal LO;
2366 typedef GlobalOrdinal GO;
2367 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2368 return createLocalMapWithNode<LO, GO, NT> (numElements, comm);
2371 template <
class LocalOrdinal,
class GlobalOrdinal>
2372 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2374 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2376 typedef LocalOrdinal LO;
2377 typedef GlobalOrdinal GO;
2378 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2379 return createUniformContigMapWithNode<LO, GO, NT> (numElements, comm);
2382 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2383 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2385 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2390 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2392 return rcp (
new map_type (numElements, indexBase, comm, GloballyDistributed));
2395 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2396 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2398 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2404 const GlobalOrdinal indexBase = 0;
2407 return rcp (
new map_type (globalNumElts, indexBase, comm, LocallyReplicated));
2410 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2411 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2413 const size_t localNumElements,
2414 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2419 const GlobalOrdinal indexBase = 0;
2421 return rcp (
new map_type (numElements, localNumElements, indexBase, comm));
2424 template <
class LocalOrdinal,
class GlobalOrdinal>
2425 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2427 const size_t localNumElements,
2428 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2430 typedef LocalOrdinal LO;
2431 typedef GlobalOrdinal GO;
2434 return Tpetra::createContigMapWithNode<LO, GO, NT> (numElements, localNumElements, comm);
2437 template <
class LocalOrdinal,
class GlobalOrdinal>
2438 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2440 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2442 typedef LocalOrdinal LO;
2443 typedef GlobalOrdinal GO;
2446 return Tpetra::createNonContigMapWithNode<LO, GO, NT> (elementList, comm);
2449 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2450 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2452 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2458 const GST INV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2462 const GlobalOrdinal indexBase = 0;
2464 return rcp (
new map_type (INV, elementList, indexBase, comm));
2467 template<
class LO,
class GO,
class NT>
2468 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >
2472 using Teuchos::Array;
2473 using Teuchos::ArrayView;
2481 const bool verbose = Details::Behavior::verbose(
"Map");
2482 std::unique_ptr<std::string> prefix;
2484 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2485 prefix = Details::createPrefix(
2486 comm.getRawPtr(),
"createOneToOne(Map)");
2487 std::ostringstream os;
2488 os << *prefix <<
"Start" << endl;
2491 const size_t maxNumToPrint = verbose ?
2492 Details::Behavior::verbosePrintCountThreshold() : size_t(0);
2493 const GST GINV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2494 const int myRank = M->getComm ()->getRank ();
2500 if (! M->isDistributed ()) {
2507 const GST numGlobalEntries = M->getGlobalNumElements ();
2508 if (M->isContiguous()) {
2509 const size_t numLocalEntries =
2510 (myRank == 0) ? as<size_t>(numGlobalEntries) : size_t(0);
2512 std::ostringstream os;
2513 os << *prefix <<
"Input is locally replicated & contiguous; "
2514 "numLocalEntries=" << numLocalEntries << endl;
2518 rcp(
new map_type(numGlobalEntries, numLocalEntries,
2519 M->getIndexBase(), M->getComm()));
2521 std::ostringstream os;
2522 os << *prefix <<
"Done" << endl;
2529 std::ostringstream os;
2530 os << *prefix <<
"Input is locally replicated & noncontiguous"
2534 ArrayView<const GO> myGids =
2535 (myRank == 0) ? M->getLocalElementList() : Teuchos::null;
2537 rcp(
new map_type(GINV, myGids(), M->getIndexBase(),
2540 std::ostringstream os;
2541 os << *prefix <<
"Done" << endl;
2547 else if (M->isContiguous ()) {
2549 std::ostringstream os;
2550 os << *prefix <<
"Input is distributed & contiguous" << endl;
2559 std::ostringstream os;
2560 os << *prefix <<
"Input is distributed & noncontiguous" << endl;
2564 const size_t numMyElems = M->getLocalNumElements ();
2565 ArrayView<const GO> myElems = M->getLocalElementList ();
2566 Array<int> owner_procs_vec (numMyElems);
2569 std::ostringstream os;
2570 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2577 std::ostringstream os;
2578 os << *prefix <<
"getDirectoryEntries result: ";
2584 Array<GO> myOwned_vec (numMyElems);
2585 size_t numMyOwnedElems = 0;
2586 for (
size_t i = 0; i < numMyElems; ++i) {
2587 const GO GID = myElems[i];
2588 const int owner = owner_procs_vec[i];
2590 if (myRank == owner) {
2591 myOwned_vec[numMyOwnedElems++] = GID;
2594 myOwned_vec.resize (numMyOwnedElems);
2597 std::ostringstream os;
2598 os << *prefix <<
"Create Map: ";
2603 auto retMap = rcp(
new map_type(GINV, myOwned_vec(),
2604 M->getIndexBase(), M->getComm()));
2606 std::ostringstream os;
2607 os << *prefix <<
"Done" << endl;
2614 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2615 Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2619 using Details::Behavior;
2621 using Teuchos::Array;
2622 using Teuchos::ArrayView;
2625 using Teuchos::toString;
2628 using LO = LocalOrdinal;
2629 using GO = GlobalOrdinal;
2632 const bool verbose = Behavior::verbose(
"Map");
2633 std::unique_ptr<std::string> prefix;
2635 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2636 prefix = Details::createPrefix(
2637 comm.getRawPtr(),
"createOneToOne(Map,TieBreak)");
2638 std::ostringstream os;
2639 os << *prefix <<
"Start" << endl;
2642 const size_t maxNumToPrint = verbose ?
2643 Behavior::verbosePrintCountThreshold() : size_t(0);
2650 std::ostringstream os;
2651 os << *prefix <<
"Initialize Directory" << endl;
2656 std::ostringstream os;
2657 os << *prefix <<
"Done initializing Directory" << endl;
2660 size_t numMyElems = M->getLocalNumElements ();
2661 ArrayView<const GO> myElems = M->getLocalElementList ();
2662 Array<int> owner_procs_vec (numMyElems);
2664 std::ostringstream os;
2665 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2672 std::ostringstream os;
2673 os << *prefix <<
"getDirectoryEntries result: ";
2679 const int myRank = M->getComm()->getRank();
2680 Array<GO> myOwned_vec (numMyElems);
2681 size_t numMyOwnedElems = 0;
2682 for (
size_t i = 0; i < numMyElems; ++i) {
2683 const GO GID = myElems[i];
2684 const int owner = owner_procs_vec[i];
2685 if (myRank == owner) {
2686 myOwned_vec[numMyOwnedElems++] = GID;
2689 myOwned_vec.resize (numMyOwnedElems);
2694 Tpetra::Details::OrdinalTraits<global_size_t>::invalid ();
2696 std::ostringstream os;
2697 os << *prefix <<
"Create Map: ";
2702 RCP<const map_type> retMap
2703 (
new map_type (GINV, myOwned_vec (), M->getIndexBase (),
2706 std::ostringstream os;
2707 os << *prefix <<
"Done" << endl;
2721 #define TPETRA_MAP_INSTANT(LO,GO,NODE) \
2723 template class Map< LO , GO , NODE >; \
2725 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2726 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \
2727 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2729 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2730 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2731 const size_t localNumElements, \
2732 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2734 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2735 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \
2736 const Teuchos::RCP<const Teuchos::Comm<int> > &comm); \
2738 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2739 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2740 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2742 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2743 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M); \
2745 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2746 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M, \
2747 const Tpetra::Details::TieBreak<LO,GO>& tie_break); \
2751 #define TPETRA_MAP_INSTANT_DEFAULTNODE(LO,GO) \
2752 template Teuchos::RCP< const Map<LO,GO> > \
2753 createLocalMap<LO,GO>( const size_t, const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2755 template Teuchos::RCP< const Map<LO,GO> > \
2756 createContigMap<LO,GO>( global_size_t, size_t, \
2757 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2759 template Teuchos::RCP< const Map<LO,GO> > \
2760 createNonContigMap(const Teuchos::ArrayView<const GO> &, \
2761 const Teuchos::RCP<const Teuchos::Comm<int> > &); \
2763 template Teuchos::RCP< const Map<LO,GO> > \
2764 createUniformContigMap<LO,GO>( const global_size_t, \
2765 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2767 #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).