42 #ifndef TPETRA_MAP_DECL_HPP 43 #define TPETRA_MAP_DECL_HPP 49 #include "Tpetra_ConfigDefs.hpp" 50 #include "Kokkos_DefaultNode.hpp" 51 #include "Kokkos_DualView.hpp" 52 #include "Teuchos_Describable.hpp" 53 #include "Tpetra_Details_FixedHashTable_decl.hpp" 66 #ifndef HAVE_TPETRA_FIXED_HASH_TABLE 67 # define HAVE_TPETRA_FIXED_HASH_TABLE 1 68 #endif // HAVE_TPETRA_FIXED_HASH_TABLE 72 #ifndef DOXYGEN_SHOULD_SKIP_THIS 74 template <
class LO,
class GO,
class N>
class Directory;
75 #endif // DOXYGEN_SHOULD_SKIP_THIS 79 #ifndef DOXYGEN_SHOULD_SKIP_THIS 81 template <
class LO,
class GO>
class TieBreak;
82 #endif // DOXYGEN_SHOULD_SKIP_THIS 86 template<
class OutMapType,
class InMapType>
88 typedef typename OutMapType::node_type out_node_type;
89 typedef typename InMapType::node_type in_node_type;
92 clone (
const InMapType& mapIn,
93 const Teuchos::RCP<out_node_type>& node2);
110 template<
class LocalOrdinal,
class GlobalOrdinal,
class DeviceType>
114 const Kokkos::View<const GlobalOrdinal*, DeviceType>& lgMap,
115 const GlobalOrdinal indexBase,
116 const GlobalOrdinal myMinGid,
117 const GlobalOrdinal myMaxGid,
118 const GlobalOrdinal firstContiguousGid,
119 const GlobalOrdinal lastContiguousGid,
120 const LocalOrdinal numLocalElements,
121 const bool contiguous) :
124 indexBase_ (indexBase),
125 myMinGid_ (myMinGid),
126 myMaxGid_ (myMaxGid),
127 firstContiguousGid_ (firstContiguousGid),
128 lastContiguousGid_ (lastContiguousGid),
129 numLocalElements_ (numLocalElements),
130 contiguous_ (contiguous)
135 return numLocalElements_;
157 KOKKOS_INLINE_FUNCTION LocalOrdinal
160 if (numLocalElements_ == 0) {
163 return static_cast<LocalOrdinal
> (numLocalElements_ - 1);
178 KOKKOS_INLINE_FUNCTION LocalOrdinal
182 if (globalIndex < myMinGid_ || globalIndex > myMaxGid_) {
185 return static_cast<LocalOrdinal
> (globalIndex - myMinGid_);
187 else if (globalIndex >= firstContiguousGid_ &&
188 globalIndex <= lastContiguousGid_) {
189 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGid_);
194 return glMap_.get (globalIndex);
199 KOKKOS_INLINE_FUNCTION GlobalOrdinal
202 if (localIndex < getMinLocalIndex () || localIndex > getMaxLocalIndex ()) {
205 if (isContiguous ()) {
206 return getMinGlobalIndex () + localIndex;
209 return lgMap_(localIndex);
215 Kokkos::View<const GlobalOrdinal*, DeviceType> lgMap_;
216 GlobalOrdinal indexBase_;
217 GlobalOrdinal myMinGid_;
218 GlobalOrdinal myMaxGid_;
219 GlobalOrdinal firstContiguousGid_;
220 GlobalOrdinal lastContiguousGid_;
221 LocalOrdinal numLocalElements_;
227 Teuchos::RCP<Node> defaultArgNode() {
233 return KokkosClassic::Details::getNode<Node> ();
386 class GlobalOrdinal = Details::DefaultTypes::global_ordinal_type,
388 class Map :
public Teuchos::Describable {
406 typedef typename Kokkos::Device<
typename Node::execution_space,
471 GlobalOrdinal indexBase,
472 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
474 const Teuchos::RCP<Node> &node = defaultArgNode<Node>());
516 size_t numLocalElements,
517 GlobalOrdinal indexBase,
518 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
519 const Teuchos::RCP<Node> &node = defaultArgNode<Node>());
556 const Teuchos::ArrayView<const GlobalOrdinal> &elementList,
557 GlobalOrdinal indexBase,
558 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
559 const Teuchos::RCP<Node> &node = defaultArgNode<Node>());
585 bool isOneToOne ()
const;
593 return numGlobalElements_;
602 return numLocalElements_;
620 return static_cast<LocalOrdinal
> (0);
634 if (this->getNodeNumElements () == 0) {
637 return static_cast<LocalOrdinal
> (this->getNodeNumElements () - 1);
689 LocalOrdinal getLocalElement (GlobalOrdinal globalIndex)
const;
699 GlobalOrdinal getGlobalElement (LocalOrdinal localIndex)
const;
737 getRemoteIndexList (
const Teuchos::ArrayView<const GlobalOrdinal>& GIDList,
738 const Teuchos::ArrayView< int>& nodeIDList,
739 const Teuchos::ArrayView< LocalOrdinal>& LIDList)
const;
765 getRemoteIndexList (
const Teuchos::ArrayView<const GlobalOrdinal> & GIDList,
766 const Teuchos::ArrayView< int> & nodeIDList)
const;
774 Teuchos::ArrayView<const GlobalOrdinal> getNodeElementList()
const;
786 bool isNodeLocalElement (LocalOrdinal localIndex)
const;
794 bool isNodeGlobalElement (GlobalOrdinal globalIndex)
const;
802 bool isUniform ()
const;
815 bool isContiguous ()
const;
837 bool isDistributed ()
const;
908 Teuchos::RCP<const Teuchos::Comm<int> > getComm ()
const;
911 Teuchos::RCP<Node> getNode ()
const;
918 std::string description ()
const;
922 describe (Teuchos::FancyOStream &out,
923 const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const;
930 template <
class NodeOut>
931 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, NodeOut> >
932 clone (
const RCP<NodeOut>& nodeOut)
const;
981 RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
982 removeEmptyProcesses ()
const;
1011 RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
1012 replaceCommWithSubset (
const Teuchos::RCP<
const Teuchos::Comm<int> >& newComm)
const;
1019 template <
class LO,
class GO,
class N>
friend class Map;
1022 template<
class OutMapType,
class InMapType>
1032 void setupDirectory ()
const;
1048 bool checkIsDist()
const;
1051 Teuchos::RCP<const Teuchos::Comm<int> > comm_;
1054 Teuchos::RCP<Node> node_;
1057 GlobalOrdinal indexBase_;
1063 size_t numLocalElements_;
1066 GlobalOrdinal minMyGID_;
1069 GlobalOrdinal maxMyGID_;
1072 GlobalOrdinal minAllGID_;
1075 GlobalOrdinal maxAllGID_;
1083 GlobalOrdinal firstContiguousGID_;
1098 GlobalOrdinal lastContiguousGID_;
1137 mutable Kokkos::View<GlobalOrdinal*, device_type> lgMap_;
1155 global_to_local_table_type glMap_;
1193 mutable Teuchos::RCP<Directory<LocalOrdinal,GlobalOrdinal,Node> > directory_;
1210 template <
class LocalOrdinal,
class GlobalOrdinal>
1211 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal> >
1212 createLocalMap (
size_t numElements,
const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1230 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1231 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1233 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1234 const Teuchos::RCP<Node>& node = defaultArgNode<Node> ());
1243 template <
class LocalOrdinal,
class GlobalOrdinal>
1244 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal> >
1246 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm);
1254 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1255 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1257 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1258 const Teuchos::RCP<Node>& node =
1259 defaultArgNode<Node> ());
1269 template <
class LocalOrdinal,
class GlobalOrdinal>
1270 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal> >
1272 size_t localNumElements,
1273 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm);
1281 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1282 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >
1284 size_t localNumElements,
1285 const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
1286 const Teuchos::RCP<Node>& node =
1287 defaultArgNode<Node> ());
1297 template <
class LocalOrdinal,
class GlobalOrdinal>
1298 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal> >
1300 const RCP<
const Teuchos::Comm<int> > &comm);
1308 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1309 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1311 const RCP<
const Teuchos::Comm<int> > &comm,
1312 const RCP<Node> &node);
1320 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1321 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1324 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
1325 const Teuchos::RCP<Node> &node);
1333 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1334 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1344 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1345 Teuchos::RCP< const Map<LocalOrdinal,GlobalOrdinal,Node> >
1351 #include "Tpetra_Directory_decl.hpp" 1356 template<
class OutMapType,
class InMapType>
1358 MapCloner<OutMapType, InMapType>::
1359 clone (
const InMapType& mapIn,
1360 const Teuchos::RCP<out_node_type>& nodeOut)
1362 static_assert (std::is_same<
typename OutMapType::local_ordinal_type,
1363 typename InMapType::local_ordinal_type>::value,
1364 "Tpetra::Map clone: The LocalOrdinal template parameter " 1365 "of the input and output Map types must be the same.");
1366 static_assert (std::is_same<
typename OutMapType::global_ordinal_type,
1367 typename InMapType::global_ordinal_type>::value,
1368 "Tpetra::Map clone: The GlobalOrdinal template parameter " 1369 "of the input and output Map types must be the same.");
1370 typedef typename OutMapType::local_ordinal_type LO;
1371 typedef typename OutMapType::global_ordinal_type GO;
1372 typedef ::Tpetra::Directory<LO, GO,
1373 typename OutMapType::node_type> out_dir_type;
1374 typedef typename OutMapType::global_to_local_table_type out_table_type;
1375 typedef typename OutMapType::device_type out_device_type;
1382 mapOut.comm_ = mapIn.comm_;
1383 mapOut.indexBase_ = mapIn.indexBase_;
1384 mapOut.numGlobalElements_ = mapIn.numGlobalElements_;
1385 mapOut.numLocalElements_ = mapIn.numLocalElements_;
1386 mapOut.minMyGID_ = mapIn.minMyGID_;
1387 mapOut.maxMyGID_ = mapIn.maxMyGID_;
1388 mapOut.minAllGID_ = mapIn.minAllGID_;
1389 mapOut.maxAllGID_ = mapIn.maxAllGID_;
1390 mapOut.firstContiguousGID_= mapIn.firstContiguousGID_;
1391 mapOut.lastContiguousGID_ = mapIn.lastContiguousGID_;
1392 mapOut.uniform_ = mapIn.uniform_;
1393 mapOut.contiguous_ = mapIn.contiguous_;
1394 mapOut.distributed_ = mapIn.distributed_;
1401 Kokkos::View<GO*, out_device_type>
1402 lgMapOut (
"lgMap", mapIn.lgMap_.dimension_0 ());
1404 mapOut.lgMap_ = lgMapOut;
1410 mapOut.glMap_ = out_table_type (mapIn.glMap_);
1412 mapOut.node_ = nodeOut;
1417 mapOut.directory_ = Teuchos::rcp (
new out_dir_type ());
1424 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1425 template <
class NodeOut>
1426 RCP<const Map<LocalOrdinal, GlobalOrdinal, NodeOut> >
1428 clone (
const Teuchos::RCP<NodeOut>& nodeOut)
const 1434 return Teuchos::rcp (
new out_map_type (cloner_type::clone (*
this, nodeOut)));
1441 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1448 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1454 #endif // TPETRA_MAP_DECL_HPP Interface for breaking ties in ownership.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getMinGlobalIndex() const
The minimum global index on the calling process.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Traits class for "invalid" (flag) values of integer types that Tpetra uses as local ordinals or globa...
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, NodeOut > > clone(const RCP< NodeOut > &nodeOut) const
Advanced methods.
GlobalOrdinal global_ordinal_type
The type of global indices.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createNonContigMap(const ArrayView< const GlobalOrdinal > &elementList, const RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a non-contiguous Map with the default Kokkos Node.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
Kokkos::Device< typename Node::execution_space, typename Node::memory_space > device_type
The Kokkos device type over which to allocate Views and perform work.
KOKKOS_INLINE_FUNCTION LocalOrdinal getLocalElement(const GlobalOrdinal globalIndex) const
Get the local index corresponding to the given global index.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createLocalMapWithNode(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode< Node >())
Nonmember constructor for a locally replicated Map with a specified Kokkos Node.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createContigMapWithNode(global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode< Node >())
Non-member constructor for a (potentially) non-uniformly distributed, contiguous Map with a user-spec...
GlobalOrdinal getIndexBase() const
The index base for this Map.
LocalOrdinal getMinLocalIndex() const
The minimum local index.
void deep_copy(const LittleBlock< ST2, LO > &dst, const LittleBlock< ST1, LO > &src, typename std::enable_if< std::is_convertible< ST1, ST2 >::value &&!std::is_const< ST2 >::value, int >::type *=NULL)
Copy the LittleBlock src into the LittleBlock dst.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createLocalMap(size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a locally replicated Map with the default Kokkos Node.
Details::LocalMap< LocalOrdinal, GlobalOrdinal, device_type > local_map_type
Type of the "local" Map.
"Local" part of Map suitable for Kokkos kernels.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createWeightedContigMapWithNode(int thisNodeWeight, global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node)
Non-member constructor for a contiguous Map with user-defined weights and a user-specified Kokkos Nod...
Implementation details of Tpetra.
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
size_t global_size_t
Global size_t object.
Traits class for "invalid" (flag) values of integer types that Tpetra uses as local ordinals or globa...
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.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createUniformContigMap(global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with the default Kokkos Node...
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createOneToOne(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &M)
Creates a one-to-one version of the given Map where each GID is owned by only one process...
KOKKOS_INLINE_FUNCTION GlobalOrdinal getGlobalElement(const LocalOrdinal localIndex) const
Get the global index corresponding to the given local index.
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
KOKKOS_INLINE_FUNCTION bool isContiguous() const
Whether the Map is (locally) contiguous.
KOKKOS_INLINE_FUNCTION LocalOrdinal getNodeNumElements() const
The number of indices that live on the calling process.
KOKKOS_INLINE_FUNCTION LocalOrdinal getMinLocalIndex() const
The minimum local index.
Node node_type
The type of the Kokkos Node.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getMaxGlobalIndex() const
The maximum global index on the calling process.
Implementation detail of Map::clone().
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createContigMap(global_size_t numElements, size_t localNumElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a (potentially) non-uniformly distributed, contiguous Map with the default...
size_t getNodeNumElements() const
The number of elements belonging to the calling process.
Describes a parallel distribution of objects over processes.
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.
bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const
True if and only if map is identical to this Map.
LocalOrdinal local_ordinal_type
The type of local indices.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createNonContigMapWithNode(const ArrayView< const GlobalOrdinal > &elementList, const RCP< const Teuchos::Comm< int > > &comm, const RCP< Node > &node)
Non-member constructor for a non-contiguous Map with a user-specified Kokkos Node.
LocalGlobal
Enum for local versus global allocation of Map entries.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getIndexBase() const
The (global) index base.
LocalOrdinal getMaxLocalIndex() const
The maximum local index on the calling process.
KOKKOS_INLINE_FUNCTION LocalOrdinal getMaxLocalIndex() const
The maximum local index.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createUniformContigMapWithNode(global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=defaultArgNode< Node >())
Non-member constructor for a uniformly distributed, contiguous Map with a user-specified Kokkos Node...
global_size_t getGlobalNumElements() const
The number of elements in this Map.