20 #include <Tpetra_Map.hpp>
30 template <
typename A,
typename B>
34 for (
size_t i = 0; i < n; i++) a[i] = b[i];
37 template <
typename A,
typename B>
44 template <
typename A,
typename B>
50 template <
typename A,
typename B>
58 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
59 Teuchos::ParameterList ¶ms,
66 typedef Tpetra::Map<>::node_type myNode_t;
73 myScalar_t *sx = coords;
74 myScalar_t *sy = sx + localCount;
75 myScalar_t *sz = sy + localCount;
77 inputAdapter_t *ia =
new inputAdapter_t(localCount,globalIds,sx,sy,sz,1,1,1);
84 quality_t *metricObject =
new quality_t(ia, ¶ms, comm,
86 if (comm->getRank() == 0){
92 std::cout <<
"no weights -- balance satisfied: " << imb << std::endl;
94 std::cout <<
"no weights -- balance failure: " << imb << std::endl;
97 std::cout << std::endl;
107 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
108 Teuchos::ParameterList ¶ms,
116 typedef Tpetra::Map<>::node_type myNode_t;
123 std::vector<const myScalar_t *> coordVec(3);
124 std::vector<int> coordStrides(3);
126 coordVec[0] = coords; coordStrides[0] = 1;
127 coordVec[1] = coords + localCount; coordStrides[1] = 1;
128 coordVec[2] = coords + localCount + localCount; coordStrides[2] = 1;
130 std::vector<const myScalar_t *> weightVec(1);
131 std::vector<int> weightStrides(1);
133 weightVec[0] =
weights; weightStrides[0] = 1;
135 inputAdapter_t *ia=
new inputAdapter_t(localCount, globalIds, coordVec,
136 coordStrides,weightVec,weightStrides);
143 quality_t *metricObject =
new quality_t(ia, ¶ms, comm,
145 if (comm->getRank() == 0){
151 std::cout <<
"weighted -- balance satisfied " << imb << std::endl;
153 std::cout <<
"weighted -- balance failed " << imb << std::endl;
156 std::cout << std::endl;
165 int main(
int narg,
char *arg[])
167 Tpetra::ScopeGuard scope(&narg, &arg);
168 const Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
169 int me = comm->getRank();
170 int np = comm->getSize();
176 Teuchos::ParameterList params(
"test params");
177 params.set(
"debug_level",
"basic_status");
178 params.set(
"error_check_level",
"debug_mode_assertions");
180 params.set(
"algorithm",
"multijagged");
181 params.set(
"num_global_parts", 64);
186 const size_t N = 9000000;
187 size_t maxLocalCount = N / np;
194 for (
size_t i=0; i < maxLocalCount*dim; i++)
199 for (
size_t i=0; i < maxLocalCount; i++)
205 size_t localCount = N / np;
209 for (
size_t i=0; i < localCount; i++)
210 globalIds[i] = offset++;
213 std::cout <<
"---------------------------------------------" << std::endl;
214 std::cout <<
"myGlobalId_t = " <<
typeid(offset).name()
215 <<
" " <<
sizeof(offset)
216 <<
"; localCount = " << localCount
217 <<
"; globalCount = " << np * localCount << std::endl;
222 if (me == 0) std::cout <<
"Test: no weights, scalar = double" << std::endl;
227 if (me == 0) std::cout <<
"Test: weights, scalar = double" << std::endl;
228 test_weights(comm, params, localCount, globalIds, coords, weights, nFail);
232 Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 1, &nFail, &gnFail);
239 if (nFail == 0) std::cout <<
"PASS" << std::endl;
240 else std::cout <<
"FAIL: " << nFail <<
" tests failed" << std::endl;
void printMetrics(std::ostream &os) const
Print all metrics.
myMap_t::local_ordinal_type myLocalId_t
A simple class that can be the User template argument for an InputAdapter.
Zoltan2::EvaluatePartition< matrixAdapter_t > quality_t
int main(int narg, char **arg)
Defines the PartitioningSolution class.
scalar_t getWeightImbalance(int weightIndex) const
Return the imbalance for the requested weight.
void test_no_weights(const Teuchos::RCP< const Teuchos::Comm< int > > &comm, Teuchos::ParameterList ¶ms, size_t localCount, myGlobalId_t *globalIds, myScalar_t *coords, int &nFail)
void test_weights(const Teuchos::RCP< const Teuchos::Comm< int > > &comm, Teuchos::ParameterList ¶ms, size_t localCount, myGlobalId_t *globalIds, myScalar_t *coords, myScalar_t *weights, int &nFail)
void copyArrays(size_t n, A *&a, B *b)
myMap_t::global_ordinal_type myGlobalId_t
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
void freeArrays(A *&a, B *b)
const PartitioningSolution< Adapter > & getSolution()
Get the solution to the problem.
PartitioningProblem sets up partitioning problems for the user.
Defines the PartitioningProblem class.
A class that computes and returns quality metrics.
Defines the BasicVectorAdapter class.
void solve(bool updateInputData=true)
Direct the problem to create a solution.
scalar_t getObjectCountImbalance() const
Return the object count imbalance.