47 #ifndef TPETRA_MAP_DEF_HPP
48 #define TPETRA_MAP_DEF_HPP
50 #include "Tpetra_Directory.hpp"
51 #include "Tpetra_Details_FixedHashTable.hpp"
52 #include "Tpetra_Details_gathervPrint.hpp"
56 #include "Teuchos_as.hpp"
57 #include "Teuchos_TypeNameTraits.hpp"
58 #include "Teuchos_CommHelpers.hpp"
59 #include "Tpetra_Details_mpiIsInitialized.hpp"
67 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 comm_ (new Teuchos::SerialComm<int> ()),
72 numGlobalElements_ (0),
73 numLocalElements_ (0),
74 minMyGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
75 maxMyGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
76 minAllGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
77 maxAllGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
78 firstContiguousGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
79 lastContiguousGID_ (Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
83 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
88 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
89 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93 const global_ordinal_type indexBase,
94 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
96 const Teuchos::RCP<Node> &) :
97 Map<LocalOrdinal,GlobalOrdinal,Node>::
Map(numGlobalElements, indexBase,
100 #endif // TPETRA_ENABLE_DEPRECATED_CODE
102 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
110 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
113 using Teuchos::broadcast;
114 using Teuchos::outArg;
115 using Teuchos::reduceAll;
116 using Teuchos::REDUCE_MIN;
117 using Teuchos::REDUCE_MAX;
118 using Teuchos::typeName;
121 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
125 #ifdef HAVE_TPETRA_DEBUG
129 GST proc0NumGlobalElements = numGlobalElements;
130 broadcast<int, GST> (*comm_, 0, outArg (proc0NumGlobalElements));
131 GST minNumGlobalElements = numGlobalElements;
132 GST maxNumGlobalElements = numGlobalElements;
133 reduceAll<int, GST> (*comm, REDUCE_MIN, numGlobalElements, outArg (minNumGlobalElements));
134 reduceAll<int, GST> (*comm, REDUCE_MAX, numGlobalElements, outArg (maxNumGlobalElements));
135 TEUCHOS_TEST_FOR_EXCEPTION(
136 minNumGlobalElements != maxNumGlobalElements || numGlobalElements != minNumGlobalElements,
137 std::invalid_argument,
138 "Tpetra::Map constructor: All processes must provide the same number "
139 "of global elements. Process 0 set numGlobalElements = "
140 << proc0NumGlobalElements <<
". The calling process "
141 << comm->getRank () <<
" set numGlobalElements = " << numGlobalElements
142 <<
". The min and max values over all processes are "
143 << minNumGlobalElements <<
" resp. " << maxNumGlobalElements <<
".");
145 GO proc0IndexBase = indexBase;
146 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
147 GO minIndexBase = indexBase;
148 GO maxIndexBase = indexBase;
149 reduceAll<int, GO> (*comm, REDUCE_MIN, indexBase, outArg (minIndexBase));
150 reduceAll<int, GO> (*comm, REDUCE_MAX, indexBase, outArg (maxIndexBase));
151 TEUCHOS_TEST_FOR_EXCEPTION(
152 minIndexBase != maxIndexBase || indexBase != minIndexBase,
153 std::invalid_argument,
154 "Tpetra::Map constructor: "
155 "All processes must provide the same indexBase argument. "
156 "Process 0 set indexBase = " << proc0IndexBase <<
". The calling "
157 "process " << comm->getRank () <<
" set indexBase = " << indexBase
158 <<
". The min and max values over all processes are "
159 << minIndexBase <<
" resp. " << maxIndexBase <<
".");
161 #endif // HAVE_TPETRA_DEBUG
180 TEUCHOS_TEST_FOR_EXCEPTION(
181 (numGlobalElements < 1 && numGlobalElements != 0),
182 std::invalid_argument,
183 "Tpetra::Map constructor: numGlobalElements (= "
184 << numGlobalElements <<
") must be nonnegative.");
186 TEUCHOS_TEST_FOR_EXCEPTION(
187 numGlobalElements == GSTI, std::invalid_argument,
188 "Tpetra::Map constructor: You provided numGlobalElements = Teuchos::"
189 "OrdinalTraits<Tpetra::global_size_t>::invalid(). This version of the "
190 "constructor requires a valid value of numGlobalElements. You "
191 "probably mistook this constructor for the \"contiguous nonuniform\" "
192 "constructor, which can compute the global number of elements for you "
193 "if you set numGlobalElements to that value.");
195 size_t numLocalElements = 0;
196 if (lOrG == GloballyDistributed) {
211 const GST numProcs =
static_cast<GST
> (comm_->getSize ());
212 const GST myRank =
static_cast<GST
> (comm_->getRank ());
213 const GST quotient = numGlobalElements / numProcs;
214 const GST remainder = numGlobalElements - quotient * numProcs;
217 if (myRank < remainder) {
218 numLocalElements =
static_cast<size_t> (1) + static_cast<size_t> (quotient);
221 startIndex = as<GO> (myRank) * as<GO> (numLocalElements);
223 numLocalElements = as<size_t> (quotient);
224 startIndex = as<GO> (myRank) * as<GO> (numLocalElements) +
228 minMyGID_ = indexBase + startIndex;
229 maxMyGID_ = indexBase + startIndex + numLocalElements - 1;
230 minAllGID_ = indexBase;
231 maxAllGID_ = indexBase + numGlobalElements - 1;
232 distributed_ = (numProcs > 1);
235 numLocalElements = as<size_t> (numGlobalElements);
236 minMyGID_ = indexBase;
237 maxMyGID_ = indexBase + numGlobalElements - 1;
238 distributed_ =
false;
241 minAllGID_ = indexBase;
242 maxAllGID_ = indexBase + numGlobalElements - 1;
243 indexBase_ = indexBase;
244 numGlobalElements_ = numGlobalElements;
245 numLocalElements_ = numLocalElements;
246 firstContiguousGID_ = minMyGID_;
247 lastContiguousGID_ = maxMyGID_;
254 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
255 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
259 const size_t numLocalElements,
260 const global_ordinal_type indexBase,
261 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
262 const Teuchos::RCP<Node> &) :
263 Map<LocalOrdinal,GlobalOrdinal,Node>::
Map(numGlobalElements,
267 #endif // TPETRA_ENABLE_DEPRECATED_CODE
269 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
272 const size_t numLocalElements,
274 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) :
277 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
280 using Teuchos::broadcast;
281 using Teuchos::outArg;
282 using Teuchos::reduceAll;
283 using Teuchos::REDUCE_MIN;
284 using Teuchos::REDUCE_MAX;
285 using Teuchos::REDUCE_SUM;
289 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
293 #ifdef HAVE_TPETRA_DEBUG
296 const GST debugGlobalSum =
297 initialNonuniformDebugCheck (numGlobalElements, numLocalElements,
299 #endif // HAVE_TPETRA_DEBUG
313 scan<int, GO> (*comm, REDUCE_SUM, numLocalElements, outArg (scanResult));
314 const GO myOffset = scanResult - numLocalElements;
316 if (numGlobalElements != GSTI) {
317 numGlobalElements_ = numGlobalElements;
323 const int numProcs = comm->getSize ();
324 GST globalSum = scanResult;
326 broadcast (*comm, numProcs - 1, outArg (globalSum));
328 numGlobalElements_ = globalSum;
330 #ifdef HAVE_TPETRA_DEBUG
332 TEUCHOS_TEST_FOR_EXCEPTION(
333 globalSum != debugGlobalSum, std::logic_error,
334 "Tpetra::Map constructor (contiguous nonuniform): "
335 "globalSum = " << globalSum <<
" != debugGlobalSum = " << debugGlobalSum
336 <<
". Please report this bug to the Tpetra developers.");
337 #endif // HAVE_TPETRA_DEBUG
339 numLocalElements_ = numLocalElements;
340 indexBase_ = indexBase;
341 minAllGID_ = (numGlobalElements_ == 0) ?
342 std::numeric_limits<GO>::max () :
344 maxAllGID_ = (numGlobalElements_ == 0) ?
345 std::numeric_limits<GO>::lowest () :
346 indexBase +
static_cast<GO
> (numGlobalElements_) - static_cast<GO> (1);
347 minMyGID_ = (numLocalElements_ == 0) ?
348 std::numeric_limits<GO>::max () :
349 indexBase +
static_cast<GO
> (myOffset);
350 maxMyGID_ = (numLocalElements_ == 0) ?
351 std::numeric_limits<GO>::lowest () :
352 indexBase + myOffset +
static_cast<GO
> (numLocalElements) - static_cast<GO> (1);
353 firstContiguousGID_ = minMyGID_;
354 lastContiguousGID_ = maxMyGID_;
356 distributed_ = checkIsDist ();
362 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
366 const size_t numLocalElements,
367 const GlobalOrdinal indexBase,
368 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
const
370 #ifdef HAVE_TPETRA_DEBUG
371 using Teuchos::broadcast;
372 using Teuchos::outArg;
374 using Teuchos::REDUCE_MAX;
375 using Teuchos::REDUCE_MIN;
376 using Teuchos::REDUCE_SUM;
377 using Teuchos::reduceAll;
378 typedef GlobalOrdinal GO;
380 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
390 GST debugGlobalSum = 0;
391 reduceAll<int, GST> (*comm, REDUCE_SUM,
static_cast<GST
> (numLocalElements),
392 outArg (debugGlobalSum));
396 GST proc0NumGlobalElements = numGlobalElements;
397 broadcast<int, GST> (*comm_, 0, outArg (proc0NumGlobalElements));
398 GST minNumGlobalElements = numGlobalElements;
399 GST maxNumGlobalElements = numGlobalElements;
400 reduceAll<int, GST> (*comm, REDUCE_MIN, numGlobalElements,
401 outArg (minNumGlobalElements));
402 reduceAll<int, GST> (*comm, REDUCE_MAX, numGlobalElements,
403 outArg (maxNumGlobalElements));
404 TEUCHOS_TEST_FOR_EXCEPTION(
405 minNumGlobalElements != maxNumGlobalElements ||
406 numGlobalElements != minNumGlobalElements,
407 std::invalid_argument,
408 "Tpetra::Map constructor: All processes must provide the same number "
409 "of global elements. This is true even if that argument is Teuchos::"
410 "OrdinalTraits<global_size_t>::invalid() to signal that the Map should "
411 "compute the global number of elements. Process 0 set numGlobalElements"
412 " = " << proc0NumGlobalElements <<
". The calling process "
413 << comm->getRank () <<
" set numGlobalElements = " << numGlobalElements
414 <<
". The min and max values over all processes are "
415 << minNumGlobalElements <<
" resp. " << maxNumGlobalElements <<
".");
417 GO proc0IndexBase = indexBase;
418 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
419 GO minIndexBase = indexBase;
420 GO maxIndexBase = indexBase;
421 reduceAll<int, GO> (*comm, REDUCE_MIN, indexBase, outArg (minIndexBase));
422 reduceAll<int, GO> (*comm, REDUCE_MAX, indexBase, outArg (maxIndexBase));
423 TEUCHOS_TEST_FOR_EXCEPTION(
424 minIndexBase != maxIndexBase || indexBase != minIndexBase,
425 std::invalid_argument,
426 "Tpetra::Map constructor: "
427 "All processes must provide the same indexBase argument. "
428 "Process 0 set indexBase = " << proc0IndexBase <<
". The calling "
429 "process " << comm->getRank () <<
" set indexBase = " << indexBase
430 <<
". The min and max values over all processes are "
431 << minIndexBase <<
" resp. " << maxIndexBase <<
".");
435 TEUCHOS_TEST_FOR_EXCEPTION
436 (numGlobalElements != GSTI && debugGlobalSum != numGlobalElements,
437 std::invalid_argument,
"Tpetra::Map constructor: The sum of each "
438 "process' number of indices over all processes, " << debugGlobalSum
439 <<
" != numGlobalElements = " << numGlobalElements <<
". If you "
440 "would like this constructor to compute numGlobalElements for you, "
441 "you may set numGlobalElements = "
442 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() on input. "
443 "Please note that this is NOT necessarily -1.");
446 return debugGlobalSum;
448 (void)numGlobalElements;
449 (void)numLocalElements;
453 #endif // HAVE_TPETRA_DEBUG
456 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
458 Map<LocalOrdinal,GlobalOrdinal,Node>::
459 initWithNonownedHostIndexList (
const global_size_t numGlobalElements,
460 const Kokkos::View<
const GlobalOrdinal*,
463 Kokkos::MemoryUnmanaged>& entryList_host,
464 const GlobalOrdinal indexBase,
465 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
467 using Kokkos::LayoutLeft;
468 using Kokkos::subview;
471 using Teuchos::broadcast;
472 using Teuchos::outArg;
474 using Teuchos::REDUCE_MAX;
475 using Teuchos::REDUCE_MIN;
476 using Teuchos::REDUCE_SUM;
477 using Teuchos::reduceAll;
478 typedef LocalOrdinal LO;
479 typedef GlobalOrdinal GO;
481 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
484 TEUCHOS_TEST_FOR_EXCEPTION
485 (! Kokkos::is_initialized (), std::runtime_error,
486 "Tpetra::Map constructor: The Kokkos execution space "
487 << Teuchos::TypeNameTraits<execution_space>::name ()
488 <<
" has not been initialized. "
489 "Please initialize it before creating a Map.")
502 const
size_t numLocalElements = static_cast<
size_t> (entryList_host.size ());
504 initialNonuniformDebugCheck (numGlobalElements, numLocalElements,
515 if (numGlobalElements != GSTI) {
516 numGlobalElements_ = numGlobalElements;
519 reduceAll<int, GST> (*comm, REDUCE_SUM,
520 static_cast<GST
> (numLocalElements),
521 outArg (numGlobalElements_));
547 numLocalElements_ = numLocalElements;
548 indexBase_ = indexBase;
550 minMyGID_ = indexBase_;
551 maxMyGID_ = indexBase_;
561 if (numLocalElements_ > 0) {
565 View<GO*, LayoutLeft, device_type> lgMap (
"lgMap", numLocalElements_);
566 auto lgMap_host = Kokkos::create_mirror_view (lgMap);
573 firstContiguousGID_ = entryList_host[0];
574 lastContiguousGID_ = firstContiguousGID_+1;
582 lgMap_host[0] = firstContiguousGID_;
584 for ( ; i < numLocalElements_; ++i) {
585 const GO curGid = entryList_host[i];
586 const LO curLid = as<LO> (i);
588 if (lastContiguousGID_ != curGid)
break;
594 lgMap_host[curLid] = curGid;
595 ++lastContiguousGID_;
597 --lastContiguousGID_;
602 minMyGID_ = firstContiguousGID_;
603 maxMyGID_ = lastContiguousGID_;
608 const std::pair<size_t, size_t> ncRange (i, entryList_host.extent (0));
609 auto nonContigGids_host = subview (entryList_host, ncRange);
610 TEUCHOS_TEST_FOR_EXCEPTION
611 (static_cast<size_t> (nonContigGids_host.extent (0)) !=
612 static_cast<size_t> (entryList_host.extent (0) - i),
613 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
614 "nonContigGids_host.extent(0) = "
615 << nonContigGids_host.extent (0)
616 <<
" != entryList_host.extent(0) - i = "
617 << (entryList_host.extent (0) - i) <<
" = "
618 << entryList_host.extent (0) <<
" - " << i
619 <<
". Please report this bug to the Tpetra developers.");
623 View<GO*, LayoutLeft, device_type>
624 nonContigGids (
"nonContigGids", nonContigGids_host.size ());
627 glMap_ = global_to_local_table_type (nonContigGids,
630 static_cast<LO> (i));
638 for ( ; i < numLocalElements_; ++i) {
639 const GO curGid = entryList_host[i];
640 const LO curLid = as<LO> (i);
641 lgMap_host[curLid] = curGid;
645 if (curGid < minMyGID_) {
648 if (curGid > maxMyGID_) {
659 lgMapHost_ = lgMap_host;
662 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
663 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
667 firstContiguousGID_ = indexBase_+1;
668 lastContiguousGID_ = indexBase_;
693 if (std::numeric_limits<GO>::is_signed) {
696 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
699 minMaxInput[0] = -minMyGID_;
700 minMaxInput[1] = maxMyGID_;
701 minMaxInput[2] = localDist;
707 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
708 minAllGID_ = -minMaxOutput[0];
709 maxAllGID_ = minMaxOutput[1];
710 const GO globalDist = minMaxOutput[2];
711 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
715 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
716 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
717 distributed_ = checkIsDist ();
722 TEUCHOS_TEST_FOR_EXCEPTION(
723 minAllGID_ < indexBase_,
724 std::invalid_argument,
725 "Tpetra::Map constructor (noncontiguous): "
726 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
727 "less than the given indexBase = " << indexBase_ <<
".");
733 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
736 const GlobalOrdinal indexList[],
737 const LocalOrdinal indexListSize,
738 const GlobalOrdinal indexBase,
739 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
742 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
749 const GlobalOrdinal*
const indsRaw = indexListSize == 0 ? NULL : indexList;
750 Kokkos::View<
const GlobalOrdinal*,
753 Kokkos::MemoryUnmanaged> inds (indsRaw, indexListSize);
754 initWithNonownedHostIndexList (numGlobalElements, inds, indexBase, comm);
757 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
758 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
761 const Teuchos::ArrayView<const GlobalOrdinal>& entryList,
762 const GlobalOrdinal indexBase,
763 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
764 const Teuchos::RCP<Node>& ) :
765 Map<LocalOrdinal,GlobalOrdinal,Node>::
Map(numGlobalElements, entryList,
768 #endif // TPETRA_ENABLE_DEPRECATED_CODE
770 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
773 const Teuchos::ArrayView<const GlobalOrdinal>& entryList,
774 const GlobalOrdinal indexBase,
775 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
778 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
782 const size_t numLclInds =
static_cast<size_t> (entryList.size ());
787 const GlobalOrdinal*
const indsRaw =
788 numLclInds == 0 ? NULL : entryList.getRawPtr ();
789 Kokkos::View<
const GlobalOrdinal*,
792 Kokkos::MemoryUnmanaged> inds (indsRaw, numLclInds);
793 initWithNonownedHostIndexList (numGlobalElements, inds, indexBase, comm);
796 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
799 const Kokkos::View<const GlobalOrdinal*, device_type>& entryList,
800 const GlobalOrdinal indexBase,
801 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
804 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
806 using Kokkos::LayoutLeft;
807 using Kokkos::subview;
810 using Teuchos::ArrayView;
812 using Teuchos::broadcast;
813 using Teuchos::outArg;
815 using Teuchos::REDUCE_MAX;
816 using Teuchos::REDUCE_MIN;
817 using Teuchos::REDUCE_SUM;
818 using Teuchos::reduceAll;
819 using Teuchos::typeName;
820 typedef LocalOrdinal LO;
821 typedef GlobalOrdinal GO;
823 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
838 const size_t numLocalElements =
static_cast<size_t> (entryList.size ());
840 initialNonuniformDebugCheck (numGlobalElements, numLocalElements,
851 if (numGlobalElements != GSTI) {
852 numGlobalElements_ = numGlobalElements;
855 reduceAll<int, GST> (*comm, REDUCE_SUM,
856 static_cast<GST
> (numLocalElements),
857 outArg (numGlobalElements_));
883 numLocalElements_ = numLocalElements;
884 indexBase_ = indexBase;
886 minMyGID_ = indexBase_;
887 maxMyGID_ = indexBase_;
897 if (numLocalElements_ > 0) {
901 View<GO*, LayoutLeft, device_type> lgMap (
"lgMap", numLocalElements_);
902 auto lgMap_host = Kokkos::create_mirror_view (lgMap);
906 auto entryList_host = Kokkos::create_mirror_view (entryList);
909 firstContiguousGID_ = entryList_host[0];
910 lastContiguousGID_ = firstContiguousGID_+1;
918 lgMap_host[0] = firstContiguousGID_;
920 for ( ; i < numLocalElements_; ++i) {
921 const GO curGid = entryList_host[i];
922 const LO curLid = as<LO> (i);
924 if (lastContiguousGID_ != curGid)
break;
930 lgMap_host[curLid] = curGid;
931 ++lastContiguousGID_;
933 --lastContiguousGID_;
938 minMyGID_ = firstContiguousGID_;
939 maxMyGID_ = lastContiguousGID_;
944 const std::pair<size_t, size_t> ncRange (i, entryList.extent (0));
945 auto nonContigGids = subview (entryList, ncRange);
946 TEUCHOS_TEST_FOR_EXCEPTION
947 (static_cast<size_t> (nonContigGids.extent (0)) !=
948 static_cast<size_t> (entryList.extent (0) - i),
949 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
950 "nonContigGids.extent(0) = "
951 << nonContigGids.extent (0)
952 <<
" != entryList.extent(0) - i = "
953 << (entryList.extent (0) - i) <<
" = "
954 << entryList.extent (0) <<
" - " << i
955 <<
". Please report this bug to the Tpetra developers.");
960 static_cast<LO> (i));
968 for ( ; i < numLocalElements_; ++i) {
969 const GO curGid = entryList_host[i];
970 const LO curLid =
static_cast<LO
> (i);
971 lgMap_host[curLid] = curGid;
975 if (curGid < minMyGID_) {
978 if (curGid > maxMyGID_) {
989 lgMapHost_ = lgMap_host;
992 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
993 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
997 firstContiguousGID_ = indexBase_+1;
998 lastContiguousGID_ = indexBase_;
1023 if (std::numeric_limits<GO>::is_signed) {
1025 const GO localDist =
1026 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
1029 minMaxInput[0] = -minMyGID_;
1030 minMaxInput[1] = maxMyGID_;
1031 minMaxInput[2] = localDist;
1034 minMaxOutput[0] = 0;
1035 minMaxOutput[1] = 0;
1036 minMaxOutput[2] = 0;
1037 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
1038 minAllGID_ = -minMaxOutput[0];
1039 maxAllGID_ = minMaxOutput[1];
1040 const GO globalDist = minMaxOutput[2];
1041 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
1045 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
1046 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
1047 distributed_ = checkIsDist ();
1050 contiguous_ =
false;
1052 TEUCHOS_TEST_FOR_EXCEPTION(
1053 minAllGID_ < indexBase_,
1054 std::invalid_argument,
1055 "Tpetra::Map constructor (noncontiguous): "
1056 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
1057 "less than the given indexBase = " << indexBase_ <<
".");
1064 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1067 if (! Kokkos::is_initialized ()) {
1068 std::ostringstream os;
1069 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1070 "Kokkos::finalize() has been called. This is user error! There are "
1071 "two likely causes: " << std::endl <<
1072 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1074 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1075 "of a Tpetra::Map) at the same scope in main() as Kokkos::finalize() "
1076 "or Tpetra::finalize()." << std::endl << std::endl <<
1077 "Don't do either of these! Please refer to GitHib Issue #2372."
1079 ::Tpetra::Details::printOnce (std::cerr, os.str (),
1080 this->getComm ().getRawPtr ());
1083 using ::Tpetra::Details::mpiIsInitialized;
1084 using ::Tpetra::Details::mpiIsFinalized;
1085 using ::Tpetra::Details::teuchosCommIsAnMpiComm;
1087 Teuchos::RCP<const Teuchos::Comm<int> > comm = this->getComm ();
1088 if (! comm.is_null () && teuchosCommIsAnMpiComm (*comm) &&
1089 mpiIsInitialized () && mpiIsFinalized ()) {
1095 std::ostringstream os;
1096 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1097 "MPI_Finalize() has been called. This is user error! There are "
1098 "two likely causes: " << std::endl <<
1099 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1101 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1102 "of a Tpetra::Map) at the same scope in main() as MPI_finalize() or "
1103 "Tpetra::finalize()." << std::endl << std::endl <<
1104 "Don't do either of these! Please refer to GitHib Issue #2372."
1106 ::Tpetra::Details::printOnce (std::cerr, os.str (), comm.getRawPtr ());
1115 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1119 TEUCHOS_TEST_FOR_EXCEPTION(
1120 getComm ().is_null (), std::logic_error,
"Tpetra::Map::isOneToOne: "
1121 "getComm() returns null. Please report this bug to the Tpetra "
1126 return directory_->isOneToOne (*
this);
1130 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1135 if (isContiguous ()) {
1136 if (globalIndex < getMinGlobalIndex () ||
1137 globalIndex > getMaxGlobalIndex ()) {
1138 return Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1140 return static_cast<LocalOrdinal
> (globalIndex - getMinGlobalIndex ());
1142 else if (globalIndex >= firstContiguousGID_ &&
1143 globalIndex <= lastContiguousGID_) {
1144 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGID_);
1149 return glMap_.get (globalIndex);
1153 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1158 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
1159 return Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
1161 if (isContiguous ()) {
1162 return getMinGlobalIndex () + localIndex;
1169 return lgMapHost_[localIndex];
1173 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1178 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
1185 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1189 return this->getLocalElement (globalIndex) !=
1190 Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1193 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1198 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1204 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1210 getMinGlobalIndex (), getMaxGlobalIndex (),
1211 firstContiguousGID_, lastContiguousGID_,
1212 getNodeNumElements (), isContiguous ());
1215 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1220 using Teuchos::outArg;
1221 using Teuchos::REDUCE_MIN;
1222 using Teuchos::reduceAll;
1232 else if (getComm ()->getSize () != map.
getComm ()->getSize ()) {
1243 else if (isContiguous () && isUniform () &&
1251 lgMap_.extent (0) != 0 && map.lgMap_.extent (0) != 0 &&
1252 lgMap_.data () == map.lgMap_.data ()) {
1266 TEUCHOS_TEST_FOR_EXCEPTION(
1268 "Tpetra::Map::isCompatible: There's a bug in this method. We've already "
1269 "checked that this condition is true above, but it's false here. "
1270 "Please report this bug to the Tpetra developers.");
1273 const int locallyCompat =
1276 int globallyCompat = 0;
1277 reduceAll<int, int> (*comm_, REDUCE_MIN, locallyCompat, outArg (globallyCompat));
1278 return (globallyCompat == 1);
1281 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1286 using Teuchos::ArrayView;
1287 typedef GlobalOrdinal GO;
1288 typedef typename ArrayView<const GO>::size_type size_type;
1311 if (isContiguous ()) {
1316 TEUCHOS_TEST_FOR_EXCEPTION(
1317 ! this->isContiguous () || map.
isContiguous (), std::logic_error,
1318 "Tpetra::Map::locallySameAs: BUG");
1320 const GO minLhsGid = this->getMinGlobalIndex ();
1321 const size_type numRhsElts = rhsElts.size ();
1322 for (size_type k = 0; k < numRhsElts; ++k) {
1323 const GO curLhsGid = minLhsGid +
static_cast<GO
> (k);
1324 if (curLhsGid != rhsElts[k]) {
1332 TEUCHOS_TEST_FOR_EXCEPTION(
1333 this->isContiguous () || ! map.
isContiguous (), std::logic_error,
1334 "Tpetra::Map::locallySameAs: BUG");
1335 ArrayView<const GO> lhsElts = this->getNodeElementList ();
1337 const size_type numLhsElts = lhsElts.size ();
1338 for (size_type k = 0; k < numLhsElts; ++k) {
1339 const GO curRhsGid = minRhsGid +
static_cast<GO
> (k);
1340 if (curRhsGid != lhsElts[k]) {
1346 else if (this->lgMap_.data () == map.lgMap_.data ()) {
1356 ArrayView<const GO> lhsElts = getNodeElementList ();
1362 return std::equal (lhsElts.begin (), lhsElts.end (), rhsElts.begin ());
1368 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1378 auto lmap2 = this->getLocalMap();
1380 auto numLocalElements1 = lmap1.getNodeNumElements();
1381 auto numLocalElements2 = lmap2.getNodeNumElements();
1383 if (numLocalElements1 > numLocalElements2) {
1388 if (lmap1.isContiguous () && lmap2.isContiguous ()) {
1390 return ((lmap1.getMinGlobalIndex () == lmap2.getMinGlobalIndex ()) &&
1391 (lmap1.getMaxGlobalIndex () <= lmap2.getMaxGlobalIndex ()));
1394 if (lmap1.getMinGlobalIndex () < lmap2.getMinGlobalIndex () ||
1395 lmap1.getMaxGlobalIndex () > lmap2.getMaxGlobalIndex ()) {
1401 typedef Kokkos::RangePolicy<LocalOrdinal, typename Node::execution_space> range_type;
1404 LocalOrdinal numDiff = 0;
1405 Kokkos::parallel_reduce(
"isLocallyFitted", range_type(0, numLocalElements1),
1406 KOKKOS_LAMBDA(
const LocalOrdinal i, LocalOrdinal& diff) {
1407 diff += (lmap1.getGlobalElement(i) != lmap2.getGlobalElement(i));
1410 return (numDiff == 0);
1413 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1418 using Teuchos::outArg;
1419 using Teuchos::REDUCE_MIN;
1420 using Teuchos::reduceAll;
1430 else if (getComm ()->getSize () != map.
getComm ()->getSize ()) {
1453 else if (isContiguous () && isUniform () &&
1474 const int isSame_lcl = locallySameAs (map) ? 1 : 0;
1478 reduceAll<int, int> (*comm_, REDUCE_MIN, isSame_lcl, outArg (isSame_gbl));
1479 return isSame_gbl == 1;
1483 template <
class LO,
class GO,
class DT>
1486 FillLgMap (
const Kokkos::View<GO*, DT>& lgMap,
1487 const GO startGid) :
1488 lgMap_ (lgMap), startGid_ (startGid)
1490 Kokkos::RangePolicy<LO, typename DT::execution_space>
1491 range (static_cast<LO> (0), static_cast<LO> (lgMap.size ()));
1492 Kokkos::parallel_for (range, *
this);
1495 KOKKOS_INLINE_FUNCTION
void operator () (
const LO& lid)
const {
1496 lgMap_(lid) = startGid_ +
static_cast<GO
> (lid);
1500 const Kokkos::View<GO*, DT> lgMap_;
1507 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1508 typename Map<LocalOrdinal,GlobalOrdinal,Node>::global_indices_array_type
1511 typedef LocalOrdinal LO;
1512 typedef GlobalOrdinal GO;
1515 typedef decltype (lgMap_) const_lg_view_type;
1516 typedef typename const_lg_view_type::non_const_type lg_view_type;
1521 const bool needToCreateLocalToGlobalMapping =
1522 lgMap_.extent (0) == 0 && numLocalElements_ > 0;
1524 if (needToCreateLocalToGlobalMapping) {
1525 #ifdef HAVE_TEUCHOS_DEBUG
1528 TEUCHOS_TEST_FOR_EXCEPTION( ! isContiguous(), std::logic_error,
1529 "Tpetra::Map::getNodeElementList: The local-to-global mapping (lgMap_) "
1530 "should have been set up already for a noncontiguous Map. Please report"
1531 " this bug to the Tpetra team.");
1532 #endif // HAVE_TEUCHOS_DEBUG
1534 const LO numElts =
static_cast<LO
> (getNodeNumElements ());
1536 lg_view_type lgMap (
"lgMap", numElts);
1537 FillLgMap<LO, GO, DT> fillIt (lgMap, minMyGID_);
1539 auto lgMapHost = Kokkos::create_mirror_view (lgMap);
1544 lgMapHost_ = lgMapHost;
1549 execution_space::fence ();
1555 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1556 Teuchos::ArrayView<const GlobalOrdinal>
1559 typedef GlobalOrdinal GO;
1564 (void) this->getMyGlobalIndices ();
1567 const GO* lgMapHostRawPtr = lgMapHost_.data ();
1571 return Teuchos::ArrayView<const GO> (lgMapHostRawPtr,
1572 lgMapHost_.extent (0),
1573 Teuchos::RCP_DISABLE_NODE_LOOKUP);
1576 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1578 return distributed_;
1581 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1583 using Teuchos::TypeNameTraits;
1584 std::ostringstream os;
1586 os <<
"Tpetra::Map: {"
1587 <<
"LocalOrdinalType: " << TypeNameTraits<LocalOrdinal>::name ()
1588 <<
", GlobalOrdinalType: " << TypeNameTraits<GlobalOrdinal>::name ()
1589 <<
", NodeType: " << TypeNameTraits<Node>::name ();
1590 if (this->getObjectLabel () !=
"") {
1591 os <<
", Label: \"" << this->getObjectLabel () <<
"\"";
1593 os <<
", Global number of entries: " << getGlobalNumElements ()
1594 <<
", Number of processes: " << getComm ()->getSize ()
1595 <<
", Uniform: " << (isUniform () ?
"true" :
"false")
1596 <<
", Contiguous: " << (isContiguous () ?
"true" :
"false")
1597 <<
", Distributed: " << (isDistributed () ?
"true" :
"false")
1606 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1611 typedef LocalOrdinal LO;
1615 if (vl < Teuchos::VERB_HIGH) {
1616 return std::string ();
1618 auto outStringP = Teuchos::rcp (
new std::ostringstream ());
1619 Teuchos::RCP<Teuchos::FancyOStream> outp =
1620 Teuchos::getFancyOStream (outStringP);
1621 Teuchos::FancyOStream& out = *outp;
1623 auto comm = this->getComm ();
1624 const int myRank = comm->getRank ();
1625 const int numProcs = comm->getSize ();
1626 out <<
"Process " << myRank <<
" of " << numProcs <<
":" << endl;
1627 Teuchos::OSTab tab1 (out);
1629 const LO numEnt =
static_cast<LO
> (this->getNodeNumElements ());
1630 out <<
"My number of entries: " << numEnt << endl
1631 <<
"My minimum global index: " << this->getMinGlobalIndex () << endl
1632 <<
"My maximum global index: " << this->getMaxGlobalIndex () << endl;
1634 if (vl == Teuchos::VERB_EXTREME) {
1635 out <<
"My global indices: [";
1636 const LO minLclInd = this->getMinLocalIndex ();
1637 for (LO k = 0; k < numEnt; ++k) {
1638 out << minLclInd + this->getGlobalElement (k);
1639 if (k + 1 < numEnt) {
1647 return outStringP->str ();
1650 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1654 const Teuchos::EVerbosityLevel verbLevel)
const
1656 using Teuchos::TypeNameTraits;
1657 using Teuchos::VERB_DEFAULT;
1658 using Teuchos::VERB_NONE;
1659 using Teuchos::VERB_LOW;
1660 using Teuchos::VERB_HIGH;
1662 typedef LocalOrdinal LO;
1663 typedef GlobalOrdinal GO;
1664 const Teuchos::EVerbosityLevel vl =
1665 (verbLevel == VERB_DEFAULT) ? VERB_LOW : verbLevel;
1667 if (vl == VERB_NONE) {
1674 auto comm = this->getComm ();
1675 if (comm.is_null ()) {
1678 const int myRank = comm->getRank ();
1679 const int numProcs = comm->getSize ();
1688 Teuchos::RCP<Teuchos::OSTab> tab0, tab1;
1694 tab0 = Teuchos::rcp (
new Teuchos::OSTab (out));
1695 out <<
"\"Tpetra::Map\":" << endl;
1696 tab1 = Teuchos::rcp (
new Teuchos::OSTab (out));
1698 out <<
"Template parameters:" << endl;
1699 Teuchos::OSTab tab2 (out);
1700 out <<
"LocalOrdinal: " << TypeNameTraits<LO>::name () << endl
1701 <<
"GlobalOrdinal: " << TypeNameTraits<GO>::name () << endl
1702 <<
"Node: " << TypeNameTraits<Node>::name () << endl;
1704 const std::string label = this->getObjectLabel ();
1706 out <<
"Label: \"" << label <<
"\"" << endl;
1708 out <<
"Global number of entries: " << getGlobalNumElements () << endl
1709 <<
"Minimum global index: " << getMinAllGlobalIndex () << endl
1710 <<
"Maximum global index: " << getMaxAllGlobalIndex () << endl
1711 <<
"Index base: " << getIndexBase () << endl
1712 <<
"Number of processes: " << numProcs << endl
1713 <<
"Uniform: " << (isUniform () ?
"true" :
"false") << endl
1714 <<
"Contiguous: " << (isContiguous () ?
"true" :
"false") << endl
1715 <<
"Distributed: " << (isDistributed () ?
"true" :
"false") << endl;
1719 if (vl >= VERB_HIGH) {
1720 const std::string lclStr = this->localDescribeToString (vl);
1725 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1726 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1733 typedef LocalOrdinal LO;
1734 typedef GlobalOrdinal GO;
1744 if (newComm.is_null () || newComm->getSize () < 1) {
1745 return Teuchos::null;
1747 else if (newComm->getSize () == 1) {
1752 RCP<map_type> newMap (
new map_type ());
1754 newMap->comm_ = newComm;
1758 newMap->indexBase_ = this->indexBase_;
1759 newMap->numGlobalElements_ = this->numLocalElements_;
1760 newMap->numLocalElements_ = this->numLocalElements_;
1761 newMap->minMyGID_ = this->minMyGID_;
1762 newMap->maxMyGID_ = this->maxMyGID_;
1763 newMap->minAllGID_ = this->minMyGID_;
1764 newMap->maxAllGID_ = this->maxMyGID_;
1765 newMap->firstContiguousGID_ = this->firstContiguousGID_;
1766 newMap->lastContiguousGID_ = this->lastContiguousGID_;
1769 newMap->uniform_ = this->uniform_;
1770 newMap->contiguous_ = this->contiguous_;
1773 newMap->distributed_ =
false;
1774 newMap->lgMap_ = this->lgMap_;
1775 newMap->lgMapHost_ = this->lgMapHost_;
1776 newMap->glMap_ = this->glMap_;
1797 const GST RECOMPUTE = Tpetra::Details::OrdinalTraits<GST>::invalid ();
1813 auto lgMap = this->getMyGlobalIndices ();
1814 typedef typename std::decay<decltype (lgMap.extent (0)) >::type size_type;
1815 const size_type lclNumInds =
1816 static_cast<size_type
> (this->getNodeNumElements ());
1817 using Teuchos::TypeNameTraits;
1818 TEUCHOS_TEST_FOR_EXCEPTION
1819 (lgMap.extent (0) != lclNumInds, std::logic_error,
1820 "Tpetra::Map::replaceCommWithSubset: Result of getMyGlobalIndices() "
1821 "has length " << lgMap.extent (0) <<
" (of type " <<
1822 TypeNameTraits<size_type>::name () <<
") != this->getNodeNumElements()"
1823 " = " << this->getNodeNumElements () <<
". The latter, upon being "
1824 "cast to size_type = " << TypeNameTraits<size_type>::name () <<
", "
1825 "becomes " << lclNumInds <<
". Please report this bug to the Tpetra "
1828 Teuchos::ArrayView<const GO> lgMap = this->getNodeElementList ();
1831 const GO indexBase = this->getIndexBase ();
1832 return rcp (
new map_type (RECOMPUTE, lgMap, indexBase, newComm));
1836 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1837 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1841 using Teuchos::Comm;
1842 using Teuchos::null;
1843 using Teuchos::outArg;
1846 using Teuchos::REDUCE_MIN;
1847 using Teuchos::reduceAll;
1854 const int color = (numLocalElements_ == 0) ? 0 : 1;
1859 RCP<const Comm<int> > newComm = comm_->split (color, 0);
1865 if (newComm.is_null ()) {
1870 RCP<Map> map = rcp (
new Map ());
1872 map->comm_ = newComm;
1873 map->indexBase_ = indexBase_;
1874 map->numGlobalElements_ = numGlobalElements_;
1875 map->numLocalElements_ = numLocalElements_;
1876 map->minMyGID_ = minMyGID_;
1877 map->maxMyGID_ = maxMyGID_;
1878 map->minAllGID_ = minAllGID_;
1879 map->maxAllGID_ = maxAllGID_;
1880 map->firstContiguousGID_= firstContiguousGID_;
1881 map->lastContiguousGID_ = lastContiguousGID_;
1885 map->uniform_ = uniform_;
1886 map->contiguous_ = contiguous_;
1901 if (! distributed_ || newComm->getSize () == 1) {
1902 map->distributed_ =
false;
1904 const int iOwnAllGids = (numLocalElements_ == numGlobalElements_) ? 1 : 0;
1905 int allProcsOwnAllGids = 0;
1906 reduceAll<int, int> (*newComm, REDUCE_MIN, iOwnAllGids, outArg (allProcsOwnAllGids));
1907 map->distributed_ = (allProcsOwnAllGids == 1) ?
false :
true;
1910 map->lgMap_ = lgMap_;
1911 map->lgMapHost_ = lgMapHost_;
1912 map->glMap_ = glMap_;
1929 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1933 TEUCHOS_TEST_FOR_EXCEPTION(
1934 directory_.is_null (), std::logic_error,
"Tpetra::Map::setupDirectory: "
1935 "The Directory is null. "
1936 "Please report this bug to the Tpetra developers.");
1940 if (! directory_->initialized ()) {
1941 directory_->initialize (*
this);
1945 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1949 const Teuchos::ArrayView<int>& PIDs,
1950 const Teuchos::ArrayView<LocalOrdinal>& LIDs)
const
1952 using Tpetra::Details::OrdinalTraits;
1953 typedef Teuchos::ArrayView<int>::size_type size_type;
1961 if (getGlobalNumElements () == 0) {
1962 if (GIDs.size () == 0) {
1965 for (size_type k = 0; k < PIDs.size (); ++k) {
1966 PIDs[k] = OrdinalTraits<int>::invalid ();
1968 for (size_type k = 0; k < LIDs.size (); ++k) {
1969 LIDs[k] = OrdinalTraits<LocalOrdinal>::invalid ();
1979 return directory_->getDirectoryEntries (*
this, GIDs, PIDs, LIDs);
1982 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1986 const Teuchos::ArrayView<int> & PIDs)
const
1988 if (getGlobalNumElements () == 0) {
1989 if (GIDs.size () == 0) {
1993 for (Teuchos::ArrayView<int>::size_type k = 0; k < PIDs.size (); ++k) {
1994 PIDs[k] = Tpetra::Details::OrdinalTraits<int>::invalid ();
2004 return directory_->getDirectoryEntries (*
this, GIDs, PIDs);
2007 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2008 Teuchos::RCP<const Teuchos::Comm<int> >
2013 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2014 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2020 return Teuchos::rcp (
new Node);
2022 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2024 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2025 bool Map<LocalOrdinal,GlobalOrdinal,Node>::checkIsDist()
const {
2027 using Teuchos::outArg;
2028 using Teuchos::REDUCE_MIN;
2029 using Teuchos::reduceAll;
2031 bool global =
false;
2032 if (comm_->getSize () > 1) {
2036 if (numGlobalElements_ == as<global_size_t> (numLocalElements_)) {
2049 reduceAll<int, int> (*comm_, REDUCE_MIN, localRep, outArg (allLocalRep));
2050 if (allLocalRep != 1) {
2063 template <
class LocalOrdinal,
class GlobalOrdinal>
2064 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal> >
2066 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2068 typedef LocalOrdinal LO;
2069 typedef GlobalOrdinal GO;
2070 typedef typename ::Tpetra::Map<LO, GO>::node_type NT;
2071 return createLocalMapWithNode<LO, GO, NT> (numElements, comm);
2074 template <
class LocalOrdinal,
class GlobalOrdinal>
2075 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal> >
2077 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2079 typedef LocalOrdinal LO;
2080 typedef GlobalOrdinal GO;
2081 typedef typename ::Tpetra::Map<LO, GO>::node_type NT;
2082 return createUniformContigMapWithNode<LO, GO, NT> (numElements, comm);
2085 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2086 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2088 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2090 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
2091 const Teuchos::RCP<Node>&
2094 return Tpetra::createUniformContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>
2095 (numElements, comm);
2097 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2099 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2100 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2102 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2107 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2109 return rcp (
new map_type (numElements, indexBase, comm, GloballyDistributed));
2112 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2113 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2115 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2117 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
2118 const Teuchos::RCP<Node>&
2121 return Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal,Node>
2122 (numElements, comm);
2124 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2126 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2127 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2129 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2135 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2138 return rcp (
new map_type (globalNumElts, indexBase, comm, LocallyReplicated));
2141 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2142 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2144 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2146 const size_t localNumElements,
2147 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
2148 const Teuchos::RCP<Node>&
2151 return Tpetra::createContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>
2152 (numElements, localNumElements, comm);
2154 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2156 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2157 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2159 const size_t localNumElements,
2160 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2165 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2167 return rcp (
new map_type (numElements, localNumElements, indexBase, comm));
2170 template <
class LocalOrdinal,
class GlobalOrdinal>
2171 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal> >
2173 const size_t localNumElements,
2174 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2176 typedef LocalOrdinal LO;
2177 typedef GlobalOrdinal GO;
2180 return Tpetra::createContigMapWithNode<LO, GO, NT> (numElements, localNumElements, comm);
2184 template <
class LocalOrdinal,
class GlobalOrdinal>
2185 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal> >
2187 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2189 typedef LocalOrdinal LO;
2190 typedef GlobalOrdinal GO;
2193 return Tpetra::createNonContigMapWithNode<LO, GO, NT> (elementList, comm);
2197 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2198 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2200 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2202 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
2203 const Teuchos::RCP<Node>&
2206 return Tpetra::createNonContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>
2207 (elementList, comm);
2209 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2211 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2212 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2214 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2220 const GST INV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2224 const GlobalOrdinal indexBase = 0;
2226 return rcp (
new map_type (INV, elementList, indexBase, comm));
2229 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2230 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2232 Teuchos::RCP< const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2233 Tpetra::createWeightedContigMapWithNode (
const int myWeight,
2235 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
2236 const Teuchos::RCP<Node>&
2239 Teuchos::RCP< Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > map;
2240 int sumOfWeights, elemsLeft, localNumElements;
2241 const int numImages = comm->getSize();
2242 const int myImageID = comm->getRank();
2243 Teuchos::reduceAll<int>(*comm,Teuchos::REDUCE_SUM,myWeight,Teuchos::outArg(sumOfWeights));
2244 const double myShare = ((double)myWeight) / ((double)sumOfWeights);
2245 localNumElements = (int)std::floor( myShare * ((
double)numElements) );
2247 Teuchos::reduceAll<int>(*comm,Teuchos::REDUCE_SUM,localNumElements,Teuchos::outArg(elemsLeft));
2248 elemsLeft = numElements - elemsLeft;
2251 TEUCHOS_TEST_FOR_EXCEPT(elemsLeft < -numImages || numImages < elemsLeft);
2252 if (elemsLeft < 0) {
2254 if (myImageID >= numImages-elemsLeft) --localNumElements;
2256 else if (elemsLeft > 0) {
2258 if (myImageID < elemsLeft) ++localNumElements;
2261 return createContigMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(numElements,localNumElements,comm);
2263 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2266 template<
class LO,
class GO,
class NT>
2267 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >
2270 using Teuchos::Array;
2271 using Teuchos::ArrayView;
2276 const GST GINV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2277 const int myRank = M->getComm ()->getRank ();
2283 if (! M->isDistributed ()) {
2290 const GST numGlobalEntries = M->getGlobalNumElements ();
2291 if (M->isContiguous ()) {
2292 const size_t numLocalEntries =
2293 (myRank == 0) ? as<size_t> (numGlobalEntries) :
static_cast<size_t> (0);
2294 return rcp (
new map_type (numGlobalEntries, numLocalEntries,
2295 M->getIndexBase (), M->getComm ()));
2298 ArrayView<const GO> myGids =
2299 (myRank == 0) ? M->getNodeElementList () : Teuchos::null;
2300 return rcp (
new map_type (GINV, myGids (), M->getIndexBase (),
2304 else if (M->isContiguous ()) {
2311 const size_t numMyElems = M->getNodeNumElements ();
2312 ArrayView<const GO> myElems = M->getNodeElementList ();
2313 Array<int> owner_procs_vec (numMyElems);
2317 Array<GO> myOwned_vec (numMyElems);
2318 size_t numMyOwnedElems = 0;
2319 for (
size_t i = 0; i < numMyElems; ++i) {
2320 const GO GID = myElems[i];
2321 const int owner = owner_procs_vec[i];
2323 if (myRank == owner) {
2324 myOwned_vec[numMyOwnedElems++] = GID;
2327 myOwned_vec.resize (numMyOwnedElems);
2329 return rcp (
new map_type (GINV, myOwned_vec (), M->getIndexBase (),
2334 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2335 Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2339 using Teuchos::Array;
2340 using Teuchos::ArrayView;
2342 typedef LocalOrdinal LO;
2343 typedef GlobalOrdinal GO;
2345 int myID = M->
getComm()->getRank();
2354 size_t numMyElems = M->getNodeNumElements ();
2355 ArrayView<const GO> myElems = M->getNodeElementList ();
2356 Array<int> owner_procs_vec (numMyElems);
2360 Array<GO> myOwned_vec (numMyElems);
2361 size_t numMyOwnedElems = 0;
2362 for (
size_t i = 0; i < numMyElems; ++i) {
2363 GO GID = myElems[i];
2364 int owner = owner_procs_vec[i];
2366 if (myID == owner) {
2367 myOwned_vec[numMyOwnedElems++] = GID;
2370 myOwned_vec.resize (numMyOwnedElems);
2375 Tpetra::Details::OrdinalTraits<global_size_t>::invalid ();
2376 return rcp (
new map_type (GINV, myOwned_vec (), M->getIndexBase (),
2387 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2389 #define TPETRA_MAP_INSTANT(LO,GO,NODE) \
2391 template class Map< LO , GO , NODE >; \
2393 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2394 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \
2395 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2397 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2398 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2399 const size_t localNumElements, \
2400 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2402 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2403 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \
2404 const Teuchos::RCP<const Teuchos::Comm<int> > &comm); \
2406 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2407 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2408 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2410 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2411 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \
2412 const Teuchos::RCP< const Teuchos::Comm< int > >& comm, \
2413 const Teuchos::RCP< NODE >& node); \
2415 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2416 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2417 const size_t localNumElements, \
2418 const Teuchos::RCP< const Teuchos::Comm< int > >& comm, \
2419 const Teuchos::RCP< NODE > &node); \
2421 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2422 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \
2423 const Teuchos::RCP<const Teuchos::Comm<int> > &comm, \
2424 const Teuchos::RCP<NODE> &node); \
2426 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2427 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2428 const Teuchos::RCP< const Teuchos::Comm< int > >& comm, \
2429 const Teuchos::RCP< NODE > &node); \
2431 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2432 createWeightedContigMapWithNode<LO,GO,NODE> (const int thisNodeWeight, \
2433 const global_size_t numElements, \
2434 const Teuchos::RCP< const Teuchos::Comm< int > >& comm, \
2435 const Teuchos::RCP< NODE >& node); \
2437 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2438 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M); \
2440 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2441 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M, \
2442 const Tpetra::Details::TieBreak<LO,GO>& tie_break); \
2444 #else // !TPETRA_ENABLE_DEPRECATED_CODE
2446 #define TPETRA_MAP_INSTANT(LO,GO,NODE) \
2448 template class Map< LO , GO , NODE >; \
2450 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2451 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \
2452 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2454 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2455 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2456 const size_t localNumElements, \
2457 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2459 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2460 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \
2461 const Teuchos::RCP<const Teuchos::Comm<int> > &comm); \
2463 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2464 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2465 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2467 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2468 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M); \
2470 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2471 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M, \
2472 const Tpetra::Details::TieBreak<LO,GO>& tie_break); \
2474 #endif // TPETRA_ENABLE_DEPRECATED_CODE
2477 #define TPETRA_MAP_INSTANT_DEFAULTNODE(LO,GO) \
2478 template Teuchos::RCP< const Map<LO,GO> > \
2479 createLocalMap<LO,GO>( const size_t, const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2481 template Teuchos::RCP< const Map<LO,GO> > \
2482 createContigMap<LO,GO>( global_size_t, size_t, \
2483 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2485 template Teuchos::RCP< const Map<LO,GO> > \
2486 createNonContigMap(const Teuchos::ArrayView<const GO> &, \
2487 const Teuchos::RCP<const Teuchos::Comm<int> > &); \
2489 template Teuchos::RCP< const Map<LO,GO> > \
2490 createUniformContigMap<LO,GO>( const global_size_t, \
2491 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2493 #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.
bool isLocallyFitted(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is locally fitted to this Map.
virtual ~Map()
Destructor (virtual for memory safety of derived classes).
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
GlobalOrdinal global_ordinal_type
The type of global indices.
Declaration of Tpetra::Details::printOnce.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is owned by this Map on the calling process.
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()).
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with 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...
GlobalOrdinal getIndexBase() const
The index base for this Map.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
Advanced methods.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
bool locallySameAs(const Map< LocalOrdinal, GlobalOrdinal, node_type > &map) const
Is this Map locally the same as the input Map?
bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on the calling process.
"Local" part of Map suitable for Kokkos kernels.
Declaration of Tpetra::Details::initializeKokkos.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
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.
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.
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.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, 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.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
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...
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Return the process ranks and corresponding local indices for the given global indices.
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...
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
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.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a NONOWNING view of the global indices owned by this process.
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...
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
A parallel distribution of indices over processes.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
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.
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.
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.
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_size_t getGlobalNumElements() const
The number of elements in this Map.
std::string description() const
Implementation of Teuchos::Describable.
Map()
Default constructor (that does nothing).