223 const ParameterList &problem_parameters,
224 bool bHasComparisons,
225 RCP<ComparisonHelper> & comparison_helper,
226 const RCP<
const Teuchos::Comm<int> > & comm)
235 int rank = comm->getRank();
236 if(!problem_parameters.isParameter(
"kind"))
239 std::cout <<
"Problem kind not provided" << std::endl;
243 if(!problem_parameters.isParameter(
"InputAdapterParameters"))
246 std::cout <<
"Input adapter parameters not provided" << std::endl;
250 if(!problem_parameters.isParameter(
"Zoltan2Parameters"))
253 std::cout <<
"Zoltan2 problem parameters not provided" << std::endl;
259 std::cout <<
"\n\nRunning test: " << problem_parameters.name() << std::endl;
267 comparison_helper->AddSource(problem_parameters.name(), comparison_source);
268 comparison_source->addTimer(
"adapter construction time");
269 comparison_source->addTimer(
"problem construction time");
270 comparison_source->addTimer(
"solve time");
275 const ParameterList &adapterPlist =
276 problem_parameters.sublist(
"InputAdapterParameters");
277 comparison_source->timers[
"adapter construction time"]->start();
283 comparison_source->timers[
"adapter construction time"]->stop();
285 comparison_source->adapterFactory = adapterFactory;
291 string adapter_name = adapterPlist.get<
string>(
"input adapter");
293 ParameterList zoltan2_parameters =
294 const_cast<ParameterList &
>(problem_parameters.sublist(
"Zoltan2Parameters"));
296 std::cout << std::endl;
299 comparison_source->timers[
"problem construction time"]->start();
300 std::string problem_kind = problem_parameters.get<std::string>(
"kind");
302 std::cout <<
"Creating a new " << problem_kind <<
" problem." << std::endl;
309 #ifdef HAVE_ZOLTAN2_MPI
315 std::cout <<
"Using input adapter type: " + adapter_name << std::endl;
318 comparison_source->problemFactory = problemFactory;
323 comparison_source->timers[
"solve time"]->start();
325 problemFactory->getProblem()->solve();
327 comparison_source->timers[
"solve time"]->stop();
329 std::cout << problem_kind +
" problem solved." << std::endl;
334 if(problem_kind ==
"partitioning") {
338 i < adapterFactory->getMainAdapter()->getLocalNumIDs(); i++) {
339 std::cout << rank <<
" LID " << i
340 <<
" GID " << kddIDs[i]
346 if (adapter_name ==
"XpetraCrsGraph") {
351 dynamic_cast<const xCG_xCG_t *
>(adapterFactory->getMainAdapter());
354 lno_t localNumObj = xscrsGraphAdapter->getLocalNumVertices();
355 const gno_t *vertexIds;
356 xscrsGraphAdapter->getVertexIDsView(vertexIds);
357 const offset_t *offsets;
359 xscrsGraphAdapter->getEdgesView(offsets, adjIds);
360 for (
int edim = 0; edim < ewgtDim; edim++) {
363 xscrsGraphAdapter->getEdgeWeightsView(
weights, stride, edim);
364 for (
lno_t i=0; i < localNumObj; i++)
365 for (offset_t j=offsets[i]; j < offsets[i+1]; j++)
366 std::cout << edim <<
" " << vertexIds[i] <<
" "
367 << adjIds[j] <<
" " <<
weights[stride*j] << std::endl;
375 bool bSuccess =
true;
376 if(problem_parameters.isSublist(
"Metrics") || bHasComparisons) {
384 std::cout <<
"Create evaluate class for: " + problem_kind << std::endl;
388 comparison_source->evaluateFactory = evaluateFactory;
390 std::ostringstream msgSummary;
392 evaluateFactory->getEvaluateClass()->printMetrics(msgSummary);
394 std::cout << msgSummary.str();
397 std::ostringstream msgResults;
398 if (!
analyzeMetrics(evaluateFactory, msgResults, problem_parameters)) {
400 std::cout <<
"MetricAnalyzer::analyzeMetrics() "
401 <<
"returned false and the test is FAILED." << std::endl;
404 std::cout << msgResults.str();
409 if (problem_kind ==
"ordering") {
410 std::cout <<
"\nLet's examine the solution..." << std::endl;
411 LocalOrderingSolution<zlno_t> * localOrderingSolution =
413 if (localOrderingSolution->haveSeparators() ) {
414 std::cout <<
"Number of column blocks: "
415 << localOrderingSolution->getNumSeparatorBlocks() << std::endl;
417 if (localOrderingSolution->havePerm()) {
418 std::cout <<
"permutation: {";
419 for (
auto &x : localOrderingSolution->getPermutationRCPConst(
false))
420 std::cout <<
" " << x;
421 std::cout <<
"}" << std::endl;
424 if (localOrderingSolution->haveInverse()) {
425 std::cout <<
"inverse permutation: {";
426 for (
auto &x : localOrderingSolution->getPermutationRCPConst(
true))
427 std::cout <<
" " << x;
428 std::cout <<
"}" << std::endl;
431 if (localOrderingSolution->haveSeparatorRange()) {
432 std::cout <<
"separator range: {";
433 for (
auto &x : localOrderingSolution->getSeparatorRangeRCPConst())
434 std::cout <<
" " << x;
435 std::cout <<
"}" << std::endl;
438 if (localOrderingSolution->haveSeparatorTree()) {
439 std::cout <<
"separator tree: {";
440 for (
auto &x : localOrderingSolution->getSeparatorTreeRCPConst())
441 std::cout <<
" " << x;
442 std::cout <<
"}" << std::endl;
449 comparison_source->printTimers();
461bool mainExecute(
int narg,
char *arg[], RCP<
const Comm<int> > &comm)
466 int rank = comm->getRank();
472 string inputFileName(
"");
474 inputFileName = arg[1];
477 std::cout <<
"\nFAILED to specify xml input file!" << std::endl;
478 std::ostringstream msg;
479 msg <<
"\nStandard use of test_driver.cpp:\n";
480 msg <<
"mpiexec -n <procs> ./Zoltan2_test_driver.exe <input_file.xml>\n";
481 std::cout << msg.str() << std::endl;
489 queue<ParameterList> problems, comparisons;
499 const ParameterList inputParameters = problems.front();
500 if(inputParameters.name() !=
"InputParameters")
503 std::cout <<
"InputParameters not defined. Testing FAILED." << std::endl;
524 while (!problems.empty()) {
527 if(uinput.hasInput()) {
528 if (!
run(uinput, problems.front(), !comparisons.empty(),
529 comparison_manager, comm)) {
530 std::cout <<
"Problem run returned false" << std::endl;
541 while (!comparisons.empty()) {
542 if (!comparison_manager->Compare(comparisons.front(),comm)) {
544 std::cout <<
"Comparison manager returned false so the "
545 <<
"test should fail." << std::endl;
554 std::cout <<
"\nFAILED to load input data source. Skipping "
555 "all tests." << std::endl;
565 Tpetra::ScopeGuard tscope(&narg, &arg);
566 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
569 int rank = comm->getRank();
574 catch(std::logic_error &e) {
579 std::cout <<
"Test driver for rank " << rank
580 <<
" caught the following exception: " << e.what() << std::endl;
584 catch(std::runtime_error &e) {
585 std::cout <<
"Test driver for rank " << rank
586 <<
" caught the following exception: " << e.what() << std::endl;
589 catch(std::exception &e) {
590 std::cout <<
"Test driver for rank " << rank
591 <<
" caught the following exception: " << e.what() << std::endl;
601 reduceAll<int,int>(*comm, Teuchos::EReductionType::REDUCE_MAX, 1,
602 &result, &resultReduced);
607 std::cout <<
"Test Driver with " << comm->getSize()
608 <<
" processes has reduced result code " << resultReduced
609 <<
" and is exiting in the "
610 << ((resultReduced == 0 ) ?
"PASSED" :
"FAILED") <<
" state."