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 Kokkos::View<
const GlobalOrdinal*,
1295 Kokkos::HostSpace> lgMapHost_;
1299 typedef ::Tpetra::Details::FixedHashTable<GlobalOrdinal, LocalOrdinal, device_type>
1300 global_to_local_table_type;
1314 global_to_local_table_type glMap_;
1352 mutable Teuchos::RCP<Directory<LocalOrdinal,GlobalOrdinal,Node> > directory_;
1369 template <
class LocalOrdinal,
class GlobalOrdinal>
1370 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal> >
1372 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1388 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1389 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1391 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1393 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1394 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1396 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1398 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1399 const Teuchos::RCP<Node>& node);
1400 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1409 template <
class LocalOrdinal,
class GlobalOrdinal>
1410 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal> >
1412 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1420 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1421 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1423 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1425 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1426 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1428 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1430 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1431 const Teuchos::RCP<Node>& node);
1432 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1440 template <
class LocalOrdinal,
class GlobalOrdinal>
1441 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal> >
1443 const size_t localNumElements,
1444 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1454 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1455 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1457 const size_t localNumElements,
1458 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1460 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1461 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1463 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1465 const size_t localNumElements,
1466 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1467 const Teuchos::RCP<Node>& node);
1468 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1476 template <
class LocalOrdinal,
class GlobalOrdinal>
1477 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal> >
1479 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1488 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1489 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1491 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm);
1492 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1493 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1495 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1497 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
1498 const Teuchos::RCP<Node>& node);
1499 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1508 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1509 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1511 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1512 createWeightedContigMapWithNode (
const int thisNodeWeight,
1514 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
1515 const Teuchos::RCP<Node>& node = Teuchos::null);
1516 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1522 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1523 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1524 createOneToOne (
const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> >& M);
1531 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1532 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1533 createOneToOne(
const Teuchos::RCP<
const Map<LocalOrdinal,GlobalOrdinal,Node> > &M,
1534 const ::Tpetra::Details::TieBreak<LocalOrdinal,GlobalOrdinal> & tie_break);
1538 #include "Tpetra_Directory_decl.hpp"
1543 template<
class OutMapType,
class InMapType>
1544 OutMapType TPETRA_DEPRECATED
1545 MapCloner<OutMapType, InMapType>::
1546 clone (
const InMapType& mapIn,
1547 const Teuchos::RCP<out_node_type>& )
1549 static_assert (std::is_same<
typename OutMapType::local_ordinal_type,
1550 typename InMapType::local_ordinal_type>::value,
1551 "Tpetra::Map clone: The LocalOrdinal template parameter "
1552 "of the input and output Map types must be the same.");
1553 static_assert (std::is_same<
typename OutMapType::global_ordinal_type,
1554 typename InMapType::global_ordinal_type>::value,
1555 "Tpetra::Map clone: The GlobalOrdinal template parameter "
1556 "of the input and output Map types must be the same.");
1557 typedef typename OutMapType::local_ordinal_type LO;
1558 typedef typename OutMapType::global_ordinal_type GO;
1559 typedef ::Tpetra::Directory<LO, GO,
1560 typename OutMapType::node_type> out_dir_type;
1561 typedef typename OutMapType::global_to_local_table_type out_table_type;
1562 typedef typename OutMapType::device_type out_device_type;
1569 mapOut.comm_ = mapIn.comm_;
1570 mapOut.indexBase_ = mapIn.indexBase_;
1571 mapOut.numGlobalElements_ = mapIn.numGlobalElements_;
1572 mapOut.numLocalElements_ = mapIn.numLocalElements_;
1573 mapOut.minMyGID_ = mapIn.minMyGID_;
1574 mapOut.maxMyGID_ = mapIn.maxMyGID_;
1575 mapOut.minAllGID_ = mapIn.minAllGID_;
1576 mapOut.maxAllGID_ = mapIn.maxAllGID_;
1577 mapOut.firstContiguousGID_= mapIn.firstContiguousGID_;
1578 mapOut.lastContiguousGID_ = mapIn.lastContiguousGID_;
1579 mapOut.uniform_ = mapIn.uniform_;
1580 mapOut.contiguous_ = mapIn.contiguous_;
1581 mapOut.distributed_ = mapIn.distributed_;
1588 Kokkos::View<GO*, Kokkos::LayoutLeft, out_device_type>
1589 lgMapOut (
"lgMap", mapIn.lgMap_.extent (0));
1591 mapOut.lgMap_ = lgMapOut;
1605 Kokkos::create_mirror_view (Kokkos::HostSpace (), lgMapOut);
1607 mapOut.lgMapHost_ = lgMapHostOut;
1613 mapOut.glMap_ = out_table_type (mapIn.glMap_);
1618 mapOut.directory_ = Teuchos::rcp (
new out_dir_type ());
1625 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1626 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1627 template <
class NodeOut>
1628 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, NodeOut> > TPETRA_DEPRECATED
1629 Map<LocalOrdinal,GlobalOrdinal,Node>::
1630 clone (
const Teuchos::RCP<NodeOut>& nodeOut)
const
1632 typedef Map<LocalOrdinal, GlobalOrdinal, Node> in_map_type;
1633 typedef Map<LocalOrdinal, GlobalOrdinal, NodeOut> out_map_type;
1634 typedef Details::MapCloner<out_map_type, in_map_type> cloner_type;
1636 return Teuchos::rcp (
new out_map_type (cloner_type::clone (*
this, nodeOut)));
1644 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1651 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1657 #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).