58 #include <Teuchos_Comm.hpp>
59 #include <Teuchos_DefaultComm.hpp>
60 #include <Teuchos_ArrayView.hpp>
61 #include <Teuchos_OrdinalTraits.hpp>
63 #include <Tpetra_CrsMatrix.hpp>
70 const RCP<
const Comm<int> > &comm)
72 int rank = comm->getRank();
73 int fail = 0, gfail = 0;
75 std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags = 0;
82 typedef Tpetra::CrsMatrix<zscalar_t, zlno_t, zgno_t>
tcrsMatrix_t;
91 zlno_t nLocalIds = M->getLocalNumRows();
92 zgno_t nGlobalIds = M->getGlobalNumRows();
94 ArrayView<const zgno_t> idList = M->getRowMap()->getLocalElementList();
95 std::set<zgno_t> idSet(idList.begin(), idList.end());
105 RCP<const adapter_t> ia = Teuchos::rcp(
new adapter_t(M));
108 RCP<const base_adapter_t> base_ia =
109 Teuchos::rcp_dynamic_cast<
const base_adapter_t>(ia);
113 base_ia, env, comm, modelFlags);
115 catch (std::exception &e){
116 std::cerr << rank <<
") " << e.what() << std::endl;
128 std::cerr << rank <<
") getLocalNumIdentifiers "
130 << nLocalIds << std::endl;
135 std::cerr << rank <<
") getGlobalNumIdentifiers "
137 << nGlobalIds << std::endl;
146 ArrayView<const zgno_t> gids;
147 ArrayView<input_t> wgts;
151 if (!fail && gids.size() != nLocalIds) {
152 std::cerr << rank <<
") getIdentifierList IDs "
153 << gids.size() <<
" "
154 << nLocalIds << std::endl;
158 if (!fail && wgts.size() != 0) {
159 std::cerr << rank <<
") getIdentifierList Weights "
160 << wgts.size() <<
" "
165 for (
zlno_t i=0; !fail && i < nLocalIds; i++){
166 std::set<zgno_t>::iterator next = idSet.find(gids[i]);
167 if (next == idSet.end()) {
168 std::cerr << rank <<
") getIdentifierList gid not found "
169 << gids[i] << std::endl;
174 Kokkos::View<const zgno_t*, typename tcrsMatrix_t::device_type> gidsKokkos;
175 Kokkos::View<zscalar_t **, typename tcrsMatrix_t::device_type> wgtsKokkos;
179 auto gidsKokkosHost = Kokkos::create_mirror_view(gidsKokkos);
180 Kokkos::deep_copy(gidsKokkosHost, gidsKokkos);
181 auto wgtsKokkosHost = Kokkos::create_mirror_view(wgtsKokkos);
182 Kokkos::deep_copy(wgtsKokkosHost, wgtsKokkos);
185 if (!fail && gidsKokkosHost.extent(0) !=
static_cast<size_t>(nLocalIds)) {
186 std::cerr << rank <<
") getIdentifierList IDs "
187 << gidsKokkosHost.extent(0) <<
" "
188 << nLocalIds << std::endl;
192 if (!fail && wgtsKokkosHost.extent(1) != 0) {
193 std::cerr << rank <<
") getIdentifierList Weights "
194 << wgtsKokkosHost.extent(1) <<
" "
199 for (
zlno_t i=0; !fail && i < nLocalIds; i++){
200 std::set<zgno_t>::iterator next = idSet.find(gidsKokkosHost(i));
201 if (next == idSet.end()) {
202 std::cerr << rank <<
") getIdentifierList gid not found "
203 << gidsKokkosHost(i) << std::endl;
218 int main(
int narg,
char *arg[])
220 Tpetra::ScopeGuard tscope(&narg, &arg);
221 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
223 int rank = comm->getRank();
225 string fname(
"simple");
233 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(".")