13 #include <Kokkos_Core.hpp>
14 #include <Teuchos_DefaultComm.hpp>
15 #include <Teuchos_RCP.hpp>
16 #include <Teuchos_CommHelpers.hpp>
20 int main(
int narg,
char *arg[]) {
22 Tpetra::ScopeGuard tscope(&narg, &arg);
23 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
27 int rank = comm->getRank();
28 int nprocs = comm->getSize();
29 int fail = 0, gfail = 0;
33 const int nWeights = 2;
35 Kokkos::View<zgno_t *, typename znode_t::device_type>
36 myIds(Kokkos::ViewAllocateWithoutInitializing(
"myIds"), numLocalIds);
37 zgno_t myFirstId = rank * numLocalIds * numLocalIds;
38 Kokkos::View<zscalar_t **, typename znode_t::device_type>
39 weights(Kokkos::ViewAllocateWithoutInitializing(
"weights"),
40 numLocalIds, nWeights);
43 Kokkos::RangePolicy<
typename znode_t::execution_space,
45 myIds(i) =
zgno_t(myFirstId + i);
47 weights(i, 1) = (nprocs - rank) / (i + 1);
52 if (!fail && ia.getLocalNumIDs() != size_t(numLocalIds)) {
55 if (!fail && ia.getNumWeightsPerID() != nWeights) {
59 Kokkos::View<const zgno_t *, typename znode_t::device_type> globalIdsIn;
60 Kokkos::View<zscalar_t **, typename znode_t::device_type> weightsIn;
62 ia.getIDsKokkosView(globalIdsIn);
64 ia.getWeightsKokkosView(weightsIn);
66 auto host_globalIdsIn = Kokkos::create_mirror_view(globalIdsIn);
67 Kokkos::deep_copy(host_globalIdsIn, globalIdsIn);
68 auto host_weightsIn = Kokkos::create_mirror_view(weightsIn);
69 Kokkos::deep_copy(host_weightsIn, weightsIn);
70 auto host_weights = Kokkos::create_mirror_view(weights);
71 Kokkos::deep_copy(host_weights, weights);
73 auto host_w0 = Kokkos::subview(host_weightsIn, Kokkos::ALL, 0);
74 auto host_w1 = Kokkos::subview(host_weightsIn, Kokkos::ALL, 1);
76 for (
zlno_t i = 0; !fail && i < numLocalIds; i++){
77 if (host_globalIdsIn(i) !=
zgno_t(myFirstId + i)) {
80 if (!fail && host_w0(i) != 1.0) {
83 if (!fail && host_w1(i) != host_weights(i, 1)) {
93 std::cout <<
"PASS" << std::endl;
void printFailureCode(const Comm< int > &comm, int fail)
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > userTypes_t
int main(int narg, char **arg)
common code used by tests
This class represents a collection of global Identifiers and their associated weights, if any.
Defines the BasicKokkosIdentifierAdapter class.
Tpetra::Map::local_ordinal_type zlno_t
static const std::string fail
int globalFail(const Comm< int > &comm, int fail)
Tpetra::Map::global_ordinal_type zgno_t