48 #include <Kokkos_Core.hpp>
49 #include <Teuchos_DefaultComm.hpp>
50 #include <Teuchos_RCP.hpp>
51 #include <Teuchos_CommHelpers.hpp>
55 int main(
int narg,
char *arg[]) {
57 Tpetra::ScopeGuard tscope(&narg, &arg);
58 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
62 int rank = comm->getRank();
63 int nprocs = comm->getSize();
64 int fail = 0, gfail = 0;
68 const int nWeights = 2;
70 Kokkos::View<zgno_t *, typename znode_t::device_type>
71 myIds(Kokkos::ViewAllocateWithoutInitializing(
"myIds"), numLocalIds);
72 zgno_t myFirstId = rank * numLocalIds * numLocalIds;
73 Kokkos::View<zscalar_t **, typename znode_t::device_type>
74 weights(Kokkos::ViewAllocateWithoutInitializing(
"weights"),
75 numLocalIds, nWeights);
78 Kokkos::RangePolicy<
typename znode_t::execution_space,
80 myIds(i) =
zgno_t(myFirstId + i);
82 weights(i, 1) = (nprocs - rank) / (i + 1);
87 if (!fail && ia.getLocalNumIDs() != size_t(numLocalIds)) {
90 if (!fail && ia.getNumWeightsPerID() != nWeights) {
94 Kokkos::View<const zgno_t *, typename znode_t::device_type> globalIdsIn;
95 Kokkos::View<zscalar_t **, typename znode_t::device_type> weightsIn;
97 ia.getIDsKokkosView(globalIdsIn);
99 ia.getWeightsKokkosView(weightsIn);
101 auto host_globalIdsIn = Kokkos::create_mirror_view(globalIdsIn);
102 Kokkos::deep_copy(host_globalIdsIn, globalIdsIn);
103 auto host_weightsIn = Kokkos::create_mirror_view(weightsIn);
104 Kokkos::deep_copy(host_weightsIn, weightsIn);
105 auto host_weights = Kokkos::create_mirror_view(weights);
106 Kokkos::deep_copy(host_weights, weights);
108 auto host_w0 = Kokkos::subview(host_weightsIn, Kokkos::ALL, 0);
109 auto host_w1 = Kokkos::subview(host_weightsIn, Kokkos::ALL, 1);
111 for (
zlno_t i = 0; !fail && i < numLocalIds; i++){
112 if (host_globalIdsIn(i) !=
zgno_t(myFirstId + i)) {
115 if (!fail && host_w0(i) != 1.0) {
118 if (!fail && host_w1(i) != host_weights(i, 1)) {
128 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