23 #include <Teuchos_Comm.hpp>
24 #include <Teuchos_DefaultComm.hpp>
25 #include <Teuchos_ArrayView.hpp>
26 #include <Teuchos_OrdinalTraits.hpp>
28 #include <Tpetra_CrsMatrix.hpp>
35 const RCP<
const Comm<int> > &comm)
37 int rank = comm->getRank();
38 int fail = 0, gfail = 0;
40 std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags = 0;
47 typedef Tpetra::CrsMatrix<zscalar_t, zlno_t, zgno_t>
tcrsMatrix_t;
56 zlno_t nLocalIds = M->getLocalNumRows();
57 zgno_t nGlobalIds = M->getGlobalNumRows();
59 ArrayView<const zgno_t> idList = M->getRowMap()->getLocalElementList();
60 std::set<zgno_t> idSet(idList.begin(), idList.end());
70 RCP<const adapter_t> ia = Teuchos::rcp(
new adapter_t(M));
73 RCP<const base_adapter_t> base_ia =
74 Teuchos::rcp_dynamic_cast<
const base_adapter_t>(ia);
78 base_ia, env, comm, modelFlags);
80 catch (std::exception &e){
81 std::cerr << rank <<
") " << e.what() << std::endl;
93 std::cerr << rank <<
") getLocalNumIdentifiers "
95 << nLocalIds << std::endl;
100 std::cerr << rank <<
") getGlobalNumIdentifiers "
102 << nGlobalIds << std::endl;
111 ArrayView<const zgno_t> gids;
112 ArrayView<input_t> wgts;
116 if (!fail && gids.size() != nLocalIds) {
117 std::cerr << rank <<
") getIdentifierList IDs "
118 << gids.size() <<
" "
119 << nLocalIds << std::endl;
123 if (!fail && wgts.size() != 0) {
124 std::cerr << rank <<
") getIdentifierList Weights "
125 << wgts.size() <<
" "
130 for (
zlno_t i=0; !fail && i < nLocalIds; i++){
131 std::set<zgno_t>::iterator next = idSet.find(gids[i]);
132 if (next == idSet.end()) {
133 std::cerr << rank <<
") getIdentifierList gid not found "
134 << gids[i] << std::endl;
139 Kokkos::View<const zgno_t*, typename tcrsMatrix_t::device_type> gidsKokkos;
140 Kokkos::View<zscalar_t **, typename tcrsMatrix_t::device_type> wgtsKokkos;
144 auto gidsKokkosHost = Kokkos::create_mirror_view(gidsKokkos);
145 Kokkos::deep_copy(gidsKokkosHost, gidsKokkos);
146 auto wgtsKokkosHost = Kokkos::create_mirror_view(wgtsKokkos);
147 Kokkos::deep_copy(wgtsKokkosHost, wgtsKokkos);
150 if (!fail && gidsKokkosHost.extent(0) !=
static_cast<size_t>(nLocalIds)) {
151 std::cerr << rank <<
") getIdentifierList IDs "
152 << gidsKokkosHost.extent(0) <<
" "
153 << nLocalIds << std::endl;
157 if (!fail && wgtsKokkosHost.extent(1) != 0) {
158 std::cerr << rank <<
") getIdentifierList Weights "
159 << wgtsKokkosHost.extent(1) <<
" "
164 for (
zlno_t i=0; !fail && i < nLocalIds; i++){
165 std::set<zgno_t>::iterator next = idSet.find(gidsKokkosHost(i));
166 if (next == idSet.end()) {
167 std::cerr << rank <<
") getIdentifierList gid not found "
168 << gidsKokkosHost(i) << std::endl;
183 int main(
int narg,
char *arg[])
185 Tpetra::ScopeGuard tscope(&narg, &arg);
186 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
188 int rank = comm->getRank();
190 string fname(
"simple");
198 if (rank==0) std::cout <<
"PASS" << std::endl;
void printFailureCode(const Comm< int > &comm, int fail)
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
MatrixAdapter defines the adapter interface for matrices.
Provides access for Zoltan2 to Xpetra::CrsMatrix data.
int main(int narg, char **arg)
common code used by tests
Defines the XpetraCrsMatrixAdapter class.
Defines the IdentifierModel interface.
void testIdentifierModel(std::string fname, zgno_t xdim, zgno_t ydim, zgno_t zdim, const RCP< const Comm< int > > &comm)
The StridedData class manages lists of weights or coordinates.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
Tpetra::Map::local_ordinal_type zlno_t
static const std::string fail
Tpetra::CrsMatrix< zscalar_t, zlno_t, zgno_t, znode_t > tcrsMatrix_t
size_t getIdentifierListKokkos(Kokkos::View< const gno_t *, typename node_t::device_type > &Ids, Kokkos::View< scalar_t **, typename node_t::device_type > &wgts) const
Defines the BasicIdentifierAdapter class.
int globalFail(const Comm< int > &comm, int fail)
size_t getLocalNumIdentifiers() const
IdentifierModel defines the interface for all identifier models.
global_size_t getGlobalNumIdentifiers() const
Tpetra::Map::global_ordinal_type zgno_t
size_t getIdentifierList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
std::string testDataFilePath(".")