56 #include <Tpetra_Map.hpp>
66 template <
typename A,
typename B>
70 for (
size_t i = 0; i < n; i++) a[i] = b[i];
73 template <
typename A,
typename B>
80 template <
typename A,
typename B>
86 template <
typename A,
typename B>
94 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
95 Teuchos::ParameterList ¶ms,
102 typedef Tpetra::Map<>::node_type myNode_t;
109 myScalar_t *sx = coords;
110 myScalar_t *sy = sx + localCount;
111 myScalar_t *sz = sy + localCount;
113 inputAdapter_t *ia =
new inputAdapter_t(localCount,globalIds,sx,sy,sz,1,1,1);
120 quality_t *metricObject =
new quality_t(ia, ¶ms, comm,
122 if (comm->getRank() == 0){
128 std::cout <<
"no weights -- balance satisfied: " << imb << std::endl;
130 std::cout <<
"no weights -- balance failure: " << imb << std::endl;
133 std::cout << std::endl;
143 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
144 Teuchos::ParameterList ¶ms,
152 typedef Tpetra::Map<>::node_type myNode_t;
159 std::vector<const myScalar_t *> coordVec(3);
160 std::vector<int> coordStrides(3);
162 coordVec[0] = coords; coordStrides[0] = 1;
163 coordVec[1] = coords + localCount; coordStrides[1] = 1;
164 coordVec[2] = coords + localCount + localCount; coordStrides[2] = 1;
166 std::vector<const myScalar_t *> weightVec(1);
167 std::vector<int> weightStrides(1);
169 weightVec[0] =
weights; weightStrides[0] = 1;
171 inputAdapter_t *ia=
new inputAdapter_t(localCount, globalIds, coordVec,
172 coordStrides,weightVec,weightStrides);
179 quality_t *metricObject =
new quality_t(ia, ¶ms, comm,
181 if (comm->getRank() == 0){
187 std::cout <<
"weighted -- balance satisfied " << imb << std::endl;
189 std::cout <<
"weighted -- balance failed " << imb << std::endl;
192 std::cout << std::endl;
201 int main(
int narg,
char *arg[])
203 Tpetra::ScopeGuard scope(&narg, &arg);
204 const Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
205 int me = comm->getRank();
206 int np = comm->getSize();
212 Teuchos::ParameterList params(
"test params");
213 params.set(
"debug_level",
"basic_status");
214 params.set(
"error_check_level",
"debug_mode_assertions");
216 params.set(
"algorithm",
"multijagged");
217 params.set(
"num_global_parts", 64);
222 const size_t N = 9000000;
223 size_t maxLocalCount = N / np;
230 for (
size_t i=0; i < maxLocalCount*dim; i++)
235 for (
size_t i=0; i < maxLocalCount; i++)
241 size_t localCount = N / np;
245 for (
size_t i=0; i < localCount; i++)
246 globalIds[i] = offset++;
249 std::cout <<
"---------------------------------------------" << std::endl;
250 std::cout <<
"myGlobalId_t = " <<
typeid(offset).name()
251 <<
" " <<
sizeof(offset)
252 <<
"; localCount = " << localCount
253 <<
"; globalCount = " << np * localCount << std::endl;
258 if (me == 0) std::cout <<
"Test: no weights, scalar = double" << std::endl;
263 if (me == 0) std::cout <<
"Test: weights, scalar = double" << std::endl;
264 test_weights(comm, params, localCount, globalIds, coords, weights, nFail);
268 Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 1, &nFail, &gnFail);
275 if (nFail == 0) std::cout <<
"PASS" << std::endl;
276 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.