17 #include "Teuchos_DefaultComm.hpp"
18 #include "Teuchos_RCP.hpp"
19 #include "Teuchos_ArrayRCP.hpp"
20 #include "Tpetra_Map.hpp"
26 typedef map_t::local_ordinal_type
lno_t;
27 typedef map_t::global_ordinal_type
gno_t;
33 int me = myMap.getComm()->getRank();
37 std::cout << me <<
" " << myName <<
" MINE: ";
38 for (
size_t i = 0; i < myMap.getLocalNumElements(); i++)
39 std::cout << myMap.getGlobalElement(i) <<
" ";
40 std::cout << std::endl;
44 Teuchos::ArrayRCP<gno_t> searchGids = arcp(
new gno_t[nSearch],
46 Teuchos::ArrayRCP<int> searchRemoteRanks = arcp(
new int[nSearch],
48 Teuchos::ArrayRCP<lno_t> searchRemoteLids = arcp(
new lno_t[nSearch],
52 for (
size_t i = 0; i < nSearch; i++) searchGids[i] = i;
53 myMap.getRemoteIndexList(searchGids(),
54 searchRemoteRanks(), searchRemoteLids());
56 for (
size_t i = 0; i < nSearch; i++) {
57 std::cout << me <<
" " << myName
58 <<
" NoDuplicates: GID " << searchGids[i]
59 <<
" RANK " << searchRemoteRanks[i]
60 <<
" LID " << searchRemoteLids[i]
61 << (searchRemoteRanks[i] == -1 ?
" BAD!" :
" ")
63 if (searchRemoteRanks[i] == -1) nFail++;
67 for (
size_t i = 0; i < nSearch; i++) searchGids[i] = i/2;
68 myMap.getRemoteIndexList(searchGids(),
69 searchRemoteRanks(), searchRemoteLids());
71 for (
size_t i = 0; i < nSearch; i++) {
72 std::cout << me <<
" " << myName
73 <<
" WithDuplicates: GID " << searchGids[i]
74 <<
" RANK " << searchRemoteRanks[i]
75 <<
" LID " << searchRemoteLids[i]
76 << (searchRemoteRanks[i] == -1 ?
" BAD!" :
" ")
78 if (searchRemoteRanks[i] == -1) nFail++;
87 int main(
int narg,
char **arg)
89 Tpetra::ScopeGuard tscope(&narg, &arg);
90 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
92 int me = comm->getRank();
93 int np = comm->getSize();
99 const map_t defaultMap(nGlobal, 0, comm);
101 nFail +=
searchIt(defaultMap,
"defaultMap");
105 lno_t nLocal = nGlobal / np + (me < (nGlobal%np));
106 gno_t myFirst = me * (nGlobal / np) + (me < (nGlobal%np) ? me : (nGlobal%np));
107 Teuchos::ArrayRCP<gno_t> myGids = arcp(
new gno_t[nLocal], 0, nLocal,
true);
108 for (
lno_t i = 0; i < nLocal; i++)
109 myGids[i] = myFirst + i;
112 gno_t dummy = Teuchos::OrdinalTraits<gno_t>::invalid();
113 const map_t customMap(dummy, myGids(), 0, comm);
115 nFail +=
searchIt(customMap,
"customMap");
117 if (nFail) std::cout <<
"FAIL" << std::endl;
118 else std::cout <<
"PASS" << std::endl;
map_t::global_ordinal_type gno_t
int main(int narg, char **arg)
map_t::local_ordinal_type lno_t
int searchIt(const map_t &myMap, const std::string &myName)