42 #ifndef TPETRA_MAP_DECL_HPP
43 #define TPETRA_MAP_DECL_HPP
49 #include "Tpetra_ConfigDefs.hpp"
54 #include "Kokkos_DefaultNode.hpp"
55 #include "Kokkos_DualView.hpp"
56 #include "Teuchos_Array.hpp"
57 #include "Teuchos_Comm.hpp"
58 #include "Teuchos_Describable.hpp"
67 template<
class OutMapType,
class InMapType>
69 typedef typename OutMapType::node_type out_node_type;
70 typedef typename InMapType::node_type in_node_type;
73 clone (
const InMapType& mapIn,
74 const Teuchos::RCP<out_node_type>& node2);
243 template <
class LocalOrdinal,
246 class Map :
public Teuchos::Describable {
346 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
349 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
353 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
355 const Teuchos::RCP<Node> &node);
356 #endif // TPETRA_ENABLE_DEPRECATED_CODE
394 const size_t numLocalElements,
396 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm);
398 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
401 const size_t numLocalElements,
403 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
404 const Teuchos::RCP<Node> &node);
405 #endif // TPETRA_ENABLE_DEPRECATED_CODE
448 const Kokkos::View<const GlobalOrdinal*, device_type>& indexList,
449 const GlobalOrdinal indexBase,
450 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
494 const GlobalOrdinal indexList[],
495 const LocalOrdinal indexListSize,
496 const GlobalOrdinal indexBase,
497 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
541 const Teuchos::ArrayView<const GlobalOrdinal>& indexList,
542 const GlobalOrdinal indexBase,
543 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
545 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
548 const Teuchos::ArrayView<const GlobalOrdinal>& indexList,
549 const GlobalOrdinal indexBase,
550 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
551 const Teuchos::RCP<Node>& node);
552 #endif // TPETRA_ENABLE_DEPRECATED_CODE
610 return numGlobalElements_;
619 return numLocalElements_;
637 return static_cast<LocalOrdinal
> (0);
652 return Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
755 const Teuchos::ArrayView< int>& nodeIDList,
756 const Teuchos::ArrayView< LocalOrdinal>& LIDList)
const;
783 const Teuchos::ArrayView< int> & nodeIDList)
const;
797 typedef Kokkos::View<
const GlobalOrdinal*,
984 Teuchos::RCP<const Teuchos::Comm<int> >
getComm ()
const;
986 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
987 TPETRA_DEPRECATED Teuchos::RCP<Node> getNode ()
const;
989 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1020 describe (Teuchos::FancyOStream &out,
1021 const Teuchos::EVerbosityLevel verbLevel =
1022 Teuchos::Describable::verbLevel_default)
const;
1028 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1029 template <
class NodeOut>
1030 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, NodeOut> > TPETRA_DEPRECATED
1031 clone (
const Teuchos::RCP<NodeOut>& nodeOut)
const;
1081 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1111 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1119 template <
class LO,
class GO,
class N>
friend class Map;
1122 template<
class OutMapType,
class InMapType>
1130 localDescribeToString (
const Teuchos::EVerbosityLevel vl)
const;
1139 void setupDirectory ()
const;
1155 bool checkIsDist()
const;
1165 initialNonuniformDebugCheck (
const global_size_t numGlobalElements,
1166 const size_t numLocalElements,
1167 const GlobalOrdinal indexBase,
1168 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
const;
1171 initWithNonownedHostIndexList (
const global_size_t numGlobalElements,
1172 const Kokkos::View<
const GlobalOrdinal*,
1175 Kokkos::MemoryUnmanaged>& entryList,
1176 const GlobalOrdinal indexBase,
1177 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1180 Teuchos::RCP<const Teuchos::Comm<int> > comm_;
1183 GlobalOrdinal indexBase_;
1190 size_t numLocalElements_;
1193 GlobalOrdinal minMyGID_;
1196 GlobalOrdinal maxMyGID_;
1200 GlobalOrdinal minAllGID_;
1204 GlobalOrdinal maxAllGID_;
1212 GlobalOrdinal firstContiguousGID_;
1227 GlobalOrdinal lastContiguousGID_;
1281 mutable Kokkos::View<
const GlobalOrdinal*,
1293 mutable typename decltype (lgMap_)::HostMirror lgMapHost_;
1297 typedef ::Tpetra::Details::FixedHashTable<GlobalOrdinal, LocalOrdinal, device_type>
1298 global_to_local_table_type;
1312 global_to_local_table_type glMap_;
1350 mutable Teuchos::RCP<Directory<LocalOrdinal,GlobalOrdinal,Node> > directory_;
1367 template <
class LocalOrdinal,
class GlobalOrdinal>
1368 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal> >
1370 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1386 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1387 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1389 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1391 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1392 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1394 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1396 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1397 const Teuchos::RCP<Node>& node);
1398 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1407 template <
class LocalOrdinal,
class GlobalOrdinal>
1408 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal> >
1410 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1418 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1419 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1421 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1423 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1424 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1426 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1428 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1429 const Teuchos::RCP<Node>& node);
1430 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1438 template <
class LocalOrdinal,
class GlobalOrdinal>
1439 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal> >
1441 const size_t localNumElements,
1442 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1452 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1453 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1455 const size_t localNumElements,
1456 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1458 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1459 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1461 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1463 const size_t localNumElements,
1464 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1465 const Teuchos::RCP<Node>& node);
1466 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1474 template <
class LocalOrdinal,
class GlobalOrdinal>
1475 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal> >
1477 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1486 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1487 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1489 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm);
1490 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1491 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1493 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1495 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
1496 const Teuchos::RCP<Node>& node);
1497 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1506 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1507 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1509 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1510 createWeightedContigMapWithNode (
const int thisNodeWeight,
1512 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
1513 const Teuchos::RCP<Node>& node = Teuchos::null);
1514 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1520 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1521 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1522 createOneToOne (
const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& M);
1529 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1530 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1531 createOneToOne(
const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> > &M,
1532 const ::Tpetra::Details::TieBreak<LocalOrdinal,GlobalOrdinal> & tie_break);
1536 #include "Tpetra_Directory_decl.hpp"
1541 template<
class OutMapType,
class InMapType>
1542 OutMapType TPETRA_DEPRECATED
1543 MapCloner<OutMapType, InMapType>::
1544 clone (
const InMapType& mapIn,
1545 const Teuchos::RCP<out_node_type>& )
1547 static_assert (std::is_same<
typename OutMapType::local_ordinal_type,
1548 typename InMapType::local_ordinal_type>::value,
1549 "Tpetra::Map clone: The LocalOrdinal template parameter "
1550 "of the input and output Map types must be the same.");
1551 static_assert (std::is_same<
typename OutMapType::global_ordinal_type,
1552 typename InMapType::global_ordinal_type>::value,
1553 "Tpetra::Map clone: The GlobalOrdinal template parameter "
1554 "of the input and output Map types must be the same.");
1555 typedef typename OutMapType::local_ordinal_type LO;
1556 typedef typename OutMapType::global_ordinal_type GO;
1557 typedef ::Tpetra::Directory<LO, GO,
1558 typename OutMapType::node_type> out_dir_type;
1559 typedef typename OutMapType::global_to_local_table_type out_table_type;
1560 typedef typename OutMapType::device_type out_device_type;
1567 mapOut.comm_ = mapIn.comm_;
1568 mapOut.indexBase_ = mapIn.indexBase_;
1569 mapOut.numGlobalElements_ = mapIn.numGlobalElements_;
1570 mapOut.numLocalElements_ = mapIn.numLocalElements_;
1571 mapOut.minMyGID_ = mapIn.minMyGID_;
1572 mapOut.maxMyGID_ = mapIn.maxMyGID_;
1573 mapOut.minAllGID_ = mapIn.minAllGID_;
1574 mapOut.maxAllGID_ = mapIn.maxAllGID_;
1575 mapOut.firstContiguousGID_= mapIn.firstContiguousGID_;
1576 mapOut.lastContiguousGID_ = mapIn.lastContiguousGID_;
1577 mapOut.uniform_ = mapIn.uniform_;
1578 mapOut.contiguous_ = mapIn.contiguous_;
1579 mapOut.distributed_ = mapIn.distributed_;
1586 Kokkos::View<GO*, Kokkos::LayoutLeft, out_device_type>
1587 lgMapOut (
"lgMap", mapIn.lgMap_.extent (0));
1589 mapOut.lgMap_ = lgMapOut;
1601 static_assert (std::is_same<
typename decltype (mapOut.lgMapHost_)::array_layout,
1602 typename decltype (mapIn.lgMapHost_)::array_layout>::value,
1603 "mapOut.lgMapHost_ and MapIn.lgMapHost_ do not have the same "
1604 "array_layout. Please report this bug to the Tpetra developers.");
1607 auto lgMapHostOut = Kokkos::create_mirror_view (lgMapOut);
1609 mapOut.lgMapHost_ = lgMapHostOut;
1615 mapOut.glMap_ = out_table_type (mapIn.glMap_);
1620 mapOut.directory_ = Teuchos::rcp (
new out_dir_type ());
1627 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1628 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1629 template <
class NodeOut>
1630 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, NodeOut> > TPETRA_DEPRECATED
1631 Map<LocalOrdinal,GlobalOrdinal,Node>::
1632 clone (
const Teuchos::RCP<NodeOut>& nodeOut)
const
1634 typedef Map<LocalOrdinal, GlobalOrdinal, Node> in_map_type;
1635 typedef Map<LocalOrdinal, GlobalOrdinal, NodeOut> out_map_type;
1636 typedef Details::MapCloner<out_map_type, in_map_type> cloner_type;
1638 return Teuchos::rcp (
new out_map_type (cloner_type::clone (*
this, nodeOut)));
1646 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1653 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1659 #endif // TPETRA_MAP_DECL_HPP
bool isLocallyFitted(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is locally fitted to this Map.
LO local_ordinal_type
The type of local indices.
virtual ~Map()
Destructor (virtual for memory safety of derived classes).
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
GO global_ordinal_type
The type of global indices.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is owned by this Map on the calling process.
global_indices_array_type getMyGlobalIndices() const
Return a view of the global indices owned by this process.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is compatible with this Map.
bool isUniform() const
Whether the range of global indices is uniform.
Declaration and definition of the Tpetra::Map class, an implementation detail of Tpetra::Map.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(const global_size_t numElements, const size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a (potentially) nonuniformly distributed, contiguous Map for a user-specifi...
GlobalOrdinal getIndexBase() const
The index base for this Map.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > removeEmptyProcesses() const
Advanced methods.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
bool operator!=(const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map1, const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map2)
True if map1 is not the same as (in the sense of isSameAs()) map2, else false.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
typename device_type::memory_space memory_space
The Kokkos memory space.
bool locallySameAs(const Map< LocalOrdinal, GlobalOrdinal, node_type > &map) const
Is this Map locally the same as the input Map?
bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on the calling process.
"Local" part of Map suitable for Kokkos kernels.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
size_t global_size_t
Global size_t object.
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
Copy the contents of the MultiVector src into dst.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createOneToOne(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &M)
Nonmember constructor for a contiguous Map with user-defined weights and a user-specified, possibly nondefault Kokkos Node type.
Forward declaration of Tpetra::Directory.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map's communicator with a subset communicator.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createUniformContigMap(const global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with the default Kokkos Node...
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const
Return the process ranks and corresponding local indices for the given global indices.
bool operator==(const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map1, const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map2)
True if map1 is the same as (in the sense of isSameAs()) map2, else false.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createContigMap(const global_size_t numElements, const size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a (potentially) non-uniformly distributed, contiguous Map using the defaul...
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createLocalMap(const size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a locally replicated Map with the default Kokkos Node.
local_map_type getLocalMap() const
Get the local Map for Kokkos kernels.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a NONOWNING view of the global indices owned by this process.
typename device_type::execution_space execution_space
The Kokkos execution space.
Implementation detail of Map::clone().
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(const global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with a user-specified Kokkos Node...
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
A parallel distribution of indices over processes.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
bool isOneToOne() const
Whether the Map is one to one.
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.
Map & operator=(const Map< local_ordinal_type, global_ordinal_type, node_type > &)=default
Copy assigment (shallow copy).
typename node_type::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.
::Tpetra::Details::LocalMap< local_ordinal_type, global_ordinal_type, device_type > local_map_type
Type of the "local" Map.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Describe this object in a human-readable way to the given output stream.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createNonContigMapWithNode(const Teuchos::ArrayView< const GlobalOrdinal > &elementList, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a noncontiguous Map with a user-specified, possibly nondefault Kokkos Node ...
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
node_type node_type
Legacy typedef that will go away at some point.
Forward declaration of Tpetra::Map.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
Forward declaration for Tpetra::TieBreak.
std::string description() const
Implementation of Teuchos::Describable.
Map()
Default constructor (that does nothing).