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,
110 inputAdapter_t *ia =
new inputAdapter_t(localCount,globalIds,sx,sy,sz,1,1,1);
117 quality_t *metricObject =
new quality_t(ia, ¶ms, comm,
119 if (comm->getRank() == 0){
121 metricObject->printMetrics(std::cout);
123 double imb = metricObject->getObjectCountImbalance();
125 std::cout <<
"no weights -- balance satisfied: " << imb << std::endl;
127 std::cout <<
"no weights -- balance failure: " << imb << std::endl;
130 std::cout << std::endl;
140 const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
141 Teuchos::ParameterList ¶ms,
153 std::vector<const myScalar_t *> coordVec(3);
154 std::vector<int> coordStrides(3);
156 coordVec[0] = coords; coordStrides[0] = 1;
157 coordVec[1] = coords + localCount; coordStrides[1] = 1;
158 coordVec[2] = coords + localCount + localCount; coordStrides[2] = 1;
160 std::vector<const myScalar_t *> weightVec(1);
161 std::vector<int> weightStrides(1);
163 weightVec[0] =
weights; weightStrides[0] = 1;
165 inputAdapter_t *ia=
new inputAdapter_t(localCount, globalIds, coordVec,
166 coordStrides,weightVec,weightStrides);
173 quality_t *metricObject =
new quality_t(ia, ¶ms, comm,
175 if (comm->getRank() == 0){
177 metricObject->printMetrics(std::cout);
179 double imb = metricObject->getWeightImbalance(0);
181 std::cout <<
"weighted -- balance satisfied " << imb << std::endl;
183 std::cout <<
"weighted -- balance failed " << imb << std::endl;
186 std::cout << std::endl;
195 int main(
int narg,
char *arg[])
197 Tpetra::ScopeGuard scope(&narg, &arg);
198 const Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
199 int me = comm->getRank();
200 int np = comm->getSize();
206 Teuchos::ParameterList params(
"test params");
207 params.set(
"debug_level",
"basic_status");
208 params.set(
"error_check_level",
"debug_mode_assertions");
210 params.set(
"algorithm",
"multijagged");
211 params.set(
"num_global_parts", 64);
216 const size_t minN = 9000000;
217 const size_t maxN = 16000000;
218 const size_t incN = 2000000;
219 size_t maxLocalCount = maxN / np;
226 for (
size_t i=0; i < maxLocalCount*dim; i++)
231 for (
size_t i=0; i < maxLocalCount; i++)
237 for (
size_t N = minN; N < maxN; N += incN) {
239 size_t localCount = N / np;
243 for (
size_t i=0; i < localCount; i++)
244 globalIds[i] = offset++;
247 std::cout <<
"---------------------------------------------" << std::endl;
248 std::cout <<
"myGlobalId_t = " <<
typeid(offset).name()
249 <<
" " <<
sizeof(offset)
250 <<
"; localCount = " << localCount
251 <<
"; globalCount = " << np * localCount << std::endl;
256 if (me == 0) std::cout <<
"Test: no weights, scalar = double" << std::endl;
261 if (me == 0) std::cout <<
"Test: weights, scalar = double" << std::endl;
262 test_weights(comm, params, localCount, globalIds, coords, weights, nFail);
266 Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 1, &nFail, &gnFail);
267 if (gnFail > 0)
break;
276 if (nFail == 0) std::cout <<
"PASS" << std::endl;
277 else std::cout <<
"FAIL: " << nFail <<
" tests failed" << std::endl;
myMap_t::local_ordinal_type myLocalId_t
int main(int narg, char *arg[])
A simple class that can be the User template argument for an InputAdapter.
Defines the PartitioningSolution class.
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.