8 #include "Teuchos_DefaultComm.hpp"
9 #include "Teuchos_RCP.hpp"
10 #include "Teuchos_ArrayRCP.hpp"
11 #include "Tpetra_Map.hpp"
17 typedef map_t::local_ordinal_type
lno_t;
18 typedef map_t::global_ordinal_type
gno_t;
24 int me = myMap.getComm()->getRank();
28 std::cout << me <<
" " << myName <<
" MINE: ";
29 for (
size_t i = 0; i < myMap.getLocalNumElements(); i++)
30 std::cout << myMap.getGlobalElement(i) <<
" ";
31 std::cout << std::endl;
35 Teuchos::ArrayRCP<gno_t> searchGids = arcp(
new gno_t[nSearch],
37 Teuchos::ArrayRCP<int> searchRemoteRanks = arcp(
new int[nSearch],
39 Teuchos::ArrayRCP<lno_t> searchRemoteLids = arcp(
new lno_t[nSearch],
43 for (
size_t i = 0; i < nSearch; i++) searchGids[i] = i;
44 myMap.getRemoteIndexList(searchGids(),
45 searchRemoteRanks(), searchRemoteLids());
47 for (
size_t i = 0; i < nSearch; i++) {
48 std::cout << me <<
" " << myName
49 <<
" NoDuplicates: GID " << searchGids[i]
50 <<
" RANK " << searchRemoteRanks[i]
51 <<
" LID " << searchRemoteLids[i]
52 << (searchRemoteRanks[i] == -1 ?
" BAD!" :
" ")
54 if (searchRemoteRanks[i] == -1) nFail++;
58 for (
size_t i = 0; i < nSearch; i++) searchGids[i] = i/2;
59 myMap.getRemoteIndexList(searchGids(),
60 searchRemoteRanks(), searchRemoteLids());
62 for (
size_t i = 0; i < nSearch; i++) {
63 std::cout << me <<
" " << myName
64 <<
" WithDuplicates: GID " << searchGids[i]
65 <<
" RANK " << searchRemoteRanks[i]
66 <<
" LID " << searchRemoteLids[i]
67 << (searchRemoteRanks[i] == -1 ?
" BAD!" :
" ")
69 if (searchRemoteRanks[i] == -1) nFail++;
78 int main(
int narg,
char **arg)
80 Tpetra::ScopeGuard tscope(&narg, &arg);
81 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
83 int me = comm->getRank();
84 int np = comm->getSize();
90 const map_t defaultMap(nGlobal, 0, comm);
92 nFail +=
searchIt(defaultMap,
"defaultMap");
96 lno_t nLocal = nGlobal / np + (me < (nGlobal%np));
97 gno_t myFirst = me * (nGlobal / np) + (me < (nGlobal%np) ? me : (nGlobal%np));
98 Teuchos::ArrayRCP<gno_t> myGids = arcp(
new gno_t[nLocal], 0, nLocal,
true);
99 for (
lno_t i = 0; i < nLocal; i++)
100 myGids[i] = myFirst + i;
103 gno_t dummy = Teuchos::OrdinalTraits<gno_t>::invalid();
104 const map_t customMap(dummy, myGids(), 0, comm);
106 nFail +=
searchIt(customMap,
"customMap");
108 if (nFail) std::cout <<
"FAIL" << std::endl;
109 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)