Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Map_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TPETRA_MAP_DECL_HPP
11#define TPETRA_MAP_DECL_HPP
12
16
17#include "Tpetra_ConfigDefs.hpp"
18#include "Tpetra_Map_fwd.hpp"
22#include "Tpetra_KokkosCompat_DefaultNode.hpp"
23#include "Kokkos_DualView.hpp"
24#include "Teuchos_Array.hpp"
25#include "Teuchos_Comm.hpp"
26#include "Teuchos_Describable.hpp"
27
28namespace Tpetra {
29
194template <class LocalOrdinal,
195 class GlobalOrdinal,
196 class Node>
197class Map : public Teuchos::Describable {
198 public:
200
201
204
207
213 using device_type = typename Node::device_type;
214
216 using execution_space = typename device_type::execution_space;
217
219 using memory_space = typename device_type::memory_space;
220
222 using node_type = Node;
223
241
243
245
297 const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
298 const LocalGlobal lg = GloballyDistributed);
299
336 const size_t numLocalElements,
338 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
339
381 const Kokkos::View<const global_ordinal_type*, device_type>& indexList,
383 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
384
427 const global_ordinal_type indexList[],
430 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
431
474 const Teuchos::ArrayView<const global_ordinal_type>& indexList,
476 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
477
491 Map();
492
495
498
500 Map&
502
504 Map&
506
516 virtual ~Map();
517
519
521
526 bool isOneToOne() const;
527
534 return numGlobalElements_;
535 }
536
542 size_t getLocalNumElements() const {
543 return numLocalElements_;
544 }
545
552 return indexBase_;
553 }
554
561 return static_cast<local_ordinal_type>(0);
562 }
563
575 if (this->getLocalNumElements() == 0) {
576 return Tpetra::Details::OrdinalTraits<local_ordinal_type>::invalid();
577 } else { // Local indices are always zero-based.
578 return static_cast<local_ordinal_type>(this->getLocalNumElements() - 1);
579 }
580 }
581
587 global_ordinal_type getMinGlobalIndex() const {
588 return minMyGID_;
589 }
590
597 return maxMyGID_;
598 }
599
606 return minAllGID_;
607 }
608
615 return maxAllGID_;
616 }
617
631
641
642 bool getGlobalElements(
643 const local_ordinal_type localIndices[], size_t numEntries, global_ordinal_type globalIndices[]) const;
644
650
681 getRemoteIndexList(const Teuchos::ArrayView<const global_ordinal_type>& GIDList,
682 const Teuchos::ArrayView<int>& nodeIDList,
683 const Teuchos::ArrayView<local_ordinal_type>& LIDList) const;
684
709 getRemoteIndexList(const Teuchos::ArrayView<const global_ordinal_type>& GIDList,
710 const Teuchos::ArrayView<int>& nodeIDList) const;
711
712 private:
724 typedef Kokkos::View<const global_ordinal_type*,
725 Kokkos::LayoutLeft,
726 Kokkos::HostSpace>
727 global_indices_array_type;
728
729 typedef Kokkos::View<const global_ordinal_type*,
731 global_indices_array_device_type;
732
733 public:
753 global_indices_array_type getMyGlobalIndices() const;
754
756 global_indices_array_device_type getMyGlobalIndicesDevice() const;
757
768 Teuchos::ArrayView<const global_ordinal_type> getLocalElementList() const;
769
771
773
781
789
796 bool isUniform() const;
797
809 bool isContiguous() const;
810
831 bool isDistributed() const;
832
858
890
896
913
915
917
919 Teuchos::RCP<const Teuchos::Comm<int>> getComm() const;
920
922
924
926 std::string description() const;
927
949 void
950 describe(Teuchos::FancyOStream& out,
951 const Teuchos::EVerbosityLevel verbLevel =
952 Teuchos::Describable::verbLevel_default) const;
954
956
1005 Teuchos::RCP<const Map<local_ordinal_type, global_ordinal_type, Node>>
1006 removeEmptyProcesses() const;
1007
1035 Teuchos::RCP<const Map<local_ordinal_type, global_ordinal_type, Node>>
1036 replaceCommWithSubset(const Teuchos::RCP<const Teuchos::Comm<int>>& newComm) const;
1038
1039 private:
1044 std::string
1045 localDescribeToString(const Teuchos::EVerbosityLevel vl) const;
1046
1054 void setupDirectory() const;
1055
1070 bool checkIsDist() const;
1071
1080 initialNonuniformDebugCheck(
1081 const char errorMessagePrefix[],
1083 const size_t numLocalElements,
1085 const Teuchos::RCP<const Teuchos::Comm<int>>& comm) const;
1086
1087 void
1088 initWithNonownedHostIndexList(
1089 const char errorMessagePrefix[],
1091 const Kokkos::View<const global_ordinal_type*,
1092 Kokkos::LayoutLeft,
1093 Kokkos::HostSpace,
1094 Kokkos::MemoryUnmanaged>& entryList,
1096 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1097
1098 public:
1103 void lazyPushToHost() const;
1104
1105 private:
1107 Teuchos::RCP<const Teuchos::Comm<int>> comm_;
1108
1110 global_ordinal_type indexBase_;
1111
1114 global_size_t numGlobalElements_;
1115
1117 size_t numLocalElements_;
1118
1120 global_ordinal_type minMyGID_;
1121
1123 global_ordinal_type maxMyGID_;
1124
1127 global_ordinal_type minAllGID_;
1128
1131 global_ordinal_type maxAllGID_;
1132
1139 global_ordinal_type firstContiguousGID_;
1140
1154 global_ordinal_type lastContiguousGID_;
1155
1161 bool uniform_;
1162
1164 bool contiguous_;
1165
1174 bool distributed_;
1175
1205 mutable Kokkos::View<const global_ordinal_type*,
1206 Kokkos::LayoutLeft,
1208 lgMap_;
1209
1217#ifndef SWIG
1218 mutable Kokkos::View<const global_ordinal_type*,
1219 Kokkos::LayoutLeft,
1220 Kokkos::HostSpace>
1221 lgMapHost_;
1222#endif
1223
1227 global_to_local_table_type;
1228
1241 global_to_local_table_type glMap_;
1242
1245 global_ordinal_type, local_ordinal_type, Kokkos::HostSpace::device_type>
1246 global_to_local_table_host_type;
1247
1253 mutable global_to_local_table_host_type glMapHost_;
1254
1291 mutable Teuchos::RCP<
1292 Directory<
1294 directory_;
1295}; // Map class
1296
1310template <class LocalOrdinal, class GlobalOrdinal>
1311Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal>>
1313 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1314
1329template <class LocalOrdinal, class GlobalOrdinal, class Node>
1330Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
1332 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1333
1341template <class LocalOrdinal, class GlobalOrdinal>
1342Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal>>
1344 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1345
1352template <class LocalOrdinal, class GlobalOrdinal, class Node>
1353Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
1355 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1356
1363template <class LocalOrdinal, class GlobalOrdinal>
1364Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal>>
1366 const size_t localNumElements,
1367 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1368
1377template <class LocalOrdinal, class GlobalOrdinal, class Node>
1378Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
1380 const size_t localNumElements,
1381 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1382
1389template <class LocalOrdinal, class GlobalOrdinal>
1390Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal>>
1391createNonContigMap(const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
1392 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1393
1401template <class LocalOrdinal, class GlobalOrdinal, class Node>
1402Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
1403createNonContigMapWithNode(const Teuchos::ArrayView<const GlobalOrdinal>& elementList,
1404 const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
1405
1413
1418template <class LocalOrdinal, class GlobalOrdinal, class Node>
1419Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
1421
1427template <class LocalOrdinal, class GlobalOrdinal, class Node>
1428Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>>
1430 const ::Tpetra::Details::TieBreak<LocalOrdinal, GlobalOrdinal>& tie_break);
1431
1432} // namespace Tpetra
1433
1434#include "Tpetra_Directory_decl.hpp"
1435
1438template <class LocalOrdinal, class GlobalOrdinal, class Node>
1441
1444template <class LocalOrdinal, class GlobalOrdinal, class Node>
1447
1448#endif // TPETRA_MAP_DECL_HPP
Declaration and definition of the Tpetra::Map class, an implementation detail of Tpetra::Map.
Forward declaration of Tpetra::Directory.
Forward declaration of Tpetra::Map.
Forward declaration for Tpetra::TieBreak.
Struct that holds views of the contents of a CrsMatrix.
"Local" part of Map suitable for Kokkos kernels.
Implement mapping from global ID to process ID and local ID.
A parallel distribution of indices over processes.
Map & operator=(Map< local_ordinal_type, global_ordinal_type, node_type > &&)=default
Move assigment (shallow move).
Map & operator=(const Map< local_ordinal_type, global_ordinal_type, node_type > &)=default
Copy assigment (shallow copy).
Map(Map< local_ordinal_type, global_ordinal_type, node_type > &&)=default
Move constructor (shallow move).
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
bool isOneToOne() const
Whether the Map is one to one.
std::string description() const
Implementation of Teuchos::Describable.
Teuchos::ArrayView< const global_ordinal_type > getLocalElementList() const
Return a NONOWNING view of the global indices owned by this process.
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.
global_ordinal_type getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createUniformContigMap(const global_size_t numElements, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Non-member constructor for a uniformly distributed, contiguous Map with the default Kokkos Node.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal > > createNonContigMap(const Teuchos::ArrayView< const GlobalOrdinal > &elementList, const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Nonmember constructor for a non-contiguous Map using the default Kokkos::Device type.
global_ordinal_type getGlobalElement(local_ordinal_type localIndex) const
The global index corresponding to the given local index.
Node node_type
Legacy typedef that will go away at some point.
Map()
Default constructor (that does nothing).
GlobalOrdinal global_ordinal_type
The type of global indices.
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.
LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const global_ordinal_type > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< local_ordinal_type > &LIDList) const
Return the process ranks and corresponding local indices for the given global indices.
bool isNodeLocalElement(local_ordinal_type localIndex) const
Whether the given local index is valid for this Map on the calling process.
bool isUniform() const
Whether the range of global indices is uniform.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
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.
typename device_type::execution_space execution_space
The Kokkos execution space.
LocalOrdinal local_ordinal_type
The type of local indices.
Teuchos::RCP< const Map< local_ordinal_type, global_ordinal_type, Node > > removeEmptyProcesses() const
Advanced methods.
void lazyPushToHost() const
Push the device data to host, if needed.
global_ordinal_type getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
bool isCompatible(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is compatible with this Map.
global_ordinal_type getIndexBase() const
The index base for this Map.
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...
bool locallySameAs(const Map< local_ordinal_type, global_ordinal_type, node_type > &map) const
Is this Map locally the same as the input Map?
bool isLocallyFitted(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is locally fitted to this Map.
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.
virtual ~Map()
Destructor (virtual for memory safety of derived classes).
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,...
global_indices_array_device_type getMyGlobalIndicesDevice() const
Return a view of the global indices owned by this process on the Map's device.
global_ordinal_type getMinGlobalIndex() const
The minimum global index owned by the calling process.
local_ordinal_type getLocalElement(global_ordinal_type globalIndex) const
The local index corresponding to the given global index.
Teuchos::RCP< const Map< local_ordinal_type, global_ordinal_type, Node > > replaceCommWithSubset(const Teuchos::RCP< const Teuchos::Comm< int > > &newComm) const
Replace this Map's communicator with a subset communicator.
::Tpetra::Details::LocalMap< local_ordinal_type, global_ordinal_type, device_type > local_map_type
Type of the "local" Map.
global_ordinal_type getMaxGlobalIndex() const
The maximum global index owned by the calling process.
Map(const Map< local_ordinal_type, global_ordinal_type, node_type > &)=default
Copy constructor (shallow copy).
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.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
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 ...
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Describe this object in a human-readable way to the given output stream.
bool isNodeGlobalElement(global_ordinal_type globalIndex) const
Whether the given global index is owned by this Map on the calling process.
bool isSameAs(const Map< local_ordinal_type, global_ordinal_type, Node > &map) const
True if and only if map is identical to this Map.
local_ordinal_type getMinLocalIndex() const
The minimum local index.
size_t getLocalNumElements() const
The number of elements belonging to the calling process.
local_map_type getLocalMap() const
Get the LocalMap for Kokkos-Kernels.
global_indices_array_type getMyGlobalIndices() const
Return a view of the global indices owned by this process.
typename device_type::memory_space memory_space
The Kokkos memory space.
local_ordinal_type getMaxLocalIndex() const
The maximum local index on the calling process.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > createOneToOne(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &M, const ::Tpetra::Details::TieBreak< LocalOrdinal, GlobalOrdinal > &tie_break)
Creates a one-to-one version of the given Map where each GID lives on only one 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...
typename Node::device_type device_type
This class' Kokkos::Device specialization.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
size_t global_size_t
Global size_t object.
LocalGlobal
Enum for local versus global allocation of Map entries.