50 #include <Kokkos_Core.hpp>
51 #include <Teuchos_DefaultComm.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;
82 int localCount = 40 * (rank + 1);
83 int totalCount = 20 * nprocs * (nprocs + 1);
84 int targetCount = totalCount / nprocs;
85 Kokkos::View<globalId_t*> globalIds(
"globalIds", localCount);
88 for (
int i = 0, num = 40; i < nprocs ; i++, num += 40) {
89 std::cout <<
"Rank " << i <<
" generates " << num <<
" ids." << std::endl;
93 globalId_t offset = 0;
94 for (
int i = 1; i <= rank; i++) {
98 for (
int i = 0; i < localCount; i++) {
99 globalIds(i) = offset++;
109 const int nWeights = 1;
110 Kokkos::View<scalar_t **, Layout>
weights(
"weights", localCount, nWeights);
111 for (
int index = 0; index < localCount; index++) {
115 inputAdapter_t ia(globalIds, weights);
120 Teuchos::ParameterList params(
"test params");
121 params.set(
"debug_level",
"basic_status");
122 params.set(
"debug_procs",
"0");
123 params.set(
"error_check_level",
"debug_mode_assertions");
125 params.set(
"algorithm",
"block");
126 params.set(
"imbalance_tolerance", 1.1);
127 params.set(
"num_global_parts", nprocs);
144 Kokkos::View<globalId_t *> ids;
145 ia.getIDsKokkosView(ids);
147 Kokkos::View<int*> partCounts(
"partCounts", nprocs);
149 Kokkos::View<int*> globalPartCounts(
"globalPartCounts", nprocs);
151 for (
size_t i = 0; i < ia.getLocalNumIDs(); i++) {
152 int pp = problem->
getSolution().getPartListView()[i];
153 std::cout << rank <<
" LID " << i <<
" GID " << ids(i)
154 <<
" PART " << pp << std::endl;
158 Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_SUM, nprocs,
159 &partCounts(0), &globalPartCounts(0));
163 for (
int i = 0; i < nprocs; i++) {
164 if (globalPartCounts(i) != targetCount) {
165 std::cout <<
"FAIL: part " << i <<
" has " << globalPartCounts(i)
166 <<
" != " << targetCount <<
"; " << ++ierr <<
" errors"
171 std::cout <<
"PASS" << std::endl;
int main(int narg, char *arg[])
A simple class that can be the User template argument for an InputAdapter.
Defines the PartitioningSolution class.
This class represents a collection of global Identifiers and their associated weights, if any.
Defines the BasicKokkosIdentifierAdapter class.
const PartitioningSolution< Adapter > & getSolution()
Get the solution to the problem.
PartitioningProblem sets up partitioning problems for the user.
Defines the PartitioningProblem class.
Kokkos::LayoutLeft weight_layout_t
void solve(bool updateInputData=true)
Direct the problem to create a solution.