45 #ifndef TPETRA_MAP_DEF_HPP 46 #define TPETRA_MAP_DEF_HPP 48 #include "Tpetra_Directory.hpp" 50 #include "Tpetra_Details_FixedHashTable.hpp" 55 #include "Teuchos_as.hpp" 56 #include "Teuchos_TypeNameTraits.hpp" 57 #include "Teuchos_CommHelpers.hpp" 58 #include "Tpetra_Details_mpiIsInitialized.hpp" 68 template<
class ExecutionSpace>
70 checkMapInputArray (
const char ctorName[],
71 const void* indexList,
72 const size_t indexListSize,
73 const ExecutionSpace& execSpace,
74 const Teuchos::Comm<int>*
const comm)
78 const bool debug = Behavior::debug(
"Map");
80 using Teuchos::outArg;
81 using Teuchos::REDUCE_MIN;
82 using Teuchos::reduceAll;
85 const int myRank = comm ==
nullptr ? 0 : comm->getRank ();
86 const bool verbose = Behavior::verbose(
"Map");
87 std::ostringstream lclErrStrm;
90 if (indexListSize != 0 && indexList ==
nullptr) {
93 lclErrStrm <<
"Proc " << myRank <<
": indexList is null, " 94 "but indexListSize=" << indexListSize <<
" != 0." << endl;
98 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
99 if (gblSuccess != 1) {
100 std::ostringstream gblErrStrm;
101 gblErrStrm <<
"Tpetra::Map constructor " << ctorName <<
102 " detected a problem with the input array " 103 "(raw array, Teuchos::ArrayView, or Kokkos::View) " 104 "of global indices." << endl;
106 using ::Tpetra::Details::gathervPrint;
109 TEUCHOS_TEST_FOR_EXCEPTION
110 (
true, std::invalid_argument, gblErrStrm.str ());
118 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
121 comm_ (new
Teuchos::SerialComm<int> ()),
123 numGlobalElements_ (0),
124 numLocalElements_ (0),
125 minMyGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
126 maxMyGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
127 minAllGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
128 maxAllGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
129 firstContiguousGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
130 lastContiguousGID_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
133 distributed_ (false),
134 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
140 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
148 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
151 using Teuchos::broadcast;
152 using Teuchos::outArg;
153 using Teuchos::reduceAll;
154 using Teuchos::REDUCE_MIN;
155 using Teuchos::REDUCE_MAX;
156 using Teuchos::typeName;
160 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
161 const char funcName[] =
"Map(gblNumInds,indexBase,comm,LG)";
163 "Tpetra::Map::Map(gblNumInds,indexBase,comm,LG): ";
165 const bool debug = Details::Behavior::debug(
"Map");
166 const bool verbose = Details::Behavior::verbose(
"Map");
167 std::unique_ptr<std::string> prefix;
169 prefix = Details::createPrefix(
170 comm_.getRawPtr(),
"Map", funcName);
171 std::ostringstream os;
172 os << *prefix <<
"Start" << endl;
173 std::cerr << os.str();
180 GST proc0NumGlobalElements = numGlobalElements;
181 broadcast(*comm_, 0, outArg(proc0NumGlobalElements));
182 GST minNumGlobalElements = numGlobalElements;
183 GST maxNumGlobalElements = numGlobalElements;
184 reduceAll(*comm, REDUCE_MIN, numGlobalElements,
185 outArg(minNumGlobalElements));
186 reduceAll(*comm, REDUCE_MAX, numGlobalElements,
187 outArg(maxNumGlobalElements));
188 TEUCHOS_TEST_FOR_EXCEPTION
189 (minNumGlobalElements != maxNumGlobalElements ||
190 numGlobalElements != minNumGlobalElements,
191 std::invalid_argument, exPfx <<
"All processes must " 192 "provide the same number of global elements. Process 0 set " 193 "numGlobalElements="<< proc0NumGlobalElements <<
". The " 194 "calling process " << comm->getRank() <<
" set " 195 "numGlobalElements=" << numGlobalElements <<
". The min " 196 "and max values over all processes are " 197 << minNumGlobalElements <<
" resp. " << maxNumGlobalElements
200 GO proc0IndexBase = indexBase;
201 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
202 GO minIndexBase = indexBase;
203 GO maxIndexBase = indexBase;
204 reduceAll(*comm, REDUCE_MIN, indexBase, outArg(minIndexBase));
205 reduceAll(*comm, REDUCE_MAX, indexBase, outArg(maxIndexBase));
206 TEUCHOS_TEST_FOR_EXCEPTION
207 (minIndexBase != maxIndexBase || indexBase != minIndexBase,
208 std::invalid_argument, exPfx <<
"All processes must " 209 "provide the same indexBase argument. Process 0 set " 210 "indexBase=" << proc0IndexBase <<
". The calling process " 211 << comm->getRank() <<
" set indexBase=" << indexBase
212 <<
". The min and max values over all processes are " 213 << minIndexBase <<
" resp. " << maxIndexBase <<
".");
233 TEUCHOS_TEST_FOR_EXCEPTION(
234 (numGlobalElements < 1 && numGlobalElements != 0),
235 std::invalid_argument, exPfx <<
"numGlobalElements (= " 236 << numGlobalElements <<
") must be nonnegative.");
238 TEUCHOS_TEST_FOR_EXCEPTION
239 (numGlobalElements == GSTI, std::invalid_argument, exPfx <<
240 "You provided numGlobalElements = Teuchos::OrdinalTraits<" 241 "Tpetra::global_size_t>::invalid(). This version of the " 242 "constructor requires a valid value of numGlobalElements. " 243 "You probably mistook this constructor for the \"contiguous " 244 "nonuniform\" constructor, which can compute the global " 245 "number of elements for you if you set numGlobalElements to " 246 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid().");
248 size_t numLocalElements = 0;
249 if (lOrG == GloballyDistributed) {
264 const GST numProcs =
static_cast<GST
> (comm_->getSize ());
265 const GST myRank =
static_cast<GST
> (comm_->getRank ());
266 const GST quotient = numGlobalElements / numProcs;
267 const GST remainder = numGlobalElements - quotient * numProcs;
270 if (myRank < remainder) {
271 numLocalElements =
static_cast<size_t> (1) + static_cast<size_t> (quotient);
274 startIndex = as<GO> (myRank) * as<GO> (numLocalElements);
276 numLocalElements = as<size_t> (quotient);
277 startIndex = as<GO> (myRank) * as<GO> (numLocalElements) +
281 minMyGID_ = indexBase + startIndex;
282 maxMyGID_ = indexBase + startIndex + numLocalElements - 1;
283 minAllGID_ = indexBase;
284 maxAllGID_ = indexBase + numGlobalElements - 1;
285 distributed_ = (numProcs > 1);
288 numLocalElements = as<size_t> (numGlobalElements);
289 minMyGID_ = indexBase;
290 maxMyGID_ = indexBase + numGlobalElements - 1;
291 distributed_ =
false;
294 minAllGID_ = indexBase;
295 maxAllGID_ = indexBase + numGlobalElements - 1;
296 indexBase_ = indexBase;
297 numGlobalElements_ = numGlobalElements;
298 numLocalElements_ = numLocalElements;
299 firstContiguousGID_ = minMyGID_;
300 lastContiguousGID_ = maxMyGID_;
307 std::ostringstream os;
308 os << *prefix <<
"Done" << endl;
309 std::cerr << os.str();
314 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
317 const size_t numLocalElements,
319 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) :
322 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
325 using Teuchos::broadcast;
326 using Teuchos::outArg;
327 using Teuchos::reduceAll;
328 using Teuchos::REDUCE_MIN;
329 using Teuchos::REDUCE_MAX;
330 using Teuchos::REDUCE_SUM;
335 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
336 const char funcName[] =
337 "Map(gblNumInds,lclNumInds,indexBase,comm)";
339 "Tpetra::Map::Map(gblNumInds,lclNumInds,indexBase,comm): ";
340 const char suffix[] =
341 ". Please report this bug to the Tpetra developers.";
343 const bool debug = Details::Behavior::debug(
"Map");
344 const bool verbose = Details::Behavior::verbose(
"Map");
345 std::unique_ptr<std::string> prefix;
347 prefix = Details::createPrefix(
348 comm_.getRawPtr(),
"Map", funcName);
349 std::ostringstream os;
350 os << *prefix <<
"Start" << endl;
351 std::cerr << os.str();
357 GST debugGlobalSum {};
359 debugGlobalSum = initialNonuniformDebugCheck(exPfx,
360 numGlobalElements, numLocalElements, indexBase, comm);
375 scan<int, GO> (*comm, REDUCE_SUM, numLocalElements, outArg (scanResult));
376 const GO myOffset = scanResult - numLocalElements;
378 if (numGlobalElements != GSTI) {
379 numGlobalElements_ = numGlobalElements;
386 const int numProcs = comm->getSize ();
387 GST globalSum = scanResult;
389 broadcast (*comm, numProcs - 1, outArg (globalSum));
391 numGlobalElements_ = globalSum;
395 TEUCHOS_TEST_FOR_EXCEPTION
396 (globalSum != debugGlobalSum, std::logic_error, exPfx <<
397 "globalSum = " << globalSum <<
" != debugGlobalSum = " <<
398 debugGlobalSum << suffix);
401 numLocalElements_ = numLocalElements;
402 indexBase_ = indexBase;
403 minAllGID_ = (numGlobalElements_ == 0) ?
404 std::numeric_limits<GO>::max () :
406 maxAllGID_ = (numGlobalElements_ == 0) ?
407 std::numeric_limits<GO>::lowest () :
408 indexBase + GO(numGlobalElements_) - GO(1);
409 minMyGID_ = (numLocalElements_ == 0) ?
410 std::numeric_limits<GO>::max () :
411 indexBase + GO(myOffset);
412 maxMyGID_ = (numLocalElements_ == 0) ?
413 std::numeric_limits<GO>::lowest () :
414 indexBase + myOffset + GO(numLocalElements) - GO(1);
415 firstContiguousGID_ = minMyGID_;
416 lastContiguousGID_ = maxMyGID_;
418 distributed_ = checkIsDist ();
424 std::ostringstream os;
425 os << *prefix <<
"Done" << endl;
426 std::cerr << os.str();
430 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
434 const char errorMessagePrefix[],
436 const size_t numLocalElements,
437 const global_ordinal_type indexBase,
438 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
const 440 const bool debug = Details::Behavior::debug(
"Map");
445 using Teuchos::broadcast;
446 using Teuchos::outArg;
448 using Teuchos::REDUCE_MAX;
449 using Teuchos::REDUCE_MIN;
450 using Teuchos::REDUCE_SUM;
451 using Teuchos::reduceAll;
452 using GO = global_ordinal_type;
453 using GST = global_size_t;
454 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
464 GST debugGlobalSum = 0;
465 reduceAll<int, GST> (*comm, REDUCE_SUM,
static_cast<GST
> (numLocalElements),
466 outArg (debugGlobalSum));
470 GST proc0NumGlobalElements = numGlobalElements;
471 broadcast<int, GST> (*comm_, 0, outArg (proc0NumGlobalElements));
472 GST minNumGlobalElements = numGlobalElements;
473 GST maxNumGlobalElements = numGlobalElements;
474 reduceAll<int, GST> (*comm, REDUCE_MIN, numGlobalElements,
475 outArg (minNumGlobalElements));
476 reduceAll<int, GST> (*comm, REDUCE_MAX, numGlobalElements,
477 outArg (maxNumGlobalElements));
478 TEUCHOS_TEST_FOR_EXCEPTION
479 (minNumGlobalElements != maxNumGlobalElements ||
480 numGlobalElements != minNumGlobalElements,
481 std::invalid_argument, errorMessagePrefix <<
"All processes " 482 "must provide the same number of global elements, even if " 484 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() " 485 "(which signals that the Map should compute the global " 486 "number of elements). Process 0 set numGlobalElements" 487 "=" << proc0NumGlobalElements <<
". The calling process " 488 << comm->getRank() <<
" set numGlobalElements=" <<
489 numGlobalElements <<
". The min and max values over all " 490 "processes are " << minNumGlobalElements <<
" resp. " <<
491 maxNumGlobalElements <<
".");
493 GO proc0IndexBase = indexBase;
494 broadcast<int, GO> (*comm_, 0, outArg (proc0IndexBase));
495 GO minIndexBase = indexBase;
496 GO maxIndexBase = indexBase;
497 reduceAll<int, GO> (*comm, REDUCE_MIN, indexBase, outArg (minIndexBase));
498 reduceAll<int, GO> (*comm, REDUCE_MAX, indexBase, outArg (maxIndexBase));
499 TEUCHOS_TEST_FOR_EXCEPTION
500 (minIndexBase != maxIndexBase || indexBase != minIndexBase,
501 std::invalid_argument, errorMessagePrefix <<
502 "All processes must provide the same indexBase argument. " 503 "Process 0 set indexBase = " << proc0IndexBase <<
". The " 504 "calling process " << comm->getRank() <<
" set indexBase=" 505 << indexBase <<
". The min and max values over all " 506 "processes are " << minIndexBase <<
" resp. " << maxIndexBase
511 TEUCHOS_TEST_FOR_EXCEPTION
512 (numGlobalElements != GSTI &&
513 debugGlobalSum != numGlobalElements, std::invalid_argument,
514 errorMessagePrefix <<
"The sum of each process' number of " 515 "indices over all processes, " << debugGlobalSum <<
", != " 516 <<
"numGlobalElements=" << numGlobalElements <<
". If you " 517 "would like this constructor to compute numGlobalElements " 518 "for you, you may set numGlobalElements=" 519 "Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid() " 520 "on input. Please note that this is NOT necessarily -1.");
522 return debugGlobalSum;
525 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
527 Map<LocalOrdinal,GlobalOrdinal,Node>::
528 initWithNonownedHostIndexList(
529 const char errorMessagePrefix[],
530 const global_size_t numGlobalElements,
531 const Kokkos::View<
const global_ordinal_type*,
534 Kokkos::MemoryUnmanaged>& entryList_host,
535 const global_ordinal_type indexBase,
536 const Teuchos::RCP<
const Teuchos::Comm<int>>& comm)
538 using Kokkos::LayoutLeft;
539 using Kokkos::subview;
541 using Kokkos::view_alloc;
542 using Kokkos::WithoutInitializing;
544 using Teuchos::broadcast;
545 using Teuchos::outArg;
547 using Teuchos::REDUCE_MAX;
548 using Teuchos::REDUCE_MIN;
549 using Teuchos::REDUCE_SUM;
550 using Teuchos::reduceAll;
552 using GO = global_ordinal_type;
554 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
557 TEUCHOS_TEST_FOR_EXCEPTION
558 (! Kokkos::is_initialized (), std::runtime_error,
559 errorMessagePrefix <<
"The Kokkos execution space " 560 << Teuchos::TypeNameTraits<execution_space>::name()
561 <<
" has not been initialized. " 562 "Please initialize it before creating a Map.")
575 const
size_t numLocalElements(entryList_host.size());
577 initialNonuniformDebugCheck(errorMessagePrefix, numGlobalElements,
578 numLocalElements, indexBase, comm);
588 if (numGlobalElements != GSTI) {
589 numGlobalElements_ = numGlobalElements;
592 reduceAll(*comm, REDUCE_SUM,
593 static_cast<GST>(numLocalElements),
594 outArg(numGlobalElements_));
620 numLocalElements_ = numLocalElements;
621 indexBase_ = indexBase;
623 minMyGID_ = indexBase_;
624 maxMyGID_ = indexBase_;
634 if (numLocalElements_ > 0) {
638 typename decltype (lgMap_)::non_const_type lgMap
639 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
641 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
649 firstContiguousGID_ = entryList_host[0];
650 lastContiguousGID_ = firstContiguousGID_+1;
658 lgMap_host[0] = firstContiguousGID_;
660 for ( ; i < numLocalElements_; ++i) {
661 const GO curGid = entryList_host[i];
662 const LO curLid = as<LO> (i);
664 if (lastContiguousGID_ != curGid)
break;
670 lgMap_host[curLid] = curGid;
671 ++lastContiguousGID_;
673 --lastContiguousGID_;
678 minMyGID_ = firstContiguousGID_;
679 maxMyGID_ = lastContiguousGID_;
684 const std::pair<size_t, size_t> ncRange (i, entryList_host.extent (0));
685 auto nonContigGids_host = subview (entryList_host, ncRange);
686 TEUCHOS_TEST_FOR_EXCEPTION
687 (static_cast<size_t> (nonContigGids_host.extent (0)) !=
688 static_cast<size_t> (entryList_host.extent (0) - i),
689 std::logic_error,
"Tpetra::Map noncontiguous constructor: " 690 "nonContigGids_host.extent(0) = " 691 << nonContigGids_host.extent (0)
692 <<
" != entryList_host.extent(0) - i = " 693 << (entryList_host.extent (0) - i) <<
" = " 694 << entryList_host.extent (0) <<
" - " << i
695 <<
". Please report this bug to the Tpetra developers.");
699 View<GO*, LayoutLeft, device_type>
700 nonContigGids (view_alloc (
"nonContigGids", WithoutInitializing),
701 nonContigGids_host.size ());
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_) {
738 lgMapHost_ = lgMap_host;
741 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
742 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
746 firstContiguousGID_ = indexBase_+1;
747 lastContiguousGID_ = indexBase_;
772 if (std::numeric_limits<GO>::is_signed) {
775 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
778 minMaxInput[0] = -minMyGID_;
779 minMaxInput[1] = maxMyGID_;
780 minMaxInput[2] = localDist;
786 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
787 minAllGID_ = -minMaxOutput[0];
788 maxAllGID_ = minMaxOutput[1];
789 const GO globalDist = minMaxOutput[2];
790 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
794 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
795 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
796 distributed_ = checkIsDist ();
801 TEUCHOS_TEST_FOR_EXCEPTION(
802 minAllGID_ < indexBase_,
803 std::invalid_argument,
804 "Tpetra::Map constructor (noncontiguous): " 805 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is " 806 "less than the given indexBase = " << indexBase_ <<
".");
812 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
813 Map<LocalOrdinal,GlobalOrdinal,Node>::
815 const GlobalOrdinal indexList[],
816 const LocalOrdinal indexListSize,
817 const GlobalOrdinal indexBase,
818 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
821 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
824 const char funcName[] =
825 "Map(gblNumInds,indexList,indexListSize,indexBase,comm)";
827 const bool verbose = Details::Behavior::verbose(
"Map");
828 std::unique_ptr<std::string> prefix;
830 prefix = Details::createPrefix(
831 comm_.getRawPtr(),
"Map", funcName);
832 std::ostringstream os;
833 os << *prefix <<
"Start" << endl;
834 std::cerr << os.str();
837 checkMapInputArray (
"(GST, const GO[], LO, GO, comm)",
838 indexList, static_cast<size_t> (indexListSize),
839 Kokkos::DefaultHostExecutionSpace (),
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)";
872 const bool verbose = Details::Behavior::verbose(
"Map");
873 std::unique_ptr<std::string> prefix;
875 prefix = Details::createPrefix(
876 comm_.getRawPtr(),
"Map", funcName);
877 std::ostringstream os;
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,
885 Kokkos::DefaultHostExecutionSpace (),
890 const GlobalOrdinal*
const indsRaw =
891 numLclInds == 0 ? NULL : entryList.getRawPtr ();
892 Kokkos::View<
const GlobalOrdinal*,
895 Kokkos::MemoryUnmanaged> inds (indsRaw, numLclInds);
896 initWithNonownedHostIndexList(funcName, numGlobalElements, inds,
899 std::ostringstream os;
900 os << *prefix <<
"Done" << endl;
901 std::cerr << os.str();
905 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
908 const Kokkos::View<const GlobalOrdinal*, device_type>& entryList,
909 const GlobalOrdinal indexBase,
910 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm) :
913 directory_ (new
Directory<LocalOrdinal, GlobalOrdinal, Node> ())
915 using Kokkos::LayoutLeft;
916 using Kokkos::subview;
918 using Kokkos::view_alloc;
919 using Kokkos::WithoutInitializing;
921 using Teuchos::ArrayView;
923 using Teuchos::broadcast;
924 using Teuchos::outArg;
926 using Teuchos::REDUCE_MAX;
927 using Teuchos::REDUCE_MIN;
928 using Teuchos::REDUCE_SUM;
929 using Teuchos::reduceAll;
930 using Teuchos::typeName;
935 const GST GSTI = Tpetra::Details::OrdinalTraits<GST>::invalid ();
936 const char funcName[] =
937 "Map(gblNumInds,entryList(Kokkos::View),indexBase,comm)";
939 const bool verbose = Details::Behavior::verbose(
"Map");
940 std::unique_ptr<std::string> prefix;
942 prefix = Details::createPrefix(
943 comm_.getRawPtr(),
"Map", funcName);
944 std::ostringstream os;
945 os << *prefix <<
"Start" << endl;
946 std::cerr << os.str();
949 checkMapInputArray (
"(GST, Kokkos::View, GO, comm)",
951 static_cast<size_t> (entryList.extent (0)),
965 const size_t numLocalElements(entryList.size());
967 initialNonuniformDebugCheck(funcName, numGlobalElements,
968 numLocalElements, indexBase, comm);
978 if (numGlobalElements != GSTI) {
979 numGlobalElements_ = numGlobalElements;
982 reduceAll(*comm, REDUCE_SUM,
983 static_cast<GST>(numLocalElements),
984 outArg(numGlobalElements_));
1010 numLocalElements_ = numLocalElements;
1011 indexBase_ = indexBase;
1013 minMyGID_ = indexBase_;
1014 maxMyGID_ = indexBase_;
1024 if (numLocalElements_ > 0) {
1028 typename decltype (lgMap_)::non_const_type lgMap
1029 (view_alloc (
"lgMap", WithoutInitializing), numLocalElements_);
1031 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
1033 using array_layout =
1034 typename View<const GO*, device_type>::array_layout;
1035 View<GO*, array_layout, Kokkos::HostSpace> entryList_host
1036 (view_alloc (
"entryList_host", WithoutInitializing),
1037 entryList.extent(0));
1040 firstContiguousGID_ = entryList_host[0];
1041 lastContiguousGID_ = firstContiguousGID_+1;
1049 lgMap_host[0] = firstContiguousGID_;
1051 for ( ; i < numLocalElements_; ++i) {
1052 const GO curGid = entryList_host[i];
1053 const LO curLid = as<LO> (i);
1055 if (lastContiguousGID_ != curGid)
break;
1061 lgMap_host[curLid] = curGid;
1062 ++lastContiguousGID_;
1064 --lastContiguousGID_;
1069 minMyGID_ = firstContiguousGID_;
1070 maxMyGID_ = lastContiguousGID_;
1075 const std::pair<size_t, size_t> ncRange (i, entryList.extent (0));
1076 auto nonContigGids = subview (entryList, ncRange);
1077 TEUCHOS_TEST_FOR_EXCEPTION
1078 (static_cast<size_t> (nonContigGids.extent (0)) !=
1079 static_cast<size_t> (entryList.extent (0) - i),
1080 std::logic_error,
"Tpetra::Map noncontiguous constructor: " 1081 "nonContigGids.extent(0) = " 1082 << nonContigGids.extent (0)
1083 <<
" != entryList.extent(0) - i = " 1084 << (entryList.extent (0) - i) <<
" = " 1085 << entryList.extent (0) <<
" - " << i
1086 <<
". Please report this bug to the Tpetra developers.");
1089 firstContiguousGID_,
1091 static_cast<LO> (i));
1101 for ( ; i < numLocalElements_; ++i) {
1102 const GO curGid = entryList_host[i];
1103 const LO curLid =
static_cast<LO
> (i);
1104 lgMap_host[curLid] = curGid;
1108 if (curGid < minMyGID_) {
1111 if (curGid > maxMyGID_) {
1122 lgMapHost_ = lgMap_host;
1125 minMyGID_ = std::numeric_limits<GlobalOrdinal>::max();
1126 maxMyGID_ = std::numeric_limits<GlobalOrdinal>::lowest();
1130 firstContiguousGID_ = indexBase_+1;
1131 lastContiguousGID_ = indexBase_;
1156 if (std::numeric_limits<GO>::is_signed) {
1158 const GO localDist =
1159 (as<GST> (numLocalElements_) < numGlobalElements_) ? 1 : 0;
1162 minMaxInput[0] = -minMyGID_;
1163 minMaxInput[1] = maxMyGID_;
1164 minMaxInput[2] = localDist;
1167 minMaxOutput[0] = 0;
1168 minMaxOutput[1] = 0;
1169 minMaxOutput[2] = 0;
1170 reduceAll<int, GO> (*comm, REDUCE_MAX, 3, minMaxInput, minMaxOutput);
1171 minAllGID_ = -minMaxOutput[0];
1172 maxAllGID_ = minMaxOutput[1];
1173 const GO globalDist = minMaxOutput[2];
1174 distributed_ = (comm_->getSize () > 1 && globalDist == 1);
1178 reduceAll<int, GO> (*comm_, REDUCE_MIN, minMyGID_, outArg (minAllGID_));
1179 reduceAll<int, GO> (*comm_, REDUCE_MAX, maxMyGID_, outArg (maxAllGID_));
1180 distributed_ = checkIsDist ();
1183 contiguous_ =
false;
1185 TEUCHOS_TEST_FOR_EXCEPTION(
1186 minAllGID_ < indexBase_,
1187 std::invalid_argument,
1188 "Tpetra::Map constructor (noncontiguous): " 1189 "Minimum global ID = " << minAllGID_ <<
" over all process(es) is " 1190 "less than the given indexBase = " << indexBase_ <<
".");
1196 std::ostringstream os;
1197 os << *prefix <<
"Done" << endl;
1198 std::cerr << os.str();
1203 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1206 if (! Kokkos::is_initialized ()) {
1207 std::ostringstream os;
1208 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after " 1209 "Kokkos::finalize() has been called. This is user error! There are " 1210 "two likely causes: " << std::endl <<
1211 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)" 1213 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr " 1214 "of a Tpetra::Map) at the same scope in main() as Kokkos::finalize() " 1215 "or Tpetra::finalize()." << std::endl << std::endl <<
1216 "Don't do either of these! Please refer to GitHib Issue #2372." 1218 ::Tpetra::Details::printOnce (std::cerr, os.str (),
1219 this->getComm ().getRawPtr ());
1222 using ::Tpetra::Details::mpiIsInitialized;
1223 using ::Tpetra::Details::mpiIsFinalized;
1224 using ::Tpetra::Details::teuchosCommIsAnMpiComm;
1226 Teuchos::RCP<const Teuchos::Comm<int> > comm = this->getComm ();
1227 if (! comm.is_null () && teuchosCommIsAnMpiComm (*comm) &&
1228 mpiIsInitialized () && mpiIsFinalized ()) {
1234 std::ostringstream os;
1235 os <<
"WARNING: Tpetra::Map destructor (~Map()) is being called after " 1236 "MPI_Finalize() has been called. This is user error! There are " 1237 "two likely causes: " << std::endl <<
1238 " 1. You have a static Tpetra::Map (or RCP or shared_ptr of a Map)" 1240 " 2. You declare and construct a Tpetra::Map (or RCP or shared_ptr " 1241 "of a Tpetra::Map) at the same scope in main() as MPI_finalize() or " 1242 "Tpetra::finalize()." << std::endl << std::endl <<
1243 "Don't do either of these! Please refer to GitHib Issue #2372." 1245 ::Tpetra::Details::printOnce (std::cerr, os.str (), comm.getRawPtr ());
1253 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1257 TEUCHOS_TEST_FOR_EXCEPTION(
1258 getComm ().is_null (), std::logic_error,
"Tpetra::Map::isOneToOne: " 1259 "getComm() returns null. Please report this bug to the Tpetra " 1264 return directory_->isOneToOne (*
this);
1267 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1272 if (isContiguous ()) {
1273 if (globalIndex < getMinGlobalIndex () ||
1274 globalIndex > getMaxGlobalIndex ()) {
1275 return Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1277 return static_cast<LocalOrdinal
> (globalIndex - getMinGlobalIndex ());
1279 else if (globalIndex >= firstContiguousGID_ &&
1280 globalIndex <= lastContiguousGID_) {
1281 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGID_);
1287 return glMapHost_.get (globalIndex);
1291 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1296 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
1297 return Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
1299 if (isContiguous ()) {
1300 return getMinGlobalIndex () + localIndex;
1307 return lgMapHost_[localIndex];
1311 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1316 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
1323 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1327 return this->getLocalElement (globalIndex) !=
1328 Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
1331 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1336 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1342 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1348 getMinGlobalIndex (), getMaxGlobalIndex (),
1349 firstContiguousGID_, lastContiguousGID_,
1350 getNodeNumElements (), isContiguous ());
1353 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1358 using Teuchos::outArg;
1359 using Teuchos::REDUCE_MIN;
1360 using Teuchos::reduceAll;
1370 else if (getComm ()->getSize () != map.
getComm ()->getSize ()) {
1381 else if (isContiguous () && isUniform () &&
1389 lgMap_.extent (0) != 0 && map.lgMap_.extent (0) != 0 &&
1390 lgMap_.data () == map.lgMap_.data ()) {
1404 TEUCHOS_TEST_FOR_EXCEPTION(
1406 "Tpetra::Map::isCompatible: There's a bug in this method. We've already " 1407 "checked that this condition is true above, but it's false here. " 1408 "Please report this bug to the Tpetra developers.");
1411 const int locallyCompat =
1414 int globallyCompat = 0;
1415 reduceAll<int, int> (*comm_, REDUCE_MIN, locallyCompat, outArg (globallyCompat));
1416 return (globallyCompat == 1);
1419 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1424 using Teuchos::ArrayView;
1426 using size_type =
typename ArrayView<const GO>::size_type;
1449 if (isContiguous ()) {
1454 TEUCHOS_TEST_FOR_EXCEPTION(
1455 ! this->isContiguous () || map.
isContiguous (), std::logic_error,
1456 "Tpetra::Map::locallySameAs: BUG");
1458 const GO minLhsGid = this->getMinGlobalIndex ();
1459 const size_type numRhsElts = rhsElts.size ();
1460 for (size_type k = 0; k < numRhsElts; ++k) {
1461 const GO curLhsGid = minLhsGid +
static_cast<GO
> (k);
1462 if (curLhsGid != rhsElts[k]) {
1470 TEUCHOS_TEST_FOR_EXCEPTION(
1471 this->isContiguous () || ! map.
isContiguous (), std::logic_error,
1472 "Tpetra::Map::locallySameAs: BUG");
1473 ArrayView<const GO> lhsElts = this->getNodeElementList ();
1475 const size_type numLhsElts = lhsElts.size ();
1476 for (size_type k = 0; k < numLhsElts; ++k) {
1477 const GO curRhsGid = minRhsGid +
static_cast<GO
> (k);
1478 if (curRhsGid != lhsElts[k]) {
1484 else if (this->lgMap_.data () == map.lgMap_.data ()) {
1494 ArrayView<const GO> lhsElts = getNodeElementList ();
1500 return std::equal (lhsElts.begin (), lhsElts.end (), rhsElts.begin ());
1506 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1516 auto lmap2 = this->getLocalMap();
1518 auto numLocalElements1 = lmap1.getNodeNumElements();
1519 auto numLocalElements2 = lmap2.getNodeNumElements();
1521 if (numLocalElements1 > numLocalElements2) {
1526 if (lmap1.isContiguous () && lmap2.isContiguous ()) {
1528 return ((lmap1.getMinGlobalIndex () == lmap2.getMinGlobalIndex ()) &&
1529 (lmap1.getMaxGlobalIndex () <= lmap2.getMaxGlobalIndex ()));
1532 if (lmap1.getMinGlobalIndex () < lmap2.getMinGlobalIndex () ||
1533 lmap1.getMaxGlobalIndex () > lmap2.getMaxGlobalIndex ()) {
1541 Kokkos::RangePolicy<LO, typename node_type::execution_space>;
1545 Kokkos::parallel_reduce(
1547 range_type(0, numLocalElements1),
1548 KOKKOS_LAMBDA (
const LO i, LO& diff) {
1549 diff += (lmap1.getGlobalElement(i) != lmap2.getGlobalElement(i));
1552 return (numDiff == 0);
1555 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1560 using Teuchos::outArg;
1561 using Teuchos::REDUCE_MIN;
1562 using Teuchos::reduceAll;
1572 else if (getComm ()->getSize () != map.
getComm ()->getSize ()) {
1595 else if (isContiguous () && isUniform () &&
1616 const int isSame_lcl = locallySameAs (map) ? 1 : 0;
1620 reduceAll<int, int> (*comm_, REDUCE_MIN, isSame_lcl, outArg (isSame_gbl));
1621 return isSame_gbl == 1;
1625 template <
class LO,
class GO,
class DT>
1628 FillLgMap (
const Kokkos::View<GO*, DT>& lgMap,
1629 const GO startGid) :
1630 lgMap_ (lgMap), startGid_ (startGid)
1632 Kokkos::RangePolicy<LO, typename DT::execution_space>
1633 range (static_cast<LO> (0), static_cast<LO> (lgMap.size ()));
1634 Kokkos::parallel_for (range, *
this);
1637 KOKKOS_INLINE_FUNCTION
void operator () (
const LO& lid)
const {
1638 lgMap_(lid) = startGid_ +
static_cast<GO
> (lid);
1642 const Kokkos::View<GO*, DT> lgMap_;
1649 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1650 typename Map<LocalOrdinal,GlobalOrdinal,Node>::global_indices_array_type
1656 using const_lg_view_type = decltype(lgMap_);
1657 using lg_view_type =
typename const_lg_view_type::non_const_type;
1658 const bool debug = Details::Behavior::debug(
"Map");
1659 const bool verbose = Details::Behavior::verbose(
"Map");
1661 std::unique_ptr<std::string> prefix;
1663 prefix = Details::createPrefix(
1664 comm_.getRawPtr(),
"Map",
"getMyGlobalIndices");
1665 std::ostringstream os;
1666 os << *prefix <<
"Start" << endl;
1667 std::cerr << os.str();
1673 const bool needToCreateLocalToGlobalMapping =
1674 lgMap_.extent (0) == 0 && numLocalElements_ > 0;
1676 if (needToCreateLocalToGlobalMapping) {
1678 std::ostringstream os;
1679 os << *prefix <<
"Need to create lgMap" << endl;
1680 std::cerr << os.str();
1685 TEUCHOS_TEST_FOR_EXCEPTION
1686 (! isContiguous(), std::logic_error,
1687 "Tpetra::Map::getMyGlobalIndices: The local-to-global " 1688 "mapping (lgMap_) should have been set up already for a " 1689 "noncontiguous Map. Please report this bug to the Tpetra " 1692 const LO numElts =
static_cast<LO
> (getNodeNumElements ());
1694 using Kokkos::view_alloc;
1695 using Kokkos::WithoutInitializing;
1696 lg_view_type lgMap (
"lgMap", numElts);
1698 std::ostringstream os;
1699 os << *prefix <<
"Fill lgMap" << endl;
1700 std::cerr << os.str();
1702 FillLgMap<LO, GO, no_uvm_device_type> fillIt (lgMap, minMyGID_);
1705 std::ostringstream os;
1706 os << *prefix <<
"Copy lgMap to lgMapHost" << endl;
1707 std::cerr << os.str();
1711 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMap);
1716 lgMapHost_ = lgMapHost;
1720 std::ostringstream os;
1721 os << *prefix <<
"Done" << endl;
1722 std::cerr << os.str();
1727 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1728 Teuchos::ArrayView<const GlobalOrdinal>
1736 (void) this->getMyGlobalIndices ();
1739 const GO* lgMapHostRawPtr = lgMapHost_.data ();
1743 return Teuchos::ArrayView<const GO>(
1745 lgMapHost_.extent (0),
1746 Teuchos::RCP_DISABLE_NODE_LOOKUP);
1749 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1751 return distributed_;
1754 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1756 using Teuchos::TypeNameTraits;
1757 std::ostringstream os;
1759 os <<
"Tpetra::Map: {" 1760 <<
"LocalOrdinalType: " << TypeNameTraits<LocalOrdinal>::name ()
1761 <<
", GlobalOrdinalType: " << TypeNameTraits<GlobalOrdinal>::name ()
1762 <<
", NodeType: " << TypeNameTraits<Node>::name ();
1763 if (this->getObjectLabel () !=
"") {
1764 os <<
", Label: \"" << this->getObjectLabel () <<
"\"";
1766 os <<
", Global number of entries: " << getGlobalNumElements ()
1767 <<
", Number of processes: " << getComm ()->getSize ()
1768 <<
", Uniform: " << (isUniform () ?
"true" :
"false")
1769 <<
", Contiguous: " << (isContiguous () ?
"true" :
"false")
1770 <<
", Distributed: " << (isDistributed () ?
"true" :
"false")
1779 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1784 using LO = local_ordinal_type;
1788 if (vl < Teuchos::VERB_HIGH) {
1789 return std::string ();
1791 auto outStringP = Teuchos::rcp (
new std::ostringstream ());
1792 Teuchos::RCP<Teuchos::FancyOStream> outp =
1793 Teuchos::getFancyOStream (outStringP);
1794 Teuchos::FancyOStream& out = *outp;
1796 auto comm = this->getComm ();
1797 const int myRank = comm->getRank ();
1798 const int numProcs = comm->getSize ();
1799 out <<
"Process " << myRank <<
" of " << numProcs <<
":" << endl;
1800 Teuchos::OSTab tab1 (out);
1802 const LO numEnt =
static_cast<LO
> (this->getNodeNumElements ());
1803 out <<
"My number of entries: " << numEnt << endl
1804 <<
"My minimum global index: " << this->getMinGlobalIndex () << endl
1805 <<
"My maximum global index: " << this->getMaxGlobalIndex () << endl;
1807 if (vl == Teuchos::VERB_EXTREME) {
1808 out <<
"My global indices: [";
1809 const LO minLclInd = this->getMinLocalIndex ();
1810 for (LO k = 0; k < numEnt; ++k) {
1811 out << minLclInd + this->getGlobalElement (k);
1812 if (k + 1 < numEnt) {
1820 return outStringP->str ();
1823 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1825 Map<LocalOrdinal,GlobalOrdinal,Node>::
1826 describe (Teuchos::FancyOStream &out,
1827 const Teuchos::EVerbosityLevel verbLevel)
const 1829 using Teuchos::TypeNameTraits;
1830 using Teuchos::VERB_DEFAULT;
1831 using Teuchos::VERB_NONE;
1832 using Teuchos::VERB_LOW;
1833 using Teuchos::VERB_HIGH;
1837 const Teuchos::EVerbosityLevel vl =
1838 (verbLevel == VERB_DEFAULT) ? VERB_LOW : verbLevel;
1840 if (vl == VERB_NONE) {
1847 auto comm = this->getComm ();
1848 if (comm.is_null ()) {
1851 const int myRank = comm->getRank ();
1852 const int numProcs = comm->getSize ();
1861 Teuchos::RCP<Teuchos::OSTab> tab0, tab1;
1867 tab0 = Teuchos::rcp (
new Teuchos::OSTab (out));
1868 out <<
"\"Tpetra::Map\":" << endl;
1869 tab1 = Teuchos::rcp (
new Teuchos::OSTab (out));
1871 out <<
"Template parameters:" << endl;
1872 Teuchos::OSTab tab2 (out);
1873 out <<
"LocalOrdinal: " << TypeNameTraits<LO>::name () << endl
1874 <<
"GlobalOrdinal: " << TypeNameTraits<GO>::name () << endl
1875 <<
"Node: " << TypeNameTraits<Node>::name () << endl;
1877 const std::string label = this->getObjectLabel ();
1879 out <<
"Label: \"" << label <<
"\"" << endl;
1881 out <<
"Global number of entries: " << getGlobalNumElements () << endl
1882 <<
"Minimum global index: " << getMinAllGlobalIndex () << endl
1883 <<
"Maximum global index: " << getMaxAllGlobalIndex () << endl
1884 <<
"Index base: " << getIndexBase () << endl
1885 <<
"Number of processes: " << numProcs << endl
1886 <<
"Uniform: " << (isUniform () ?
"true" :
"false") << endl
1887 <<
"Contiguous: " << (isContiguous () ?
"true" :
"false") << endl
1888 <<
"Distributed: " << (isDistributed () ?
"true" :
"false") << endl;
1892 if (vl >= VERB_HIGH) {
1893 const std::string lclStr = this->localDescribeToString (vl);
1898 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1899 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1917 if (newComm.is_null () || newComm->getSize () < 1) {
1918 return Teuchos::null;
1920 else if (newComm->getSize () == 1) {
1925 RCP<map_type> newMap (
new map_type ());
1927 newMap->comm_ = newComm;
1931 newMap->indexBase_ = this->indexBase_;
1932 newMap->numGlobalElements_ = this->numLocalElements_;
1933 newMap->numLocalElements_ = this->numLocalElements_;
1934 newMap->minMyGID_ = this->minMyGID_;
1935 newMap->maxMyGID_ = this->maxMyGID_;
1936 newMap->minAllGID_ = this->minMyGID_;
1937 newMap->maxAllGID_ = this->maxMyGID_;
1938 newMap->firstContiguousGID_ = this->firstContiguousGID_;
1939 newMap->lastContiguousGID_ = this->lastContiguousGID_;
1942 newMap->uniform_ = this->uniform_;
1943 newMap->contiguous_ = this->contiguous_;
1946 newMap->distributed_ =
false;
1947 newMap->lgMap_ = this->lgMap_;
1948 newMap->lgMapHost_ = this->lgMapHost_;
1949 newMap->glMap_ = this->glMap_;
1950 newMap->glMapHost_ = this->glMapHost_;
1971 const GST RECOMPUTE = Tpetra::Details::OrdinalTraits<GST>::invalid ();
1987 auto lgMap = this->getMyGlobalIndices ();
1989 typename std::decay<decltype (lgMap.extent (0)) >::type;
1990 const size_type lclNumInds =
1991 static_cast<size_type
> (this->getNodeNumElements ());
1992 using Teuchos::TypeNameTraits;
1993 TEUCHOS_TEST_FOR_EXCEPTION
1994 (lgMap.extent (0) != lclNumInds, std::logic_error,
1995 "Tpetra::Map::replaceCommWithSubset: Result of getMyGlobalIndices() " 1996 "has length " << lgMap.extent (0) <<
" (of type " <<
1997 TypeNameTraits<size_type>::name () <<
") != this->getNodeNumElements()" 1998 " = " << this->getNodeNumElements () <<
". The latter, upon being " 1999 "cast to size_type = " << TypeNameTraits<size_type>::name () <<
", " 2000 "becomes " << lclNumInds <<
". Please report this bug to the Tpetra " 2003 Teuchos::ArrayView<const GO> lgMap = this->getNodeElementList ();
2006 const GO indexBase = this->getIndexBase ();
2008 auto lgMap_device = Kokkos::create_mirror_view_and_copy(
device_type(), lgMap);
2009 return rcp (
new map_type (RECOMPUTE, lgMap_device, indexBase, newComm));
2013 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2014 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
2018 using Teuchos::Comm;
2019 using Teuchos::null;
2020 using Teuchos::outArg;
2023 using Teuchos::REDUCE_MIN;
2024 using Teuchos::reduceAll;
2031 const int color = (numLocalElements_ == 0) ? 0 : 1;
2036 RCP<const Comm<int> > newComm = comm_->split (color, 0);
2042 if (newComm.is_null ()) {
2045 RCP<Map> map = rcp (
new Map ());
2047 map->comm_ = newComm;
2048 map->indexBase_ = indexBase_;
2049 map->numGlobalElements_ = numGlobalElements_;
2050 map->numLocalElements_ = numLocalElements_;
2051 map->minMyGID_ = minMyGID_;
2052 map->maxMyGID_ = maxMyGID_;
2053 map->minAllGID_ = minAllGID_;
2054 map->maxAllGID_ = maxAllGID_;
2055 map->firstContiguousGID_= firstContiguousGID_;
2056 map->lastContiguousGID_ = lastContiguousGID_;
2060 map->uniform_ = uniform_;
2061 map->contiguous_ = contiguous_;
2076 if (! distributed_ || newComm->getSize () == 1) {
2077 map->distributed_ =
false;
2079 const int iOwnAllGids = (numLocalElements_ == numGlobalElements_) ? 1 : 0;
2080 int allProcsOwnAllGids = 0;
2081 reduceAll<int, int> (*newComm, REDUCE_MIN, iOwnAllGids, outArg (allProcsOwnAllGids));
2082 map->distributed_ = (allProcsOwnAllGids == 1) ?
false :
true;
2085 map->lgMap_ = lgMap_;
2086 map->lgMapHost_ = lgMapHost_;
2087 map->glMap_ = glMap_;
2088 map->glMapHost_ = glMapHost_;
2105 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2109 TEUCHOS_TEST_FOR_EXCEPTION(
2110 directory_.is_null (), std::logic_error,
"Tpetra::Map::setupDirectory: " 2111 "The Directory is null. " 2112 "Please report this bug to the Tpetra developers.");
2116 if (! directory_->initialized ()) {
2117 directory_->initialize (*
this);
2121 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2123 Map<LocalOrdinal,GlobalOrdinal,Node>::
2124 getRemoteIndexList (
const Teuchos::ArrayView<const GlobalOrdinal>& GIDs,
2125 const Teuchos::ArrayView<int>& PIDs,
2126 const Teuchos::ArrayView<LocalOrdinal>& LIDs)
const 2128 using Tpetra::Details::OrdinalTraits;
2131 using size_type = Teuchos::ArrayView<int>::size_type;
2133 const bool verbose = Details::Behavior::verbose(
"Map");
2134 const size_t maxNumToPrint = verbose ?
2135 Details::Behavior::verbosePrintCountThreshold() : size_t(0);
2136 std::unique_ptr<std::string> prefix;
2138 prefix = Details::createPrefix(comm_.getRawPtr(),
2139 "Map",
"getRemoteIndexList(GIDs,PIDs,LIDs)");
2140 std::ostringstream os;
2141 os << *prefix <<
"Start: ";
2144 std::cerr << os.str();
2153 if (getGlobalNumElements () == 0) {
2154 if (GIDs.size () == 0) {
2156 std::ostringstream os;
2157 os << *prefix <<
"Done; both Map & input are empty" << endl;
2158 std::cerr << os.str();
2164 std::ostringstream os;
2165 os << *prefix <<
"Done: Map is empty on all processes, " 2166 "so all output PIDs & LIDs are invalid (-1)." << endl;
2167 std::cerr << os.str();
2169 for (size_type k = 0; k < PIDs.size (); ++k) {
2170 PIDs[k] = OrdinalTraits<int>::invalid ();
2172 for (size_type k = 0; k < LIDs.size (); ++k) {
2173 LIDs[k] = OrdinalTraits<LocalOrdinal>::invalid ();
2184 std::ostringstream os;
2185 os << *prefix <<
"Call setupDirectory" << endl;
2186 std::cerr << os.str();
2190 std::ostringstream os;
2191 os << *prefix <<
"Call directory_->getDirectoryEntries" << endl;
2192 std::cerr << os.str();
2195 directory_->getDirectoryEntries (*
this, GIDs, PIDs, LIDs);
2197 std::ostringstream os;
2198 os << *prefix <<
"Done; getDirectoryEntries returned " 2199 << (retVal ==
IDNotPresent ?
"IDNotPresent" :
"AllIDsPresent")
2205 std::cerr << os.str();
2210 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2214 const Teuchos::ArrayView<int> & PIDs)
const 2219 const bool verbose = Details::Behavior::verbose(
"Map");
2220 const size_t maxNumToPrint = verbose ?
2221 Details::Behavior::verbosePrintCountThreshold() : size_t(0);
2222 std::unique_ptr<std::string> prefix;
2224 prefix = Details::createPrefix(comm_.getRawPtr(),
2225 "Map",
"getRemoteIndexList(GIDs,PIDs)");
2226 std::ostringstream os;
2227 os << *prefix <<
"Start: ";
2230 std::cerr << os.str();
2233 if (getGlobalNumElements () == 0) {
2234 if (GIDs.size () == 0) {
2236 std::ostringstream os;
2237 os << *prefix <<
"Done; both Map & input are empty" << endl;
2238 std::cerr << os.str();
2244 std::ostringstream os;
2245 os << *prefix <<
"Done: Map is empty on all processes, " 2246 "so all output PIDs are invalid (-1)." << endl;
2247 std::cerr << os.str();
2249 for (Teuchos::ArrayView<int>::size_type k = 0; k < PIDs.size (); ++k) {
2250 PIDs[k] = Tpetra::Details::OrdinalTraits<int>::invalid ();
2261 std::ostringstream os;
2262 os << *prefix <<
"Call setupDirectory" << endl;
2263 std::cerr << os.str();
2267 std::ostringstream os;
2268 os << *prefix <<
"Call directory_->getDirectoryEntries" << endl;
2269 std::cerr << os.str();
2272 directory_->getDirectoryEntries(*
this, GIDs, PIDs);
2274 std::ostringstream os;
2275 os << *prefix <<
"Done; getDirectoryEntries returned " 2276 << (retVal ==
IDNotPresent ?
"IDNotPresent" :
"AllIDsPresent")
2280 std::cerr << os.str();
2285 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2286 Teuchos::RCP<const Teuchos::Comm<int> >
2291 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2297 using Teuchos::outArg;
2298 using Teuchos::REDUCE_MIN;
2299 using Teuchos::reduceAll;
2302 const bool verbose = Details::Behavior::verbose(
"Map");
2303 std::unique_ptr<std::string> prefix;
2305 prefix = Details::createPrefix(
2306 comm_.getRawPtr(),
"Map",
"checkIsDist");
2307 std::ostringstream os;
2308 os << *prefix <<
"Start" << endl;
2309 std::cerr << os.str();
2312 bool global =
false;
2313 if (comm_->getSize () > 1) {
2317 if (numGlobalElements_ == as<global_size_t> (numLocalElements_)) {
2330 reduceAll<int, int> (*comm_, REDUCE_MIN, localRep, outArg (allLocalRep));
2331 if (allLocalRep != 1) {
2341 std::ostringstream os;
2342 os << *prefix <<
"Done; global=" << (global ?
"true" :
"false")
2344 std::cerr << os.str();
2351 template <
class LocalOrdinal,
class GlobalOrdinal>
2352 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2354 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2356 typedef LocalOrdinal LO;
2357 typedef GlobalOrdinal GO;
2358 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2359 return createLocalMapWithNode<LO, GO, NT> (numElements, comm);
2362 template <
class LocalOrdinal,
class GlobalOrdinal>
2363 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2365 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2367 typedef LocalOrdinal LO;
2368 typedef GlobalOrdinal GO;
2369 using NT = typename ::Tpetra::Map<LO, GO>::node_type;
2370 return createUniformContigMapWithNode<LO, GO, NT> (numElements, comm);
2373 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2374 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2376 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2381 const GlobalOrdinal indexBase =
static_cast<GlobalOrdinal
> (0);
2383 return rcp (
new map_type (numElements, indexBase, comm, GloballyDistributed));
2386 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2387 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2389 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2395 const GlobalOrdinal indexBase = 0;
2398 return rcp (
new map_type (globalNumElts, indexBase, comm, LocallyReplicated));
2401 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2402 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2404 const size_t localNumElements,
2405 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2410 const GlobalOrdinal indexBase = 0;
2412 return rcp (
new map_type (numElements, localNumElements, indexBase, comm));
2415 template <
class LocalOrdinal,
class GlobalOrdinal>
2416 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2418 const size_t localNumElements,
2419 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2421 typedef LocalOrdinal LO;
2422 typedef GlobalOrdinal GO;
2425 return Tpetra::createContigMapWithNode<LO, GO, NT> (numElements, localNumElements, comm);
2428 template <
class LocalOrdinal,
class GlobalOrdinal>
2429 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal> >
2431 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
2433 typedef LocalOrdinal LO;
2434 typedef GlobalOrdinal GO;
2437 return Tpetra::createNonContigMapWithNode<LO, GO, NT> (elementList, comm);
2440 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2441 Teuchos::RCP< const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> >
2443 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm
2449 const GST INV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2453 const GlobalOrdinal indexBase = 0;
2455 return rcp (
new map_type (INV, elementList, indexBase, comm));
2458 template<
class LO,
class GO,
class NT>
2459 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> >
2463 using Teuchos::Array;
2464 using Teuchos::ArrayView;
2472 const bool verbose = Details::Behavior::verbose(
"Map");
2473 std::unique_ptr<std::string> prefix;
2475 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2476 prefix = Details::createPrefix(
2477 comm.getRawPtr(),
"createOneToOne(Map)");
2478 std::ostringstream os;
2479 os << *prefix <<
"Start" << endl;
2482 const size_t maxNumToPrint = verbose ?
2483 Details::Behavior::verbosePrintCountThreshold() : size_t(0);
2484 const GST GINV = Tpetra::Details::OrdinalTraits<GST>::invalid ();
2485 const int myRank = M->getComm ()->getRank ();
2491 if (! M->isDistributed ()) {
2498 const GST numGlobalEntries = M->getGlobalNumElements ();
2499 if (M->isContiguous()) {
2500 const size_t numLocalEntries =
2501 (myRank == 0) ? as<size_t>(numGlobalEntries) : size_t(0);
2503 std::ostringstream os;
2504 os << *prefix <<
"Input is locally replicated & contiguous; " 2505 "numLocalEntries=" << numLocalEntries << endl;
2509 rcp(
new map_type(numGlobalEntries, numLocalEntries,
2510 M->getIndexBase(), M->getComm()));
2512 std::ostringstream os;
2513 os << *prefix <<
"Done" << endl;
2520 std::ostringstream os;
2521 os << *prefix <<
"Input is locally replicated & noncontiguous" 2525 ArrayView<const GO> myGids =
2526 (myRank == 0) ? M->getNodeElementList() : Teuchos::null;
2528 rcp(
new map_type(GINV, myGids(), M->getIndexBase(),
2531 std::ostringstream os;
2532 os << *prefix <<
"Done" << endl;
2538 else if (M->isContiguous ()) {
2540 std::ostringstream os;
2541 os << *prefix <<
"Input is distributed & contiguous" << endl;
2550 std::ostringstream os;
2551 os << *prefix <<
"Input is distributed & noncontiguous" << endl;
2555 const size_t numMyElems = M->getNodeNumElements ();
2556 ArrayView<const GO> myElems = M->getNodeElementList ();
2557 Array<int> owner_procs_vec (numMyElems);
2560 std::ostringstream os;
2561 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2568 std::ostringstream os;
2569 os << *prefix <<
"getDirectoryEntries result: ";
2575 Array<GO> myOwned_vec (numMyElems);
2576 size_t numMyOwnedElems = 0;
2577 for (
size_t i = 0; i < numMyElems; ++i) {
2578 const GO GID = myElems[i];
2579 const int owner = owner_procs_vec[i];
2581 if (myRank == owner) {
2582 myOwned_vec[numMyOwnedElems++] = GID;
2585 myOwned_vec.resize (numMyOwnedElems);
2588 std::ostringstream os;
2589 os << *prefix <<
"Create Map: ";
2594 auto retMap = rcp(
new map_type(GINV, myOwned_vec(),
2595 M->getIndexBase(), M->getComm()));
2597 std::ostringstream os;
2598 os << *prefix <<
"Done" << endl;
2605 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2606 Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
2610 using Details::Behavior;
2612 using Teuchos::Array;
2613 using Teuchos::ArrayView;
2616 using Teuchos::toString;
2619 using LO = LocalOrdinal;
2620 using GO = GlobalOrdinal;
2623 const bool verbose = Behavior::verbose(
"Map");
2624 std::unique_ptr<std::string> prefix;
2626 auto comm = M.is_null() ? Teuchos::null : M->getComm();
2627 prefix = Details::createPrefix(
2628 comm.getRawPtr(),
"createOneToOne(Map,TieBreak)");
2629 std::ostringstream os;
2630 os << *prefix <<
"Start" << endl;
2633 const size_t maxNumToPrint = verbose ?
2634 Behavior::verbosePrintCountThreshold() : size_t(0);
2641 std::ostringstream os;
2642 os << *prefix <<
"Initialize Directory" << endl;
2647 std::ostringstream os;
2648 os << *prefix <<
"Done initializing Directory" << endl;
2651 size_t numMyElems = M->getNodeNumElements ();
2652 ArrayView<const GO> myElems = M->getNodeElementList ();
2653 Array<int> owner_procs_vec (numMyElems);
2655 std::ostringstream os;
2656 os << *prefix <<
"Call Directory::getDirectoryEntries: ";
2663 std::ostringstream os;
2664 os << *prefix <<
"getDirectoryEntries result: ";
2670 const int myRank = M->getComm()->getRank();
2671 Array<GO> myOwned_vec (numMyElems);
2672 size_t numMyOwnedElems = 0;
2673 for (
size_t i = 0; i < numMyElems; ++i) {
2674 const GO GID = myElems[i];
2675 const int owner = owner_procs_vec[i];
2676 if (myRank == owner) {
2677 myOwned_vec[numMyOwnedElems++] = GID;
2680 myOwned_vec.resize (numMyOwnedElems);
2685 Tpetra::Details::OrdinalTraits<global_size_t>::invalid ();
2687 std::ostringstream os;
2688 os << *prefix <<
"Create Map: ";
2693 RCP<const map_type> retMap
2694 (
new map_type (GINV, myOwned_vec (), M->getIndexBase (),
2697 std::ostringstream os;
2698 os << *prefix <<
"Done" << endl;
2712 #define TPETRA_MAP_INSTANT(LO,GO,NODE) \ 2714 template class Map< LO , GO , NODE >; \ 2716 template Teuchos::RCP< const Map<LO,GO,NODE> > \ 2717 createLocalMapWithNode<LO,GO,NODE> (const size_t numElements, \ 2718 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \ 2720 template Teuchos::RCP< const Map<LO,GO,NODE> > \ 2721 createContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \ 2722 const size_t localNumElements, \ 2723 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \ 2725 template Teuchos::RCP< const Map<LO,GO,NODE> > \ 2726 createNonContigMapWithNode(const Teuchos::ArrayView<const GO> &elementList, \ 2727 const Teuchos::RCP<const Teuchos::Comm<int> > &comm); \ 2729 template Teuchos::RCP< const Map<LO,GO,NODE> > \ 2730 createUniformContigMapWithNode<LO,GO,NODE> (const global_size_t numElements, \ 2731 const Teuchos::RCP< const Teuchos::Comm< int > >& comm); \ 2733 template Teuchos::RCP<const Map<LO,GO,NODE> > \ 2734 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M); \ 2736 template Teuchos::RCP<const Map<LO,GO,NODE> > \ 2737 createOneToOne (const Teuchos::RCP<const Map<LO,GO,NODE> >& M, \ 2738 const Tpetra::Details::TieBreak<LO,GO>& tie_break); \ 2742 #define TPETRA_MAP_INSTANT_DEFAULTNODE(LO,GO) \ 2743 template Teuchos::RCP< const Map<LO,GO> > \ 2744 createLocalMap<LO,GO>( const size_t, const Teuchos::RCP< const Teuchos::Comm< int > > &); \ 2746 template Teuchos::RCP< const Map<LO,GO> > \ 2747 createContigMap<LO,GO>( global_size_t, size_t, \ 2748 const Teuchos::RCP< const Teuchos::Comm< int > > &); \ 2750 template Teuchos::RCP< const Map<LO,GO> > \ 2751 createNonContigMap(const Teuchos::ArrayView<const GO> &, \ 2752 const Teuchos::RCP<const Teuchos::Comm<int> > &); \ 2754 template Teuchos::RCP< const Map<LO,GO> > \ 2755 createUniformContigMap<LO,GO>( const global_size_t, \ 2756 const Teuchos::RCP< const Teuchos::Comm< int > > &); \ 2758 #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.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
LO local_ordinal_type
The type of local indices.
GO global_ordinal_type
The type of global indices.
Declaration of Tpetra::Details::printOnce.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
Declaration of a function that prints strings from each process.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(const global_size_t numElements, const size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a (potentially) nonuniformly distributed, contiguous Map for a user-specifi...
bool isContiguous() const
True if this Map is distributed contiguously, else false.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
global_ordinal_type getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
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 verbosePrintArray(std::ostream &out, const ArrayType &x, const char name[], const size_t maxNumToPrint)
Print min(x.size(), maxNumToPrint) entries of x.
int local_ordinal_type
Default value of Scalar template parameter.
"Local" part of Map suitable for Kokkos kernels.
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
Implementation details of Tpetra.
Declaration of Tpetra::Details::initializeKokkos.
void gathervPrint(std::ostream &out, const std::string &s, const Teuchos::Comm< int > &comm)
On Process 0 in the given communicator, print strings from each process in that communicator, in rank order.
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 Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
global_ordinal_type getMinGlobalIndex() const
The minimum global index owned by the calling process.
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.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
global_ordinal_type getIndexBase() const
The index base for this Map.
Functions for initializing and finalizing Tpetra.
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...
global_ordinal_type getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
global_ordinal_type getMaxGlobalIndex() const
The maximum global index owned by the calling process.
Teuchos::ArrayView< const global_ordinal_type > getNodeElementList() const
Return a NONOWNING view of the global indices owned by this process.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createContigMap(const global_size_t numElements, const size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a (potentially) non-uniformly distributed, contiguous Map using the defaul...
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createLocalMap(const size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a locally replicated Map with the default Kokkos Node.
typename device_type::execution_space execution_space
The Kokkos execution space.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(const global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with a user-specified Kokkos Node...
A parallel distribution of indices over processes.
Implement mapping from global ID to process ID and local ID.
Stand-alone utility functions and macros.
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 NT ::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.
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 ...
bool isUniform() const
Whether the range of global indices is uniform.
Node node_type
Legacy typedef that will go away at some point.
Description of Tpetra's behavior.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Map()
Default constructor (that does nothing).