50 #include <Kokkos_Core.hpp> 
   51 #include <Teuchos_DefaultComm.hpp> 
   52 #include <Zoltan2_BasicKokkosIdentifierAdapter.hpp> 
   53 #include <Zoltan2_PartitioningProblem.hpp> 
   54 #include <Zoltan2_PartitioningSolution.hpp> 
   65 int main(
int narg, 
char *arg[]) {
 
   66   Tpetra::ScopeGuard tscope(&narg, &arg);
 
   67   Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
 
   69   int rank = comm->getRank();
 
   70   int nprocs = comm->getSize();
 
   74   typedef Tpetra::Map<> Map_t;
 
   75   typedef Map_t::local_ordinal_type localId_t;
 
   76   typedef Map_t::global_ordinal_type globalId_t;
 
   77   typedef Tpetra::Details::DefaultTypes::scalar_type scalar_t;
 
   78   typedef Tpetra::Map<>::node_type node_t;
 
   83   int localCount = 40 * (rank + 1);
 
   84   int totalCount = 20 * nprocs * (nprocs + 1);
 
   85   int targetCount = totalCount / nprocs;
 
   87   Kokkos::View<globalId_t*, typename node_t::device_type>
 
   88     globalIds(Kokkos::ViewAllocateWithoutInitializing(
"globalIds"), localCount);
 
   89   auto host_globalIds = Kokkos::create_mirror_view(globalIds);
 
   92     for (
int i = 0, num = 40; i < nprocs ; i++, num += 40) {
 
   93       std::cout << 
"Rank " << i << 
" generates " << num << 
" ids." << std::endl;
 
   97   globalId_t offset = 0;
 
   98   for (
int i = 1; i <= rank; i++) {
 
  102   for (
int i = 0; i < localCount; i++) {
 
  103     host_globalIds(i) = offset++;
 
  105   Kokkos::deep_copy(globalIds, host_globalIds);
 
  110   typedef Zoltan2::BasicUserTypes<scalar_t, localId_t, globalId_t> myTypes;
 
  111   typedef Zoltan2::BasicKokkosIdentifierAdapter<myTypes> inputAdapter_t;
 
  113   const int nWeights = 1;
 
  114   Kokkos::View<scalar_t **, typename node_t::device_type>
 
  115     weights(
"weights", localCount, nWeights);
 
  116   for (
int index = 0; index < localCount; index++) {
 
  117     weights(index, 0) = 1; 
 
  120   inputAdapter_t ia(globalIds, weights);
 
  125   Teuchos::ParameterList params(
"test params");
 
  126   params.set(
"debug_level", 
"basic_status");
 
  127   params.set(
"debug_procs", 
"0");
 
  128   params.set(
"error_check_level", 
"debug_mode_assertions");
 
  130   params.set(
"algorithm", 
"block");
 
  131   params.set(
"imbalance_tolerance", 1.1);
 
  132   params.set(
"num_global_parts", nprocs);
 
  137   Zoltan2::PartitioningProblem<inputAdapter_t> *problem =
 
  138       new Zoltan2::PartitioningProblem<inputAdapter_t>(&ia, ¶ms);
 
  149   Kokkos::View<const globalId_t *, typename node_t::device_type> ids;
 
  150   ia.getIDsKokkosView(ids);
 
  152   auto host_ids = Kokkos::create_mirror_view(ids);
 
  153   Kokkos::deep_copy(host_ids, ids);
 
  155   Kokkos::View<int*, Kokkos::HostSpace> partCounts(
"partCounts", nprocs);
 
  157   Kokkos::View<int*, Kokkos::HostSpace>
 
  158     globalPartCounts(
"globalPartCounts", nprocs);
 
  160   for (
size_t i = 0; i < ia.getLocalNumIDs(); i++) {
 
  161     int pp = problem->getSolution().getPartListView()[i];
 
  162     std::cout << rank << 
" LID " << i << 
" GID " << host_ids(i)
 
  163               << 
" PART " << pp << std::endl;
 
  167   Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_SUM, nprocs,
 
  168       partCounts.data(), globalPartCounts.data());
 
  172     for (
int i = 0; i < nprocs; i++) {
 
  173       if (globalPartCounts(i) != targetCount) {
 
  174         std::cout << 
"FAIL: part " << i << 
" has " << globalPartCounts(i)
 
  175                   << 
" != " << targetCount << 
"; " << ++ierr << 
" errors" 
  180       std::cout << 
"PASS" << std::endl;
 
int main(int argc, char *argv[])