45#ifndef TPETRA_MAP_DEF_HPP
46#define TPETRA_MAP_DEF_HPP
48#include "Tpetra_Directory.hpp"
50#include "Tpetra_Details_FixedHashTable.hpp"
55#include "Teuchos_as.hpp"
56#include "Teuchos_TypeNameTraits.hpp"
57#include "Teuchos_CommHelpers.hpp"
58#include "Tpetra_Details_mpiIsInitialized.hpp"
69 checkMapInputArray (
const char ctorName[],
70 const void* indexList,
71 const size_t indexListSize,
72 const Teuchos::Comm<int>*
const comm)
76 const bool debug = Behavior::debug(
"Map");
78 using Teuchos::outArg;
79 using Teuchos::REDUCE_MIN;
80 using Teuchos::reduceAll;
83 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
84 const bool verbose = Behavior::verbose(
"Map");
85 std::ostringstream lclErrStrm;
88 if (indexListSize != 0 && indexList ==
nullptr) {
91 lclErrStrm <<
"Proc " << myRank <<
": indexList is null, "
92 "but indexListSize=" << indexListSize <<
" != 0." << endl;
96 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
97 if (gblSuccess != 1) {
98 std::ostringstream gblErrStrm;
99 gblErrStrm <<
"Tpetra::Map constructor " << ctorName <<
100 " detected a problem with the input array "
101 "(raw array, Teuchos::ArrayView, or Kokkos::View) "
102 "of global indices." << endl;
107 TEUCHOS_TEST_FOR_EXCEPTION
108 (
true, std::invalid_argument, gblErrStrm.str ());
116 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
119 comm_ (new Teuchos::SerialComm<int> ()),
121 numGlobalElements_ (0),
122 numLocalElements_ (0),
123 minMyGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
124 maxMyGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
125 minAllGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
126 maxAllGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
127 firstContiguousGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
128 lastContiguousGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
131 distributed_ (false),
132 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
138 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
146 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
149 using Teuchos::broadcast;
150 using Teuchos::outArg;
151 using Teuchos::reduceAll;
152 using Teuchos::REDUCE_MIN;
153 using Teuchos::REDUCE_MAX;
154 using Teuchos::typeName;
158 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
159 const char funcName[] =
"Map(gblNumInds,indexBase,comm,LG)";
161 "Tpetra::Map::Map(gblNumInds,indexBase,comm,LG): ";
165 std::unique_ptr<std::string> prefix;
168 comm_.getRawPtr(),
"Map", funcName);
169 std::ostringstream os;
170 os << *prefix <<
"Start" << endl;
171 std::cerr << os.str();
178 GST proc0NumGlobalElements = numGlobalElements;
179 broadcast(*comm_, 0, outArg(proc0NumGlobalElements));
180 GST minNumGlobalElements = numGlobalElements;
181 GST maxNumGlobalElements = numGlobalElements;
182 reduceAll(*comm, REDUCE_MIN, numGlobalElements,
183 outArg(minNumGlobalElements));
184 reduceAll(*comm, REDUCE_MAX, numGlobalElements,
185 outArg(maxNumGlobalElements));
186 TEUCHOS_TEST_FOR_EXCEPTION
187 (minNumGlobalElements != maxNumGlobalElements ||
188 numGlobalElements != minNumGlobalElements,
189 std::invalid_argument, exPfx <<
"All processes must "
190 "provide the same number of global elements. Process 0 set "
191 "numGlobalElements="<< proc0NumGlobalElements <<
". The "
192 "calling process " << comm->getRank() <<
" set "
193 "numGlobalElements=" << numGlobalElements <<
". The min "
194 "and max values over all processes are "
195 << minNumGlobalElements <<
" resp. " << maxNumGlobalElements
198 GO proc0IndexBase = indexBase;
199 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
200 GO minIndexBase = indexBase;
201 GO maxIndexBase = indexBase;
202 reduceAll(*comm, REDUCE_MIN, indexBase, outArg(minIndexBase));
203 reduceAll(*comm, REDUCE_MAX, indexBase, outArg(maxIndexBase));
204 TEUCHOS_TEST_FOR_EXCEPTION
205 (minIndexBase != maxIndexBase || indexBase != minIndexBase,
206 std::invalid_argument, exPfx <<
"All processes must "
207 "provide the same indexBase argument. Process 0 set "
208 "indexBase=" << proc0IndexBase <<
". The calling process "
209 << comm->getRank() <<
" set indexBase=" << indexBase
210 <<
". The min and max values over all processes are "
211 << minIndexBase <<
" resp. " << maxIndexBase <<
".");
231 TEUCHOS_TEST_FOR_EXCEPTION(
232 (numGlobalElements < 1 && numGlobalElements != 0),
233 std::invalid_argument, exPfx <<
"numGlobalElements (= "
234 << numGlobalElements <<
") must be nonnegative.");
236 TEUCHOS_TEST_FOR_EXCEPTION
237 (numGlobalElements == GSTI, std::invalid_argument, exPfx <<
238 "You provided numGlobalElements = Teuchos::OrdinalTraits<"
239 "Tpetra::global_size_t>::invalid(). This version of the "
240 "constructor requires a valid value of numGlobalElements. "
241 "You probably mistook this constructor for the \"contiguous "
242 "nonuniform\" constructor, which can compute the global "
243 "number of elements for you if you set numGlobalElements to "
244 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid().");
246 size_t numLocalElements = 0;
247 if (lOrG == GloballyDistributed) {
262 const GST numProcs =
static_cast<GST
> (comm_->getSize ());
263 const GST myRank =
static_cast<GST
> (comm_->getRank ());
264 const GST quotient = numGlobalElements / numProcs;
265 const GST remainder = numGlobalElements - quotient * numProcs;
268 if (myRank < remainder) {
269 numLocalElements =
static_cast<size_t> (1) +
static_cast<size_t> (quotient);
272 startIndex = as<GO> (myRank) * as<GO> (numLocalElements);
274 numLocalElements = as<size_t> (quotient);
275 startIndex = as<GO> (myRank) * as<GO> (numLocalElements) +
279 minMyGID_ = indexBase + startIndex;
280 maxMyGID_ = indexBase + startIndex + numLocalElements - 1;
281 minAllGID_ = indexBase;
282 maxAllGID_ = indexBase + numGlobalElements - 1;
283 distributed_ = (numProcs > 1);
286 numLocalElements = as<size_t> (numGlobalElements);
287 minMyGID_ = indexBase;
288 maxMyGID_ = indexBase + numGlobalElements - 1;
289 distributed_ =
false;
292 minAllGID_ = indexBase;
293 maxAllGID_ = indexBase + numGlobalElements - 1;
294 indexBase_ = indexBase;
295 numGlobalElements_ = numGlobalElements;
296 numLocalElements_ = numLocalElements;
297 firstContiguousGID_ = minMyGID_;
298 lastContiguousGID_ = maxMyGID_;
305 std::ostringstream os;
306 os << *prefix <<
"Done" << endl;
307 std::cerr << os.str();
312 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
315 const size_t numLocalElements,
317 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) :
320 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
323 using Teuchos::broadcast;
324 using Teuchos::outArg;
325 using Teuchos::reduceAll;
326 using Teuchos::REDUCE_MIN;
327 using Teuchos::REDUCE_MAX;
328 using Teuchos::REDUCE_SUM;
333 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
334 const char funcName[] =
335 "Map(gblNumInds,lclNumInds,indexBase,comm)";
337 "Tpetra::Map::Map(gblNumInds,lclNumInds,indexBase,comm): ";
338 const char suffix[] =
339 ". Please report this bug to the Tpetra developers.";
343 std::unique_ptr<std::string> prefix;
346 comm_.getRawPtr(),
"Map", funcName);
347 std::ostringstream os;
348 os << *prefix <<
"Start" << endl;
349 std::cerr << os.str();
355 GST debugGlobalSum {};
357 debugGlobalSum = initialNonuniformDebugCheck(exPfx,
358 numGlobalElements, numLocalElements, indexBase, comm);
373 scan<int, GO> (*comm, REDUCE_SUM, numLocalElements, outArg (scanResult));
374 const GO myOffset = scanResult - numLocalElements;
376 if (numGlobalElements != GSTI) {
377 numGlobalElements_ = numGlobalElements;
384 const int numProcs = comm->getSize ();
385 GST globalSum = scanResult;
387 broadcast (*comm, numProcs - 1, outArg (globalSum));
389 numGlobalElements_ = globalSum;
393 TEUCHOS_TEST_FOR_EXCEPTION
394 (globalSum != debugGlobalSum, std::logic_error, exPfx <<
395 "globalSum = " << globalSum <<
" != debugGlobalSum = " <<
396 debugGlobalSum << suffix);
399 numLocalElements_ = numLocalElements;
400 indexBase_ = indexBase;
401 minAllGID_ = (numGlobalElements_ == 0) ?
402 std::numeric_limits<GO>::max () :
404 maxAllGID_ = (numGlobalElements_ == 0) ?
405 std::numeric_limits<GO>::lowest () :
406 indexBase + GO(numGlobalElements_) - GO(1);
407 minMyGID_ = (numLocalElements_ == 0) ?
408 std::numeric_limits<GO>::max () :
409 indexBase + GO(myOffset);
410 maxMyGID_ = (numLocalElements_ == 0) ?
411 std::numeric_limits<GO>::lowest () :
412 indexBase + myOffset + GO(numLocalElements) - GO(1);
413 firstContiguousGID_ = minMyGID_;
414 lastContiguousGID_ = maxMyGID_;
416 distributed_ = checkIsDist ();
422 std::ostringstream os;
423 os << *prefix <<
"Done" << endl;
424 std::cerr << os.str();
428 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
432 const char errorMessagePrefix[],
434 const size_t numLocalElements,
436 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
const
443 using Teuchos::broadcast;
444 using Teuchos::outArg;
446 using Teuchos::REDUCE_MAX;
447 using Teuchos::REDUCE_MIN;
448 using Teuchos::REDUCE_SUM;
449 using Teuchos::reduceAll;
450 using GO = global_ordinal_type;
452 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
462 GST debugGlobalSum = 0;
463 reduceAll<int, GST> (*comm, REDUCE_SUM,
static_cast<GST
> (numLocalElements),
464 outArg (debugGlobalSum));
468 GST proc0NumGlobalElements = numGlobalElements;
469 broadcast<int, GST> (*comm_, 0, outArg (proc0NumGlobalElements));
470 GST minNumGlobalElements = numGlobalElements;
471 GST maxNumGlobalElements = numGlobalElements;
472 reduceAll<int, GST> (*comm, REDUCE_MIN, numGlobalElements,
473 outArg (minNumGlobalElements));
474 reduceAll<int, GST> (*comm, REDUCE_MAX, numGlobalElements,
475 outArg (maxNumGlobalElements));
476 TEUCHOS_TEST_FOR_EXCEPTION
477 (minNumGlobalElements != maxNumGlobalElements ||
478 numGlobalElements != minNumGlobalElements,
479 std::invalid_argument, errorMessagePrefix <<
"All processes "
480 "must provide the same number of global elements, even if "
482 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() "
483 "(which signals that the Map should compute the global "
484 "number of elements). Process 0 set numGlobalElements"
485 "=" << proc0NumGlobalElements <<
". The calling process "
486 << comm->getRank() <<
" set numGlobalElements=" <<
487 numGlobalElements <<
". The min and max values over all "
488 "processes are " << minNumGlobalElements <<
" resp. " <<
489 maxNumGlobalElements <<
".");
491 GO proc0IndexBase = indexBase;
492 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
493 GO minIndexBase = indexBase;
494 GO maxIndexBase = indexBase;
495 reduceAll<int, GO> (*comm, REDUCE_MIN, indexBase, outArg (minIndexBase));
496 reduceAll<int, GO> (*comm, REDUCE_MAX, indexBase, outArg (maxIndexBase));
497 TEUCHOS_TEST_FOR_EXCEPTION
498 (minIndexBase != maxIndexBase || indexBase != minIndexBase,
499 std::invalid_argument, errorMessagePrefix <<
500 "All processes must provide the same indexBase argument. "
501 "Process 0 set indexBase = " << proc0IndexBase <<
". The "
502 "calling process " << comm->getRank() <<
" set indexBase="
503 << indexBase <<
". The min and max values over all "
504 "processes are " << minIndexBase <<
" resp. " << maxIndexBase
509 TEUCHOS_TEST_FOR_EXCEPTION
510 (numGlobalElements != GSTI &&
511 debugGlobalSum != numGlobalElements, std::invalid_argument,
512 errorMessagePrefix <<
"The sum of each process' number of "
513 "indices over all processes, " << debugGlobalSum <<
", != "
514 <<
"numGlobalElements=" << numGlobalElements <<
". If you "
515 "would like this constructor to compute numGlobalElements "
516 "for you, you may set numGlobalElements="
517 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() "
518 "on input. Please note that this is NOT necessarily -1.");
520 return debugGlobalSum;
523 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
527 const char errorMessagePrefix[],
532 Kokkos::MemoryUnmanaged>& entryList_host,
534 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
536 using Kokkos::LayoutLeft;
537 using Kokkos::subview;
539 using Kokkos::view_alloc;
540 using Kokkos::WithoutInitializing;
542 using Teuchos::broadcast;
543 using Teuchos::outArg;
545 using Teuchos::REDUCE_MAX;
546 using Teuchos::REDUCE_MIN;
547 using Teuchos::REDUCE_SUM;
548 using Teuchos::reduceAll;
552 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
555 TEUCHOS_TEST_FOR_EXCEPTION
556 (! Kokkos::is_initialized (), std::runtime_error,
557 errorMessagePrefix <<
"The Kokkos execution space "
558 << Teuchos::TypeNameTraits<execution_space>::name()
559 <<
" has not been initialized. "
560 "Please initialize it before creating a Map.")
573 const
size_t numLocalElements(entryList_host.size());
575 initialNonuniformDebugCheck(errorMessagePrefix, numGlobalElements,
576 numLocalElements, indexBase, comm);
586 if (numGlobalElements != GSTI) {
587 numGlobalElements_ = numGlobalElements;
590 reduceAll(*comm, REDUCE_SUM,
591 static_cast<GST
>(numLocalElements),
592 outArg(numGlobalElements_));
618 numLocalElements_ = numLocalElements;
619 indexBase_ = indexBase;
621 minMyGID_ = indexBase_;
622 maxMyGID_ = indexBase_;
632 if (numLocalElements_ > 0) {
636 typename decltype (lgMap_)::non_const_type lgMap
637 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
639 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
647 firstContiguousGID_ = entryList_host[0];
648 lastContiguousGID_ = firstContiguousGID_+1;
656 lgMap_host[0] = firstContiguousGID_;
658 for ( ; i < numLocalElements_; ++i) {
659 const GO curGid = entryList_host[i];
660 const LO curLid = as<LO> (i);
662 if (lastContiguousGID_ != curGid)
break;
668 lgMap_host[curLid] = curGid;
669 ++lastContiguousGID_;
671 --lastContiguousGID_;
676 minMyGID_ = firstContiguousGID_;
677 maxMyGID_ = lastContiguousGID_;
682 const std::pair<size_t, size_t> ncRange (i, entryList_host.extent (0));
683 auto nonContigGids_host = subview (entryList_host, ncRange);
684 TEUCHOS_TEST_FOR_EXCEPTION
685 (
static_cast<size_t> (nonContigGids_host.extent (0)) !=
686 static_cast<size_t> (entryList_host.extent (0) - i),
687 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
688 "nonContigGids_host.extent(0) = "
689 << nonContigGids_host.extent (0)
690 <<
" != entryList_host.extent(0) - i = "
691 << (entryList_host.extent (0) - i) <<
" = "
692 << entryList_host.extent (0) <<
" - " << i
693 <<
". Please report this bug to the Tpetra developers.");
697 View<GO*, LayoutLeft, device_type>
698 nonContigGids (view_alloc (
"nonContigGids", WithoutInitializing),
699 nonContigGids_host.size ());
701 Kokkos::deep_copy (
execution_space(), nonContigGids, nonContigGids_host);
704 glMap_ = global_to_local_table_type(nonContigGids,
707 static_cast<LO
> (i));
709 glMapHost_ = global_to_local_table_host_type(glMap_);
717 for ( ; i < numLocalElements_; ++i) {
718 const GO curGid = entryList_host[i];
719 const LO curLid =
static_cast<LO
> (i);
720 lgMap_host[curLid] = curGid;
724 if (curGid < minMyGID_) {
727 if (curGid > maxMyGID_) {
739 lgMapHost_ = lgMap_host;
742 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
743 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
747 firstContiguousGID_ = indexBase_+1;
748 lastContiguousGID_ = indexBase_;
773 if (std::numeric_limits<GO>::is_signed) {
776 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
779 minMaxInput[0] = -minMyGID_;
780 minMaxInput[1] = maxMyGID_;
781 minMaxInput[2] = localDist;
787 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
788 minAllGID_ = -minMaxOutput[0];
789 maxAllGID_ = minMaxOutput[1];
790 const GO globalDist = minMaxOutput[2];
791 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
795 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
796 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
797 distributed_ = checkIsDist ();
802 TEUCHOS_TEST_FOR_EXCEPTION(
803 minAllGID_ < indexBase_,
804 std::invalid_argument,
805 "Tpetra::Map constructor (noncontiguous): "
806 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
807 "less than the given indexBase = " << indexBase_ <<
".");
813 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
816 const GlobalOrdinal indexList[],
817 const LocalOrdinal indexListSize,
818 const GlobalOrdinal indexBase,
819 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
822 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
825 const char funcName[] =
826 "Map(gblNumInds,indexList,indexListSize,indexBase,comm)";
829 std::unique_ptr<std::string> prefix;
832 comm_.getRawPtr(),
"Map", funcName);
833 std::ostringstream os;
834 os << *prefix <<
"Start" << endl;
835 std::cerr << os.str();
838 checkMapInputArray (
"(GST, const GO[], LO, GO, comm)",
839 indexList,
static_cast<size_t> (indexListSize),
844 const GlobalOrdinal*
const indsRaw = indexListSize == 0 ? NULL : indexList;
845 Kokkos::View<
const GlobalOrdinal*,
848 Kokkos::MemoryUnmanaged> inds (indsRaw, indexListSize);
849 initWithNonownedHostIndexList(funcName, numGlobalElements, inds,
852 std::ostringstream os;
853 os << *prefix <<
"Done" << endl;
854 std::cerr << os.str();
858 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
861 const Teuchos::ArrayView<const GlobalOrdinal>& entryList,
862 const GlobalOrdinal indexBase,
863 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
866 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
869 const char funcName[] =
870 "Map(gblNumInds,entryList(Teuchos::ArrayView),indexBase,comm)";
873 std::unique_ptr<std::string> prefix;
876 comm_.getRawPtr(),
"Map", funcName);
877 std::ostringstream os;
878 os << *prefix <<
"Start" << endl;
879 std::cerr << os.str();
882 const size_t numLclInds =
static_cast<size_t> (entryList.size ());
883 checkMapInputArray (
"(GST, ArrayView, GO, comm)",
884 entryList.getRawPtr (), numLclInds,
889 const GlobalOrdinal*
const indsRaw =
890 numLclInds == 0 ? NULL : entryList.getRawPtr ();
891 Kokkos::View<
const GlobalOrdinal*,
894 Kokkos::MemoryUnmanaged> inds (indsRaw, numLclInds);
895 initWithNonownedHostIndexList(funcName, numGlobalElements, inds,
898 std::ostringstream os;
899 os << *prefix <<
"Done" << endl;
900 std::cerr << os.str();
904 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
907 const Kokkos::View<const GlobalOrdinal*, device_type>& entryList,
908 const GlobalOrdinal indexBase,
909 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
912 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
914 using Kokkos::LayoutLeft;
915 using Kokkos::subview;
917 using Kokkos::view_alloc;
918 using Kokkos::WithoutInitializing;
920 using Teuchos::ArrayView;
922 using Teuchos::broadcast;
923 using Teuchos::outArg;
925 using Teuchos::REDUCE_MAX;
926 using Teuchos::REDUCE_MIN;
927 using Teuchos::REDUCE_SUM;
928 using Teuchos::reduceAll;
929 using Teuchos::typeName;
934 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
935 const char funcName[] =
936 "Map(gblNumInds,entryList(Kokkos::View),indexBase,comm)";
939 std::unique_ptr<std::string> prefix;
942 comm_.getRawPtr(),
"Map", funcName);
943 std::ostringstream os;
944 os << *prefix <<
"Start" << endl;
945 std::cerr << os.str();
948 checkMapInputArray (
"(GST, Kokkos::View, GO, comm)",
950 static_cast<size_t> (entryList.extent (0)),
964 const size_t numLocalElements(entryList.size());
966 initialNonuniformDebugCheck(funcName, numGlobalElements,
967 numLocalElements, indexBase, comm);
977 if (numGlobalElements != GSTI) {
978 numGlobalElements_ = numGlobalElements;
981 reduceAll(*comm, REDUCE_SUM,
982 static_cast<GST
>(numLocalElements),
983 outArg(numGlobalElements_));
1009 numLocalElements_ = numLocalElements;
1010 indexBase_ = indexBase;
1012 minMyGID_ = indexBase_;
1013 maxMyGID_ = indexBase_;
1023 if (numLocalElements_ > 0) {
1027 typename decltype (lgMap_)::non_const_type lgMap
1028 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
1030 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
1032 using array_layout =
1033 typename View<const GO*, device_type>::array_layout;
1034 View<GO*, array_layout, Kokkos::HostSpace> entryList_host
1035 (view_alloc (
"entryList_host", WithoutInitializing),
1036 entryList.extent(0));
1040 firstContiguousGID_ = entryList_host[0];
1041 lastContiguousGID_ = firstContiguousGID_+1;
1049 lgMap_host[0] = firstContiguousGID_;
1051 for ( ; i < numLocalElements_; ++i) {
1052 const GO curGid = entryList_host[i];
1053 const LO curLid = as<LO> (i);
1055 if (lastContiguousGID_ != curGid)
break;
1061 lgMap_host[curLid] = curGid;
1062 ++lastContiguousGID_;
1064 --lastContiguousGID_;
1069 minMyGID_ = firstContiguousGID_;
1070 maxMyGID_ = lastContiguousGID_;
1075 const std::pair<size_t, size_t> ncRange (i, entryList.extent (0));
1076 auto nonContigGids = subview (entryList, ncRange);
1077 TEUCHOS_TEST_FOR_EXCEPTION
1078 (
static_cast<size_t> (nonContigGids.extent (0)) !=
1079 static_cast<size_t> (entryList.extent (0) - i),
1080 std::logic_error,
"Tpetra::Map noncontiguous constructor: "
1081 "nonContigGids.extent(0) = "
1082 << nonContigGids.extent (0)
1083 <<
" != entryList.extent(0) - i = "
1084 << (entryList.extent (0) - i) <<
" = "
1085 << entryList.extent (0) <<
" - " << i
1086 <<
". Please report this bug to the Tpetra developers.");
1088 glMap_ = global_to_local_table_type(nonContigGids,
1089 firstContiguousGID_,
1091 static_cast<LO
> (i));
1093 glMapHost_ = global_to_local_table_host_type(glMap_);
1101 for ( ; i < numLocalElements_; ++i) {
1102 const GO curGid = entryList_host[i];
1103 const LO curLid =
static_cast<LO
> (i);
1104 lgMap_host[curLid] = curGid;
1108 if (curGid < minMyGID_) {
1111 if (curGid > maxMyGID_) {
1123 lgMapHost_ = lgMap_host;
1126 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
1127 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
1131 firstContiguousGID_ = indexBase_+1;
1132 lastContiguousGID_ = indexBase_;
1157 if (std::numeric_limits<GO>::is_signed) {
1159 const GO localDist =
1160 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
1163 minMaxInput[0] = -minMyGID_;
1164 minMaxInput[1] = maxMyGID_;
1165 minMaxInput[2] = localDist;
1168 minMaxOutput[0] = 0;
1169 minMaxOutput[1] = 0;
1170 minMaxOutput[2] = 0;
1171 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
1172 minAllGID_ = -minMaxOutput[0];
1173 maxAllGID_ = minMaxOutput[1];
1174 const GO globalDist = minMaxOutput[2];
1175 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
1179 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
1180 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
1181 distributed_ = checkIsDist ();
1184 contiguous_ =
false;
1186 TEUCHOS_TEST_FOR_EXCEPTION(
1187 minAllGID_ < indexBase_,
1188 std::invalid_argument,
1189 "Tpetra::Map constructor (noncontiguous): "
1190 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is "
1191 "less than the given indexBase = " << indexBase_ <<
".");
1197 std::ostringstream os;
1198 os << *prefix <<
"Done" << endl;
1199 std::cerr << os.str();
1204 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1207 if (! Kokkos::is_initialized ()) {
1208 std::ostringstream os;
1209 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1210 "Kokkos::finalize() has been called. This is user error! There are "
1211 "two likely causes: " << std::endl <<
1212 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1214 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1215 "of a Tpetra::Map) at the same scope in main() as Kokkos::finalize() "
1216 "or Tpetra::finalize()." << std::endl << std::endl <<
1217 "Don't do either of these! Please refer to GitHib Issue #2372."
1220 this->getComm ().getRawPtr ());
1227 Teuchos::RCP<const Teuchos::Comm<int> > comm = this->
getComm ();
1228 if (! comm.is_null () && teuchosCommIsAnMpiComm (*comm) &&
1229 mpiIsInitialized () && mpiIsFinalized ()) {
1235 std::ostringstream os;
1236 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after "
1237 "MPI_Finalize() has been called. This is user error! There are "
1238 "two likely causes: " << std::endl <<
1239 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)"
1241 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr "
1242 "of a Tpetra::Map) at the same scope in main() as MPI_finalize() or "
1243 "Tpetra::finalize()." << std::endl << std::endl <<
1244 "Don't do either of these! Please refer to GitHib Issue #2372."
1254 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1258 TEUCHOS_TEST_FOR_EXCEPTION(
1259 getComm ().is_null (), std::logic_error,
"Tpetra::Map::isOneToOne: "
1260 "getComm() returns null. Please report this bug to the Tpetra "
1265 return directory_->isOneToOne (*
this);
1268 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1276 return Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1280 else if (globalIndex >= firstContiguousGID_ &&
1281 globalIndex <= lastContiguousGID_) {
1282 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGID_);
1288 return glMapHost_.get (globalIndex);
1292 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1298 return Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
1308 return lgMapHost_[localIndex];
1312 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1324 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1329 Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1332 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1337 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1343 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1350 firstContiguousGID_, lastContiguousGID_,
1354 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1359 using Teuchos::outArg;
1360 using Teuchos::REDUCE_MIN;
1361 using Teuchos::reduceAll;
1390 lgMap_.extent (0) != 0 && map.lgMap_.extent (0) != 0 &&
1391 lgMap_.data () == map.lgMap_.data ()) {
1405 TEUCHOS_TEST_FOR_EXCEPTION(
1407 "Tpetra::Map::isCompatible: There's a bug in this method. We've already "
1408 "checked that this condition is true above, but it's false here. "
1409 "Please report this bug to the Tpetra developers.");
1412 const int locallyCompat =
1415 int globallyCompat = 0;
1416 reduceAll<int, int> (*comm_, REDUCE_MIN, locallyCompat, outArg (globallyCompat));
1417 return (globallyCompat == 1);
1420 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1425 using Teuchos::ArrayView;
1427 using size_type =
typename ArrayView<const GO>::size_type;
1455 TEUCHOS_TEST_FOR_EXCEPTION(
1457 "Tpetra::Map::locallySameAs: BUG");
1460 const size_type numRhsElts = rhsElts.size ();
1461 for (size_type k = 0; k < numRhsElts; ++k) {
1462 const GO curLhsGid = minLhsGid +
static_cast<GO
> (k);
1463 if (curLhsGid != rhsElts[k]) {
1471 TEUCHOS_TEST_FOR_EXCEPTION(
1473 "Tpetra::Map::locallySameAs: BUG");
1476 const size_type numLhsElts = lhsElts.size ();
1477 for (size_type k = 0; k < numLhsElts; ++k) {
1478 const GO curRhsGid = minRhsGid +
static_cast<GO
> (k);
1479 if (curRhsGid != lhsElts[k]) {
1485 else if (this->lgMap_.data () == map.lgMap_.data ()) {
1501 return std::equal (lhsElts.begin (), lhsElts.end (), rhsElts.begin ());
1507 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1522 auto numLocalElements1 = lmap1.getLocalNumElements();
1523 auto numLocalElements2 = lmap2.getLocalNumElements();
1525 if (numLocalElements1 > numLocalElements2) {
1530 if (lmap1.isContiguous () && lmap2.isContiguous ()) {
1532 return ((lmap1.getMinGlobalIndex () == lmap2.getMinGlobalIndex ()) &&
1533 (lmap1.getMaxGlobalIndex () <= lmap2.getMaxGlobalIndex ()));
1536 if (lmap1.getMinGlobalIndex () < lmap2.getMinGlobalIndex () ||
1537 lmap1.getMaxGlobalIndex () > lmap2.getMaxGlobalIndex ()) {
1545 Kokkos::RangePolicy<LO, typename node_type::execution_space>;
1549 Kokkos::parallel_reduce(
1551 range_type(0, numLocalElements1),
1552 KOKKOS_LAMBDA (
const LO i, LO& diff) {
1553 diff += (lmap1.getGlobalElement(i) != lmap2.getGlobalElement(i));
1556 return (numDiff == 0);
1559 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1564 using Teuchos::outArg;
1565 using Teuchos::REDUCE_MIN;
1566 using Teuchos::reduceAll;
1624 reduceAll<int, int> (*comm_, REDUCE_MIN, isSame_lcl, outArg (isSame_gbl));
1625 return isSame_gbl == 1;
1629 template <
class LO,
class GO,
class DT>
1632 FillLgMap (
const Kokkos::View<GO*, DT>& lgMap,
1633 const GO startGid) :
1634 lgMap_ (lgMap), startGid_ (startGid)
1636 Kokkos::RangePolicy<LO, typename DT::execution_space>
1637 range (
static_cast<LO
> (0),
static_cast<LO
> (lgMap.size ()));
1638 Kokkos::parallel_for (range, *
this);
1641 KOKKOS_INLINE_FUNCTION
void operator () (
const LO& lid)
const {
1642 lgMap_(lid) = startGid_ +
static_cast<GO
> (lid);
1646 const Kokkos::View<GO*, DT> lgMap_;
1653 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1654 typename Map<LocalOrdinal,GlobalOrdinal,Node>::global_indices_array_type
1660 using const_lg_view_type =
decltype(lgMap_);
1661 using lg_view_type =
typename const_lg_view_type::non_const_type;
1665 std::unique_ptr<std::string> prefix;
1668 comm_.getRawPtr(),
"Map",
"getMyGlobalIndices");
1669 std::ostringstream os;
1670 os << *prefix <<
"Start" << endl;
1671 std::cerr << os.str();
1677 const bool needToCreateLocalToGlobalMapping =
1678 lgMap_.extent (0) == 0 && numLocalElements_ > 0;
1680 if (needToCreateLocalToGlobalMapping) {
1682 std::ostringstream os;
1683 os << *prefix <<
"Need to create lgMap" << endl;
1684 std::cerr << os.str();
1689 TEUCHOS_TEST_FOR_EXCEPTION
1691 "Tpetra::Map::getMyGlobalIndices: The local-to-global "
1692 "mapping (lgMap_) should have been set up already for a "
1693 "noncontiguous Map. Please report this bug to the Tpetra "
1698 using Kokkos::view_alloc;
1699 using Kokkos::WithoutInitializing;
1700 lg_view_type lgMap (
"lgMap", numElts);
1702 std::ostringstream os;
1703 os << *prefix <<
"Fill lgMap" << endl;
1704 std::cerr << os.str();
1706 FillLgMap<LO, GO, no_uvm_device_type> fillIt (lgMap, minMyGID_);
1709 std::ostringstream os;
1710 os << *prefix <<
"Copy lgMap to lgMapHost" << endl;
1711 std::cerr << os.str();
1715 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
1718 Kokkos::deep_copy (exec_instance, lgMapHost, lgMap);
1722 exec_instance.fence();
1726 lgMapHost_ = lgMapHost;
1730 std::ostringstream os;
1731 os << *prefix <<
"Done" << endl;
1732 std::cerr << os.str();
1737 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1738 Teuchos::ArrayView<const GlobalOrdinal>
1749 const GO* lgMapHostRawPtr = lgMapHost_.data ();
1753 return Teuchos::ArrayView<const GO>(
1755 lgMapHost_.extent (0),
1756 Teuchos::RCP_DISABLE_NODE_LOOKUP);
1759 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1761 return distributed_;
1764 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1766 using Teuchos::TypeNameTraits;
1767 std::ostringstream os;
1769 os <<
"Tpetra::Map: {"
1770 <<
"LocalOrdinalType: " << TypeNameTraits<LocalOrdinal>::name ()
1771 <<
", GlobalOrdinalType: " << TypeNameTraits<GlobalOrdinal>::name ()
1772 <<
", NodeType: " << TypeNameTraits<Node>::name ();
1773 if (this->getObjectLabel () !=
"") {
1774 os <<
", Label: \"" << this->getObjectLabel () <<
"\"";
1777 <<
", Number of processes: " <<
getComm ()->getSize ()
1778 <<
", Uniform: " << (
isUniform () ?
"true" :
"false")
1779 <<
", Contiguous: " << (
isContiguous () ?
"true" :
"false")
1780 <<
", Distributed: " << (
isDistributed () ?
"true" :
"false")
1789 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1798 if (vl < Teuchos::VERB_HIGH) {
1799 return std::string ();
1801 auto outStringP = Teuchos::rcp (
new std::ostringstream ());
1802 Teuchos::RCP<Teuchos::FancyOStream> outp =
1803 Teuchos::getFancyOStream (outStringP);
1804 Teuchos::FancyOStream& out = *outp;
1806 auto comm = this->getComm ();
1807 const int myRank = comm->getRank ();
1808 const int numProcs = comm->getSize ();
1809 out <<
"Process " << myRank <<
" of " << numProcs <<
":" << endl;
1810 Teuchos::OSTab tab1 (out);
1812 const LO numEnt =
static_cast<LO
> (this->getLocalNumElements ());
1813 out <<
"My number of entries: " << numEnt << endl
1814 <<
"My minimum global index: " << this->getMinGlobalIndex () << endl
1815 <<
"My maximum global index: " << this->getMaxGlobalIndex () << endl;
1817 if (vl == Teuchos::VERB_EXTREME) {
1818 out <<
"My global indices: [";
1819 const LO minLclInd = this->getMinLocalIndex ();
1820 for (LO k = 0; k < numEnt; ++k) {
1821 out << minLclInd + this->getGlobalElement (k);
1822 if (k + 1 < numEnt) {
1830 return outStringP->str ();
1833 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1836 describe (Teuchos::FancyOStream &out,
1837 const Teuchos::EVerbosityLevel verbLevel)
const
1839 using Teuchos::TypeNameTraits;
1840 using Teuchos::VERB_DEFAULT;
1841 using Teuchos::VERB_NONE;
1842 using Teuchos::VERB_LOW;
1843 using Teuchos::VERB_HIGH;
1847 const Teuchos::EVerbosityLevel vl =
1848 (verbLevel == VERB_DEFAULT) ? VERB_LOW : verbLevel;
1850 if (vl == VERB_NONE) {
1858 if (comm.is_null ()) {
1861 const int myRank = comm->getRank ();
1862 const int numProcs = comm->getSize ();
1871 Teuchos::RCP<Teuchos::OSTab> tab0, tab1;
1877 tab0 = Teuchos::rcp (
new Teuchos::OSTab (out));
1878 out <<
"\"Tpetra::Map\":" << endl;
1879 tab1 = Teuchos::rcp (
new Teuchos::OSTab (out));
1881 out <<
"Template parameters:" << endl;
1882 Teuchos::OSTab tab2 (out);
1883 out <<
"LocalOrdinal: " << TypeNameTraits<LO>::name () << endl
1884 <<
"GlobalOrdinal: " << TypeNameTraits<GO>::name () << endl
1885 <<
"Node: " << TypeNameTraits<Node>::name () << endl;
1887 const std::string label = this->getObjectLabel ();
1889 out <<
"Label: \"" << label <<
"\"" << endl;
1895 <<
"Number of processes: " << numProcs << endl
1896 <<
"Uniform: " << (
isUniform () ?
"true" :
"false") << endl
1897 <<
"Contiguous: " << (
isContiguous () ?
"true" :
"false") << endl
1898 <<
"Distributed: " << (
isDistributed () ?
"true" :
"false") << endl;
1902 if (vl >= VERB_HIGH) {
1903 const std::string lclStr = this->localDescribeToString (vl);
1908 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1909 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1927 if (newComm.is_null () || newComm->getSize () < 1) {
1928 return Teuchos::null;
1930 else if (newComm->getSize () == 1) {
1935 RCP<map_type> newMap (
new map_type ());
1937 newMap->comm_ = newComm;
1941 newMap->indexBase_ = this->indexBase_;
1942 newMap->numGlobalElements_ = this->numLocalElements_;
1943 newMap->numLocalElements_ = this->numLocalElements_;
1944 newMap->minMyGID_ = this->minMyGID_;
1945 newMap->maxMyGID_ = this->maxMyGID_;
1946 newMap->minAllGID_ = this->minMyGID_;
1947 newMap->maxAllGID_ = this->maxMyGID_;
1948 newMap->firstContiguousGID_ = this->firstContiguousGID_;
1949 newMap->lastContiguousGID_ = this->lastContiguousGID_;
1952 newMap->uniform_ = this->uniform_;
1953 newMap->contiguous_ = this->contiguous_;
1956 newMap->distributed_ =
false;
1957 newMap->lgMap_ = this->lgMap_;
1958 newMap->lgMapHost_ = this->lgMapHost_;
1959 newMap->glMap_ = this->glMap_;
1960 newMap->glMapHost_ = this->glMapHost_;
1981 const GST RECOMPUTE = Tpetra::Details::OrdinalTraits<GST>::invalid ();
1999 typename std::decay<
decltype (lgMap.extent (0)) >::type;
2000 const size_type lclNumInds =
2002 using Teuchos::TypeNameTraits;
2003 TEUCHOS_TEST_FOR_EXCEPTION
2004 (lgMap.extent (0) != lclNumInds, std::logic_error,
2005 "Tpetra::Map::replaceCommWithSubset: Result of getMyGlobalIndices() "
2006 "has length " << lgMap.extent (0) <<
" (of type " <<
2007 TypeNameTraits<size_type>::name () <<
") != this->getLocalNumElements()"
2008 " = " << this->getLocalNumElements () <<
". The latter, upon being "
2009 "cast to size_type = " << TypeNameTraits<size_type>::name () <<
", "
2010 "becomes " << lclNumInds <<
". Please report this bug to the Tpetra "
2018 auto lgMap_device = Kokkos::create_mirror_view_and_copy(
device_type(), lgMap);
2019 return rcp (
new map_type (RECOMPUTE, lgMap_device, indexBase, newComm));
2023 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2024 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
2028 using Teuchos::Comm;
2029 using Teuchos::null;
2030 using Teuchos::outArg;
2033 using Teuchos::REDUCE_MIN;
2034 using Teuchos::reduceAll;
2041 const int color = (numLocalElements_ == 0) ? 0 : 1;
2046 RCP<const Comm<int> > newComm = comm_->split (color, 0);
2052 if (newComm.is_null ()) {
2055 RCP<Map> map = rcp (
new Map ());
2057 map->comm_ = newComm;
2058 map->indexBase_ = indexBase_;
2059 map->numGlobalElements_ = numGlobalElements_;
2060 map->numLocalElements_ = numLocalElements_;
2061 map->minMyGID_ = minMyGID_;
2062 map->maxMyGID_ = maxMyGID_;
2063 map->minAllGID_ = minAllGID_;
2064 map->maxAllGID_ = maxAllGID_;
2065 map->firstContiguousGID_= firstContiguousGID_;
2066 map->lastContiguousGID_ = lastContiguousGID_;
2070 map->uniform_ = uniform_;
2071 map->contiguous_ = contiguous_;
2086 if (! distributed_ || newComm->getSize () == 1) {
2087 map->distributed_ =
false;
2089 const int iOwnAllGids = (numLocalElements_ == numGlobalElements_) ? 1 : 0;
2090 int allProcsOwnAllGids = 0;
2091 reduceAll<int, int> (*newComm, REDUCE_MIN, iOwnAllGids, outArg (allProcsOwnAllGids));
2092 map->distributed_ = (allProcsOwnAllGids == 1) ?
false :
true;
2095 map->lgMap_ = lgMap_;
2096 map->lgMapHost_ = lgMapHost_;
2097 map->glMap_ = glMap_;
2098 map->glMapHost_ = glMapHost_;
2115 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2117 Map<LocalOrdinal,GlobalOrdinal,Node>::setupDirectory ()
const
2119 TEUCHOS_TEST_FOR_EXCEPTION(
2120 directory_.is_null (), std::logic_error,
"Tpetra::Map::setupDirectory: "
2121 "The Directory is null. "
2122 "Please report this bug to the Tpetra developers.");
2126 if (! directory_->initialized ()) {
2127 directory_->initialize (*
this);
2131 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2135 const Teuchos::ArrayView<int>& PIDs,
2136 const Teuchos::ArrayView<LocalOrdinal>& LIDs)
const
2138 using Tpetra::Details::OrdinalTraits;
2141 using size_type = Teuchos::ArrayView<int>::size_type;
2144 const size_t maxNumToPrint = verbose ?
2146 std::unique_ptr<std::string> prefix;
2149 "Map",
"getRemoteIndexList(GIDs,PIDs,LIDs)");
2150 std::ostringstream os;
2151 os << *prefix <<
"Start: ";
2152 verbosePrintArray(os, GIDs,
"GIDs", maxNumToPrint);
2154 std::cerr << os.str();
2164 if (GIDs.size () == 0) {
2166 std::ostringstream os;
2167 os << *prefix <<
"Done; both Map & input are empty" << endl;
2168 std::cerr << os.str();
2174 std::ostringstream os;
2175 os << *prefix <<
"Done: Map is empty on all processes, "
2176 "so all output PIDs & LIDs are invalid (-1)." << endl;
2177 std::cerr << os.str();
2179 for (size_type k = 0; k < PIDs.size (); ++k) {
2180 PIDs[k] = OrdinalTraits<int>::invalid ();
2182 for (size_type k = 0; k < LIDs.size (); ++k) {
2183 LIDs[k] = OrdinalTraits<LocalOrdinal>::invalid ();
2194 std::ostringstream os;
2195 os << *prefix <<
"Call setupDirectory" << endl;
2196 std::cerr << os.str();
2200 std::ostringstream os;
2201 os << *prefix <<
"Call directory_->getDirectoryEntries" << endl;
2202 std::cerr << os.str();
2205 directory_->getDirectoryEntries (*
this, GIDs, PIDs, LIDs);
2207 std::ostringstream os;
2208 os << *prefix <<
"Done; getDirectoryEntries returned "
2209 << (retVal ==
IDNotPresent ?
"IDNotPresent" :
"AllIDsPresent")
2211 verbosePrintArray(os, PIDs,
"PIDs", maxNumToPrint);
2213 verbosePrintArray(os, LIDs,
"LIDs", maxNumToPrint);
2215 std::cerr << os.str();
2220 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2224 const Teuchos::ArrayView<int> & PIDs)
const
2230 const size_t maxNumToPrint = verbose ?
2232 std::unique_ptr<std::string> prefix;
2235 "Map",
"getRemoteIndexList(GIDs,PIDs)");
2236 std::ostringstream os;
2237 os << *prefix <<
"Start: ";
2238 verbosePrintArray(os, GIDs,
"GIDs", maxNumToPrint);
2240 std::cerr << os.str();
2244 if (GIDs.size () == 0) {
2246 std::ostringstream os;
2247 os << *prefix <<
"Done; both Map & input are empty" << endl;
2248 std::cerr << os.str();
2254 std::ostringstream os;
2255 os << *prefix <<
"Done: Map is empty on all processes, "
2256 "so all output PIDs are invalid (-1)." << endl;
2257 std::cerr << os.str();
2259 for (Teuchos::ArrayView<int>::size_type k = 0; k < PIDs.size (); ++k) {
2260 PIDs[k] = Tpetra::Details::OrdinalTraits<int>::invalid ();
2271 std::ostringstream os;
2272 os << *prefix <<
"Call setupDirectory" << endl;
2273 std::cerr << os.str();
2277 std::ostringstream os;
2278 os << *prefix <<
"Call directory_->getDirectoryEntries" << endl;
2279 std::cerr << os.str();
2282 directory_->getDirectoryEntries(*
this, GIDs, PIDs);
2284 std::ostringstream os;
2285 os << *prefix <<
"Done; getDirectoryEntries returned "
2286 << (retVal ==
IDNotPresent ?
"IDNotPresent" :
"AllIDsPresent")
2288 verbosePrintArray(os, PIDs,
"PIDs", maxNumToPrint);
2290 std::cerr << os.str();
2295 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2296 Teuchos::RCP<const Teuchos::Comm<int> >
2301 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2307 using Teuchos::outArg;
2308 using Teuchos::REDUCE_MIN;
2309 using Teuchos::reduceAll;
2313 std::unique_ptr<std::string> prefix;
2316 comm_.getRawPtr(),
"Map",
"checkIsDist");
2317 std::ostringstream os;
2318 os << *prefix <<
"Start" << endl;
2319 std::cerr << os.str();
2322 bool global =
false;
2323 if (comm_->getSize () > 1) {
2327 if (numGlobalElements_ == as<global_size_t> (numLocalElements_)) {
2340 reduceAll<int, int> (*comm_, REDUCE_MIN, localRep, outArg (allLocalRep));
2341 if (allLocalRep != 1) {
2351 std::ostringstream os;
2352 os << *prefix <<
"Done; global=" << (global ?
"true" :
"false")
2354 std::cerr << os.str();
2361template <
class LocalOrdinal,
class GlobalOrdinal>
2362Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2364 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2366 typedef LocalOrdinal LO;
2367 typedef GlobalOrdinal GO;
2368 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2369 return createLocalMapWithNode<LO, GO, NT> (numElements, comm);
2372template <
class LocalOrdinal,
class GlobalOrdinal>
2373Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2375 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2377 typedef LocalOrdinal LO;
2378 typedef GlobalOrdinal GO;
2379 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2380 return createUniformContigMapWithNode<LO, GO, NT> (numElements, comm);
2383template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2384Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2386 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2391 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2393 return rcp (
new map_type (numElements, indexBase, comm, GloballyDistributed));
2396template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2397Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2399 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2405 const GlobalOrdinal indexBase = 0;
2408 return rcp (
new map_type (globalNumElts, indexBase, comm, LocallyReplicated));
2411template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2412Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2414 const size_t localNumElements,
2415 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2420 const GlobalOrdinal indexBase = 0;
2422 return rcp (
new map_type (numElements, localNumElements, indexBase, comm));
2425template <
class LocalOrdinal,
class GlobalOrdinal>
2426Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2428 const size_t localNumElements,
2429 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2431 typedef LocalOrdinal LO;
2432 typedef GlobalOrdinal GO;
2438template <
class LocalOrdinal,
class GlobalOrdinal>
2439Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2441 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2443 typedef LocalOrdinal LO;
2444 typedef GlobalOrdinal GO;
2450template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2451Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2453 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2459 const GST INV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2463 const GlobalOrdinal indexBase = 0;
2465 return rcp (
new map_type (INV, elementList, indexBase, comm));
2468template<
class LO,
class GO,
class NT>
2469Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >
2472 using Details::verbosePrintArray;
2473 using Teuchos::Array;
2474 using Teuchos::ArrayView;
2482 const bool verbose = Details::Behavior::verbose(
"Map");
2483 std::unique_ptr<std::string> prefix;
2485 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2486 prefix = Details::createPrefix(
2487 comm.getRawPtr(),
"createOneToOne(Map)");
2488 std::ostringstream os;
2489 os << *prefix <<
"Start" << endl;
2492 const size_t maxNumToPrint = verbose ?
2493 Details::Behavior::verbosePrintCountThreshold() : size_t(0);
2494 const GST GINV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2495 const int myRank = M->getComm ()->getRank ();
2501 if (! M->isDistributed ()) {
2508 const GST numGlobalEntries = M->getGlobalNumElements ();
2509 if (M->isContiguous()) {
2510 const size_t numLocalEntries =
2511 (myRank == 0) ? as<size_t>(numGlobalEntries) : size_t(0);
2513 std::ostringstream os;
2514 os << *prefix <<
"Input is locally replicated & contiguous; "
2515 "numLocalEntries=" << numLocalEntries << endl;
2519 rcp(
new map_type(numGlobalEntries, numLocalEntries,
2520 M->getIndexBase(), M->getComm()));
2522 std::ostringstream os;
2523 os << *prefix <<
"Done" << endl;
2530 std::ostringstream os;
2531 os << *prefix <<
"Input is locally replicated & noncontiguous"
2535 ArrayView<const GO> myGids =
2536 (myRank == 0) ? M->getLocalElementList() : Teuchos::null;
2538 rcp(
new map_type(GINV, myGids(), M->getIndexBase(),
2541 std::ostringstream os;
2542 os << *prefix <<
"Done" << endl;
2548 else if (M->isContiguous ()) {
2550 std::ostringstream os;
2551 os << *prefix <<
"Input is distributed & contiguous" << endl;
2560 std::ostringstream os;
2561 os << *prefix <<
"Input is distributed & noncontiguous" << endl;
2565 const size_t numMyElems = M->getLocalNumElements ();
2566 ArrayView<const GO> myElems = M->getLocalElementList ();
2567 Array<int> owner_procs_vec (numMyElems);
2570 std::ostringstream os;
2571 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2578 std::ostringstream os;
2579 os << *prefix <<
"getDirectoryEntries result: ";
2585 Array<GO> myOwned_vec (numMyElems);
2586 size_t numMyOwnedElems = 0;
2587 for (
size_t i = 0; i < numMyElems; ++i) {
2588 const GO GID = myElems[i];
2589 const int owner = owner_procs_vec[i];
2591 if (myRank == owner) {
2592 myOwned_vec[numMyOwnedElems++] = GID;
2595 myOwned_vec.resize (numMyOwnedElems);
2598 std::ostringstream os;
2599 os << *prefix <<
"Create Map: ";
2604 auto retMap = rcp(
new map_type(GINV, myOwned_vec(),
2605 M->getIndexBase(), M->getComm()));
2607 std::ostringstream os;
2608 os << *prefix <<
"Done" << endl;
2615template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2616Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2620 using Details::Behavior;
2621 using Details::verbosePrintArray;
2622 using Teuchos::Array;
2623 using Teuchos::ArrayView;
2626 using Teuchos::toString;
2629 using LO = LocalOrdinal;
2630 using GO = GlobalOrdinal;
2633 const bool verbose = Behavior::verbose(
"Map");
2634 std::unique_ptr<std::string> prefix;
2636 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2637 prefix = Details::createPrefix(
2638 comm.getRawPtr(),
"createOneToOne(Map,TieBreak)");
2639 std::ostringstream os;
2640 os << *prefix <<
"Start" << endl;
2643 const size_t maxNumToPrint = verbose ?
2644 Behavior::verbosePrintCountThreshold() : size_t(0);
2651 std::ostringstream os;
2652 os << *prefix <<
"Initialize Directory" << endl;
2657 std::ostringstream os;
2658 os << *prefix <<
"Done initializing Directory" << endl;
2661 size_t numMyElems = M->getLocalNumElements ();
2662 ArrayView<const GO> myElems = M->getLocalElementList ();
2663 Array<int> owner_procs_vec (numMyElems);
2665 std::ostringstream os;
2666 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2673 std::ostringstream os;
2674 os << *prefix <<
"getDirectoryEntries result: ";
2680 const int myRank = M->getComm()->getRank();
2681 Array<GO> myOwned_vec (numMyElems);
2682 size_t numMyOwnedElems = 0;
2683 for (
size_t i = 0; i < numMyElems; ++i) {
2684 const GO GID = myElems[i];
2685 const int owner = owner_procs_vec[i];
2686 if (myRank == owner) {
2687 myOwned_vec[numMyOwnedElems++] = GID;
2690 myOwned_vec.resize (numMyOwnedElems);
2695 Tpetra::Details::OrdinalTraits<global_size_t>::invalid ();
2697 std::ostringstream os;
2698 os << *prefix <<
"Create Map: ";
2703 RCP<const map_type> retMap
2704 (
new map_type (GINV, myOwned_vec (), M->getIndexBase (),
2707 std::ostringstream os;
2708 os << *prefix <<
"Done" << endl;
2722#define TPETRA_MAP_INSTANT(LO,GO,NODE) \
2724 template class Map< LO , GO , NODE >; \
2726 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2727 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \
2728 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2730 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2731 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2732 const size_t localNumElements, \
2733 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2735 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2736 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \
2737 const Teuchos::RCP<const Teuchos::Comm<int> > &comm); \
2739 template Teuchos::RCP< const Map<LO,GO,NODE> > \
2740 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \
2741 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \
2743 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2744 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M); \
2746 template Teuchos::RCP<const Map<LO,GO,NODE> > \
2747 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M, \
2748 const Tpetra::Details::TieBreak<LO,GO>& tie_break); \
2752#define TPETRA_MAP_INSTANT_DEFAULTNODE(LO,GO) \
2753 template Teuchos::RCP< const Map<LO,GO> > \
2754 createLocalMap<LO,GO>( const size_t, const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2756 template Teuchos::RCP< const Map<LO,GO> > \
2757 createContigMap<LO,GO>( global_size_t, size_t, \
2758 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
2760 template Teuchos::RCP< const Map<LO,GO> > \
2761 createNonContigMap(const Teuchos::ArrayView<const GO> &, \
2762 const Teuchos::RCP<const Teuchos::Comm<int> > &); \
2764 template Teuchos::RCP< const Map<LO,GO> > \
2765 createUniformContigMap<LO,GO>( const global_size_t, \
2766 const Teuchos::RCP< const Teuchos::Comm< int > > &); \
Functions for initializing and finalizing Tpetra.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Declaration of a function that prints strings from each process.
Declaration of Tpetra::Details::initializeKokkos.
Declaration of Tpetra::Details::printOnce.
Stand-alone utility functions and macros.
Description of Tpetra's behavior.
static bool debug()
Whether Tpetra is in debug mode.
static bool verbose()
Whether Tpetra is in verbose mode.
static size_t verbosePrintCountThreshold()
Number of entries below which arrays, lists, etc. will be printed in debug mode.
Interface for breaking ties in ownership.
Implement mapping from global ID to process ID and local ID.
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.
void initialize(const map_type &map)
Initialize the Directory with its Map.
A parallel distribution of indices over processes.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
bool isOneToOne() const
Whether the Map is one to one.
std::string description() const
Implementation of Teuchos::Describable.
Teuchos::ArrayView< const global_ordinal_type > getLocalElementList() const
Return a NONOWNING view of the global indices owned by this process.
global_ordinal_type getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
global_ordinal_type getGlobalElement(local_ordinal_type localIndex) const
The global index corresponding to the given local index.
Node node_type
Legacy typedef that will go away at some point.
Map()
Default constructor (that does nothing).
GlobalOrdinal global_ordinal_type
The type of global indices.
Map(const global_size_t numGlobalElements, const global_ordinal_type indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const LocalGlobal lg=GloballyDistributed)
Constructor with contiguous uniform distribution.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const global_ordinal_type > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< local_ordinal_type > &LIDList) const
Return the process ranks and corresponding local indices for the given global indices.
bool isNodeLocalElement(local_ordinal_type localIndex) const
Whether the given local index is valid for this Map on the calling process.
bool isUniform() const
Whether the range of global indices is uniform.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
typename device_type::execution_space execution_space
The Kokkos execution space.
LocalOrdinal local_ordinal_type
The type of local indices.
Teuchos::RCP< const Map< local_ordinal_type, global_ordinal_type, Node > > removeEmptyProcesses() const
Advanced methods.
global_ordinal_type getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
bool isCompatible(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is compatible with this Map.
global_ordinal_type getIndexBase() const
The index base for this Map.
bool locallySameAs(const Map< local_ordinal_type, global_ordinal_type, node_type > &map) const
Is this Map locally the same as the input Map?
bool isLocallyFitted(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is locally fitted to this Map.
virtual ~Map()
Destructor (virtual for memory safety of derived classes).
global_ordinal_type getMinGlobalIndex() const
The minimum global index owned by the calling process.
local_ordinal_type getLocalElement(global_ordinal_type globalIndex) const
The local index corresponding to the given global index.
Teuchos::RCP< const Map< local_ordinal_type, global_ordinal_type, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map's communicator with a subset communicator.
global_ordinal_type getMaxGlobalIndex() const
The maximum global index owned by the calling process.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Describe this object in a human-readable way to the given output stream.
bool isNodeGlobalElement(global_ordinal_type globalIndex) const
Whether the given global index is owned by this Map on the calling process.
bool isSameAs(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is identical to this Map.
local_ordinal_type getMinLocalIndex() const
The minimum local index.
size_t getLocalNumElements() const
The number of elements belonging to the calling process.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
global_indices_array_type getMyGlobalIndices() const
Return a view of the global indices owned by this process.
local_ordinal_type getMaxLocalIndex() const
The maximum local index on the calling process.
typename Node::device_type device_type
This class' Kokkos::Device specialization.
::Tpetra::Details::LocalMap< local_ordinal_type, global_ordinal_type, device_type > local_map_type
Type of the "local" Map.
Implementation details of Tpetra.
void verbosePrintArray(std::ostream &out, const ArrayType &x, const char name[], const size_t maxNumToPrint)
Print min(x.size(), maxNumToPrint) entries of x.
void printOnce(std::ostream &out, const std::string &s, const Teuchos::Comm< int > *comm)
Print on one process of the given communicator, or at least try to do so (if MPI is not initialized).
bool teuchosCommIsAnMpiComm(const Teuchos::Comm< int > &)
Is the given Comm a Teuchos::MpiComm<int> instance?
std::unique_ptr< std::string > createPrefix(const int myRank, const char prefix[])
Create string prefix for each line of verbose output.
bool mpiIsInitialized()
Has MPI_Init been called (on this process)?
bool congruent(const Teuchos::Comm< int > &comm1, const Teuchos::Comm< int > &comm2)
Whether the two communicators are congruent.
void initializeKokkos()
Initialize Kokkos, using command-line arguments (if any) given to Teuchos::GlobalMPISession.
bool mpiIsFinalized()
Has MPI_Finalize been called (on this process)?
void gathervPrint(std::ostream &out, const std::string &s, const Teuchos::Comm< int > &comm)
On Process 0 in the given communicator, print strings from each process in that communicator,...
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createLocalMap(const size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a locally replicated Map with the default Kokkos Node.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createUniformContigMap(const global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with the default Kokkos Node.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createNonContigMap(const Teuchos::ArrayView< const GlobalOrdinal > &elementList, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a non-contiguous Map using the default Kokkos::Device type.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(const global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with a user-specified Kokkos Node.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createContigMap(const global_size_t numElements, const size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a (potentially) non-uniformly distributed, contiguous Map using the defaul...
size_t global_size_t
Global size_t object.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createOneToOne(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &M)
Nonmember constructor for a contiguous Map with user-defined weights and a user-specified,...
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(const size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a locally replicated Map with a specified Kokkos Node.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createNonContigMapWithNode(const Teuchos::ArrayView< const GlobalOrdinal > &elementList, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a noncontiguous Map with a user-specified, possibly nondefault Kokkos Node ...
LocalGlobal
Enum for local versus global allocation of Map entries.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(const global_size_t numElements, const size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a (potentially) nonuniformly distributed, contiguous Map for a user-specifi...