61 #include "Teuchos_XMLParameterListHelpers.hpp" 63 #include <Teuchos_LAPACK.hpp> 72 #ifdef hopper_separate_test 75 #define CATCH_EXCEPTIONS_AND_RETURN(pp) \ 76 catch (std::runtime_error &e) { \ 77 cout << "Runtime exception returned from " << pp << ": " \ 78 << e.what() << " FAIL" << endl; \ 81 catch (std::logic_error &e) { \ 82 cout << "Logic exception returned from " << pp << ": " \ 83 << e.what() << " FAIL" << endl; \ 86 catch (std::bad_alloc &e) { \ 87 cout << "Bad_alloc exception returned from " << pp << ": " \ 88 << e.what() << " FAIL" << endl; \ 91 catch (std::exception &e) { \ 92 cout << "Unknown exception returned from " << pp << ": " \ 93 << e.what() << " FAIL" << endl; \ 97 #define CATCH_EXCEPTIONS_WITH_COUNT(ierr, pp) \ 98 catch (std::runtime_error &e) { \ 99 cout << "Runtime exception returned from " << pp << ": " \ 100 << e.what() << " FAIL" << endl; \ 103 catch (std::logic_error &e) { \ 104 cout << "Logic exception returned from " << pp << ": " \ 105 << e.what() << " FAIL" << endl; \ 108 catch (std::bad_alloc &e) { \ 109 cout << "Bad_alloc exception returned from " << pp << ": " \ 110 << e.what() << " FAIL" << endl; \ 113 catch (std::exception &e) { \ 114 cout << "Unknown exception returned from " << pp << ": " \ 115 << e.what() << " FAIL" << endl; \ 120 typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t>
tMVector_t;
131 const string& delimiters =
" \f\n\r\t\v" )
133 return s.substr( 0, s.find_last_not_of( delimiters ) + 1 );
138 const string& delimiters =
" \f\n\r\t\v" )
140 return s.substr( s.find_first_not_of( delimiters ) );
145 const string& delimiters =
" \f\n\r\t\v" )
150 template <
typename Adapter>
154 typename Adapter::scalar_t *lower,
155 typename Adapter::scalar_t *upper,
157 typename Adapter::part_t *parts
160 std::cout <<
"boxAssign test " << str <<
": Box (";
161 for (
int j = 0; j < dim; j++) std::cout << lower[j] <<
" ";
162 std::cout <<
") x (";
163 for (
int j = 0; j < dim; j++) std::cout << upper[j] <<
" ";
166 std::cout <<
") does not overlap any parts" << std::endl;
168 std::cout <<
") overlaps parts ";
169 for (
size_t k = 0; k < nparts; k++) std::cout << parts[k] <<
" ";
170 std::cout << std::endl;
174 template <
typename Adapter>
177 RCP<tMVector_t> &coords)
182 int coordDim = coords->getNumVectors();
184 typename Adapter::part_t part = -1;
187 sprintf(mechar,
"%d", problem->
getComm()->getRank());
192 const typename Adapter::part_t *solnPartView =
195 size_t numPoints = coords->getLocalLength();
196 for (
size_t localID = 0; localID < numPoints; localID++) {
198 typename Adapter::part_t solnPart = solnPartView[localID];
200 for (
int i = 0; i < coordDim; i++)
201 pointDrop[i] = coords->getData(i)[localID];
204 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
208 std::cout << me <<
" Point " << localID
209 <<
" gid " << coords->getMap()->getGlobalElement(localID)
210 <<
" (" << pointDrop[0];
211 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
212 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
213 std::cout <<
") in boxPart " << part
214 <<
" in solnPart " << solnPart
233 typename Adapter::part_t> >
234 pBoxes = problem->
getSolution().getPartBoxesView();
235 for (
size_t i = 0; i < pBoxes.size(); i++) {
236 zscalar_t *lmin = pBoxes[i].getlmins();
237 zscalar_t *lmax = pBoxes[i].getlmaxs();;
238 std::cout << me <<
" pBox " << i <<
" pid " << pBoxes[i].getpId()
239 <<
" (" << lmin[0] <<
"," << lmin[1] <<
"," 240 << (coordDim > 2 ? lmin[2] : 0) <<
") x " 241 <<
" (" << lmax[0] <<
"," << lmax[1] <<
"," 242 << (coordDim > 2 ? lmax[2] : 0) <<
")" << std::endl;
248 for (
int i = 0; i < coordDim; i++) pointDrop[i] = 0.;
250 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
253 std::cout << me <<
" OriginPoint (" << pointDrop[0];
254 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
255 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
256 std::cout <<
") part " << part << std::endl;
261 for (
int i = 0; i < coordDim; i++) pointDrop[i] = -100.+i;
263 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
266 std::cout << me <<
" NegativePoint (" << pointDrop[0];
267 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
268 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
269 std::cout <<
") part " << part << std::endl;
274 for (
int i = 0; i < coordDim; i++) pointDrop[i] = i*5;
276 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
279 std::cout << me <<
" i*5-Point (" << pointDrop[0];
280 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
281 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
282 std::cout <<
") part " << part << std::endl;
287 for (
int i = 0; i < coordDim; i++) pointDrop[i] = 10+i*5;
289 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
292 std::cout << me <<
" WoopWoop-Point (" << pointDrop[0];
293 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
294 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
295 std::cout <<
") part " << part << std::endl;
302 template <
typename Adapter>
305 RCP<tMVector_t> &coords)
310 int coordDim = coords->getNumVectors();
315 sprintf(mechar,
"%d", problem->
getComm()->getRank());
319 typename Adapter::part_t> >
320 pBoxes = problem->
getSolution().getPartBoxesView();
321 size_t nBoxes = pBoxes.size();
326 typename Adapter::part_t *parts;
327 size_t pickabox = nBoxes / 2;
328 for (
int i = 0; i < coordDim; i++) {
329 zscalar_t dd = 0.2 * (pBoxes[pickabox].getlmaxs()[i] -
330 pBoxes[pickabox].getlmins()[i]);
331 lower[i] = pBoxes[pickabox].getlmins()[i] + dd;
332 upper[i] = pBoxes[pickabox].getlmaxs()[i] - dd;
335 problem->
getSolution().boxAssign(coordDim, lower, upper,
340 std::cout << me <<
" FAIL boxAssign error: smaller test, nparts > 1" 344 print_boxAssign_result<Adapter>(
"smallerbox", coordDim,
345 lower, upper, nparts, parts);
352 typename Adapter::part_t *parts;
353 size_t pickabox = nBoxes / 2;
354 for (
int i = 0; i < coordDim; i++) {
355 zscalar_t dd = 0.2 * (pBoxes[pickabox].getlmaxs()[i] -
356 pBoxes[pickabox].getlmins()[i]);
357 lower[i] = pBoxes[pickabox].getlmins()[i] - dd;
358 upper[i] = pBoxes[pickabox].getlmaxs()[i] + dd;
361 problem->
getSolution().boxAssign(coordDim, lower, upper,
367 if ((nBoxes > 1) && (nparts < 2)) {
368 std::cout << me <<
" FAIL boxAssign error: " 369 <<
"larger test, nparts < 2" 375 bool found_pickabox = 0;
376 for (
size_t i = 0; i < nparts; i++)
377 if (parts[i] == pBoxes[pickabox].getpId()) {
381 if (!found_pickabox) {
382 std::cout << me <<
" FAIL boxAssign error: " 383 <<
"larger test, pickabox not found" 388 print_boxAssign_result<Adapter>(
"largerbox", coordDim,
389 lower, upper, nparts, parts);
396 typename Adapter::part_t *parts;
397 for (
int i = 0; i < coordDim; i++) {
398 lower[i] = std::numeric_limits<zscalar_t>::max();
399 upper[i] = std::numeric_limits<zscalar_t>::min();
401 for (
size_t j = 0; j < nBoxes; j++) {
402 for (
int i = 0; i < coordDim; i++) {
403 if (pBoxes[j].getlmins()[i] <= lower[i])
404 lower[i] = pBoxes[j].getlmins()[i];
405 if (pBoxes[j].getlmaxs()[i] >= upper[i])
406 upper[i] = pBoxes[j].getlmaxs()[i];
410 problem->
getSolution().boxAssign(coordDim, lower, upper,
416 if (nparts != nBoxes) {
417 std::cout << me <<
" FAIL boxAssign error: " 418 <<
"global test, nparts found " << nparts
419 <<
" != num global parts " << nBoxes
423 print_boxAssign_result<Adapter>(
"globalbox", coordDim,
424 lower, upper, nparts, parts);
433 typename Adapter::part_t *parts;
434 for (
int i = 0; i < coordDim; i++) {
440 problem->
getSolution().boxAssign(coordDim, lower, upper,
446 if (nparts != nBoxes) {
447 std::cout << me <<
" FAIL boxAssign error: " 448 <<
"bigdomain test, nparts found " << nparts
449 <<
" != num global parts " << nBoxes
453 print_boxAssign_result<Adapter>(
"bigdomainbox", coordDim,
454 lower, upper, nparts, parts);
463 typename Adapter::part_t *parts;
464 for (
int i = 0; i < coordDim; i++) {
465 lower[i] = upper[i] + 10;
470 problem->
getSolution().boxAssign(coordDim, lower, upper,
478 std::cout << me <<
" FAIL boxAssign error: " 479 <<
"outthere test, nparts found " << nparts
484 print_boxAssign_result<Adapter>(
"outthere box", coordDim,
485 lower, upper, nparts, parts);
494 void readGeoGenParams(
string paramFileName, Teuchos::ParameterList &geoparams,
const RCP<
const Teuchos::Comm<int> > & comm){
495 std::string input =
"";
497 for(
int i = 0; i < 25000; ++i){
502 if(comm->getRank() == 0){
504 fstream inParam(paramFileName.c_str());
511 std::string tmp =
"";
512 getline (inParam,tmp);
513 while (!inParam.eof()){
520 getline (inParam,tmp);
523 for (
size_t i = 0; i < input.size(); ++i){
531 int size = input.size();
535 comm->broadcast(0,
sizeof(
int), (
char*) &size);
537 throw "File " + paramFileName +
" cannot be opened.";
539 comm->broadcast(0, size, inp);
540 istringstream inParam(inp);
542 getline (inParam,str);
543 while (!inParam.eof()){
545 size_t pos = str.find(
'=');
546 if(pos == string::npos){
547 throw "Invalid Line:" + str +
" in parameter file";
549 string paramname =
trim_copy(str.substr(0,pos));
550 string paramvalue =
trim_copy(str.substr(pos + 1));
551 geoparams.set(paramname, paramvalue);
553 getline (inParam,str);
558 int numParts,
float imbalance,
559 std::string paramFile, std::string pqParts,
562 int migration_check_option,
563 int migration_all_to_all_type,
565 int migration_processor_assignment_type,
566 int migration_doMigration_type,
572 Teuchos::ParameterList geoparams(
"geo params");
583 for(
int i = 0; i < coord_dim; ++i){
584 coords[i] =
new zscalar_t[numLocalPoints];
588 if (numWeightsPerCoord) {
589 weight=
new zscalar_t * [numWeightsPerCoord];
590 for(
int i = 0; i < numWeightsPerCoord; ++i){
591 weight[i] =
new zscalar_t[numLocalPoints];
598 RCP<Tpetra::Map<zlno_t, zgno_t, znode_t> > mp = rcp(
599 new Tpetra::Map<zlno_t, zgno_t, znode_t>(numGlobalPoints,
600 numLocalPoints, 0, comm));
602 Teuchos::Array<Teuchos::ArrayView<const zscalar_t> > coordView(coord_dim);
603 for (
int i=0; i < coord_dim; i++){
604 if(numLocalPoints > 0){
605 Teuchos::ArrayView<const zscalar_t> a(coords[i], numLocalPoints);
609 Teuchos::ArrayView<const zscalar_t> a;
614 RCP<tMVector_t> tmVector = RCP<tMVector_t>(
new 618 RCP<const tMVector_t> coordsConst =
619 Teuchos::rcp_const_cast<
const tMVector_t>(tmVector);
620 vector<const zscalar_t *>
weights;
621 if(numWeightsPerCoord){
622 for (
int i = 0; i < numWeightsPerCoord;++i){
623 weights.push_back(weight[i]);
630 inputAdapter_t ia(coordsConst,weights, stride);
632 Teuchos::RCP<Teuchos::ParameterList> params ;
636 params = Teuchos::getParametersFromXmlFile(pfname);
639 params =RCP<Teuchos::ParameterList>(
new Teuchos::ParameterList,
true);
645 params->set(
"timer_output_stream" ,
"std::cout");
647 params->set(
"algorithm",
"multijagged");
648 params->set(
"compute_metrics",
"true");
650 params->set(
"mj_keep_part_boxes", 1);
652 params->set(
"rectilinear",
"true");
655 params->set(
"imbalance_tolerance",
double(imbalance));
658 params->set(
"mj_parts", pqParts);
660 params->set(
"num_global_parts", numParts);
662 params->set(
"mj_concurrent_part_count", k);
663 if(migration_check_option >= 0)
664 params->set(
"mj_migration_option", migration_check_option);
665 if(migration_imbalance_cut_off >= 0)
666 params->set(
"mj_minimum_migration_imbalance",
667 double(migration_imbalance_cut_off));
681 if (comm->getRank() == 0){
688 ierr = run_pointAssign_tests<inputAdapter_t>(problem, tmVector);
689 ierr += run_boxAssign_tests<inputAdapter_t>(problem, tmVector);
692 if(numWeightsPerCoord){
693 for(
int i = 0; i < numWeightsPerCoord; ++i)
698 for(
int i = 0; i < coord_dim; ++i)
707 RCP<
const Teuchos::Comm<int> > &comm,
714 int migration_check_option,
715 int migration_all_to_all_type,
717 int migration_processor_assignment_type,
718 int migration_doMigration_type,
731 RCP<const tMVector_t> coordsConst = rcp_const_cast<
const tMVector_t>(coords);
733 inputAdapter_t ia(coordsConst);
735 Teuchos::RCP <Teuchos::ParameterList> params ;
739 params = Teuchos::getParametersFromXmlFile(pfname);
742 params =RCP <Teuchos::ParameterList> (
new Teuchos::ParameterList,
true);
746 params->set(
"compute_metrics",
"true");
748 params->set(
"mj_keep_part_boxes", 1);
750 params->set(
"rectilinear",
"true");
751 params->set(
"algorithm",
"multijagged");
753 params->set(
"imbalance_tolerance",
double(imbalance));
757 params->set(
"mj_parts", pqParts);
760 params->set(
"num_global_parts", numParts);
763 params->set(
"mj_concurrent_part_count", k);
765 if(migration_check_option >= 0){
766 params->set(
"mj_migration_option", migration_check_option);
768 if(migration_imbalance_cut_off >= 0){
769 params->set(
"mj_minimum_migration_imbalance",
770 double (migration_imbalance_cut_off));
788 const int bvme = comm->getRank();
789 const inputAdapter_t::lno_t bvlen =
790 inputAdapter_t::lno_t(coords->getLocalLength());
791 const size_t bvnvecs = coords->getNumVectors();
792 const size_t bvsize = coords->getNumVectors() * coords->getLocalLength();
794 ArrayRCP<inputAdapter_t::scalar_t> *bvtpetravectors =
795 new ArrayRCP<inputAdapter_t::scalar_t>[bvnvecs];
796 for (
size_t i = 0; i < bvnvecs; i++)
797 bvtpetravectors[i] = coords->getDataNonConst(i);
800 inputAdapter_t::gno_t *bvgids =
new 801 inputAdapter_t::gno_t[coords->getLocalLength()];
802 inputAdapter_t::scalar_t *bvcoordarr =
new inputAdapter_t::scalar_t[bvsize];
803 for (inputAdapter_t::lno_t j = 0; j < bvlen; j++) {
804 bvgids[j] = coords->getMap()->getGlobalElement(j);
805 for (
size_t i = 0; i < bvnvecs; i++) {
806 bvcoordarr[idx++] = bvtpetravectors[i][j];
811 inputAdapter_t::lno_t,
812 inputAdapter_t::gno_t> bvtypes_t;
814 std::vector<const inputAdapter_t::scalar_t *> bvcoords(bvnvecs);
815 std::vector<int> bvstrides(bvnvecs);
816 for (
size_t i = 0; i < bvnvecs; i++) {
817 bvcoords[i] = &bvcoordarr[i];
818 bvstrides[i] = bvnvecs;
820 std::vector<const inputAdapter_t::scalar_t *> bvwgts;
821 std::vector<int> bvwgtstrides;
823 bvadapter_t bvia(bvlen, bvgids, bvcoords, bvstrides,
824 bvwgts, bvwgtstrides);
840 for (inputAdapter_t::lno_t i = 0; i < bvlen; i++) {
843 cout << bvme <<
" " << i <<
" " 844 << coords->getMap()->getGlobalElement(i) <<
" " << bvgids[i]
845 <<
": XMV " << problem->
getSolution().getPartListView()[i]
846 <<
"; BMV " << bvproblem->
getSolution().getPartListView()[i]
847 <<
" : FAIL" << endl;
851 delete [] bvcoordarr;
852 delete [] bvtpetravectors;
856 if (coordsConst->getGlobalLength() < 40) {
857 int len = coordsConst->getLocalLength();
858 const inputAdapter_t::part_t *zparts =
860 for (
int i = 0; i < len; i++)
861 cout << comm->getRank()
863 <<
" gid " << coords->getMap()->getGlobalElement(i)
864 <<
" part " << zparts[i] << endl;
867 if (comm->getRank() == 0){
869 cout <<
"testFromDataFile is done " << endl;
876 ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
877 ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
884 #ifdef hopper_separate_test 886 template <
typename zscalar_t,
typename zlno_t>
888 FILE *f = fopen(fileName.c_str(),
"r");
890 cout << fileName <<
" cannot be opened" << endl;
893 fscanf(f,
"%d", &numLocal);
894 fscanf(f,
"%d", &dim);
896 for (
int i = 0; i < dim; ++i){
899 for (
int i = 0; i < dim; ++i){
900 for (
zlno_t j = 0; j < numLocal; ++j){
901 fscanf(f,
"%lf", &(coords[i][j]));
907 int testFromSeparateDataFiles(
908 RCP<
const Teuchos::Comm<int> > &comm,
915 int migration_check_option,
916 int migration_all_to_all_type,
918 int migration_processor_assignment_type,
919 int migration_doMigration_type,
928 int mR = comm->getRank();
929 if (mR == 0) cout <<
"size of zscalar_t:" <<
sizeof(
zscalar_t) << endl;
930 string tFile = fname +
"_" + Zoltan2::toString<int>(mR) +
".mtx";
934 getCoords<zscalar_t, zlno_t>(double_coords, numLocal, dim, tFile);
936 Teuchos::Array<Teuchos::ArrayView<const zscalar_t> > coordView(dim);
937 for (
int i=0; i < dim; i++){
939 Teuchos::ArrayView<const zscalar_t> a(double_coords[i], numLocal);
942 Teuchos::ArrayView<const zscalar_t> a;
949 Teuchos::Comm<int> *tcomm = (Teuchos::Comm<int> *)comm.getRawPtr();
951 reduceAll<int, zgno_t>(
960 RCP<Tpetra::Map<zlno_t, zgno_t, znode_t> > mp = rcp(
961 new Tpetra::Map<zlno_t, zgno_t, znode_t> (numGlobal, numLocal, 0, comm));
962 RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >coords = RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >(
963 new Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t>( mp, coordView.view(0, dim), dim));
967 RCP<const tMVector_t> coordsConst = rcp_const_cast<
const tMVector_t>(coords);
969 typedef Zoltan2::XpetraMultiVectorInput<tMVector_t> inputAdapter_t;
970 inputAdapter_t ia(coordsConst);
972 Teuchos::RCP <Teuchos::ParameterList> params ;
976 params = Teuchos::getParametersFromXmlFile(pfname);
979 params =RCP <Teuchos::ParameterList> (
new Teuchos::ParameterList,
true);
983 params->set(
"compute_metrics",
"true");
984 params->set(
"algorithm",
"multijagged");
986 params->set(
"imbalance_tolerance",
double(imbalance));
990 params->set(
"pqParts", pqParts);
993 params->set(
"num_global_parts", numParts);
996 params->set(
"parallel_part_calculation_count", k);
998 if(migration_processor_assignment_type >= 0){
999 params->set(
"migration_processor_assignment_type", migration_processor_assignment_type);
1001 if(migration_check_option >= 0){
1002 params->set(
"migration_check_option", migration_check_option);
1004 if(migration_all_to_all_type >= 0){
1005 params->set(
"migration_all_to_all_type", migration_all_to_all_type);
1007 if(migration_imbalance_cut_off >= 0){
1008 params->set(
"migration_imbalance_cut_off",
1009 double (migration_imbalance_cut_off));
1011 if (migration_doMigration_type >= 0){
1012 params->set(
"migration_doMigration_type",
int (migration_doMigration_type));
1015 params->set(
"mj_keep_part_boxes", 1);
1017 params->set(
"rectilinear",
"true");
1033 if (coordsConst->getGlobalLength() < 40) {
1034 int len = coordsConst->getLocalLength();
1035 const inputAdapter_t::part_t *zparts =
1037 for (
int i = 0; i < len; i++)
1038 cout << comm->getRank()
1039 <<
" gid " << coords->getMap()->getGlobalElement(i)
1040 <<
" part " << zparts[i] << endl;
1043 if (comm->getRank() == 0){
1045 cout <<
"testFromDataFile is done " << endl;
1052 ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
1053 ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
1065 for(
int i = 0; args[i] != 0; i++)
1070 stringstream stream(stringstream::in | stringstream::out);
1071 stream << argumentline;
1072 getline(stream, argumentid,
'=');
1076 stream >> argumentValue;
1088 std::string &pfname,
1090 int &migration_check_option,
1091 int &migration_all_to_all_type,
1093 int &migration_processor_assignment_type,
1094 int &migration_doMigration_type,
1099 bool isCset =
false;
1100 bool isPset =
false;
1101 bool isFset =
false;
1102 bool isPFset =
false;
1104 for(
int i = 0; i < argc; ++i){
1106 string identifier =
"";
1107 long long int value = -1;
double fval = -1;
1109 value = (
long long int) (fval);
1111 if(identifier ==
"C"){
1116 throw "Invalid argument at " + tmp;
1118 }
else if(identifier ==
"P"){
1119 stringstream stream(stringstream::in | stringstream::out);
1122 getline(stream, ttmp,
'=');
1125 }
else if(identifier ==
"I"){
1129 throw "Invalid argument at " + tmp;
1131 }
else if(identifier ==
"MI"){
1133 migration_imbalance_cut_off=fval;
1135 throw "Invalid argument at " + tmp;
1137 }
else if(identifier ==
"MO"){
1139 migration_check_option = value;
1141 throw "Invalid argument at " + tmp;
1143 }
else if(identifier ==
"AT"){
1145 migration_processor_assignment_type = value;
1147 throw "Invalid argument at " + tmp;
1151 else if(identifier ==
"MT"){
1153 migration_all_to_all_type = value;
1155 throw "Invalid argument at " + tmp;
1158 else if(identifier ==
"DM"){
1160 migration_doMigration_type = value;
1162 throw "Invalid argument at " + tmp;
1165 else if(identifier ==
"F"){
1166 stringstream stream(stringstream::in | stringstream::out);
1168 getline(stream, fname,
'=');
1173 else if(identifier ==
"PF"){
1174 stringstream stream(stringstream::in | stringstream::out);
1176 getline(stream, pfname,
'=');
1182 else if(identifier ==
"O"){
1183 if(value >= 0 && value <= 3){
1186 throw "Invalid argument at " + tmp;
1189 else if(identifier ==
"K"){
1193 throw "Invalid argument at " + tmp;
1196 else if(identifier ==
"TB"){
1198 test_boxes = (value == 0 ?
false :
true);
1200 throw "Invalid argument at " + tmp;
1203 else if(identifier ==
"R"){
1205 rectilinear = (value == 0 ?
false :
true);
1207 throw "Invalid argument at " + tmp;
1211 throw "Invalid argument at " + tmp;
1215 if(!( (isCset || isPset || isPFset) && isFset)){
1216 throw "(C || P || PF) && F are mandatory arguments.";
1222 cout <<
"\nUsage:" << endl;
1223 cout << executable <<
" arglist" << endl;
1224 cout <<
"arglist:" << endl;
1225 cout <<
"\tC=numParts: numParts > 0" << endl;
1226 cout <<
"\tP=MultiJaggedPart: Example: P=512,512" << endl;
1227 cout <<
"\tI=imbalance: Example I=1.03 (ignored for now.)" << endl;
1228 cout <<
"\tF=filePath: When O=0 the path of the coordinate input file, for O>1 the path to the geometric generator parameter file." << endl;
1229 cout <<
"\tO=input option: O=0 for reading coordinate from file, O>0 for generating coordinate from coordinate generator file. Default will run geometric generator." << endl;
1230 cout <<
"\tK=concurrent part calculation input: K>0." << endl;
1231 cout <<
"\tMI=migration_imbalance_cut_off: MI=1.35. " << endl;
1232 cout <<
"\tMT=migration_all_to_all_type: 0 for alltoallv, 1 for Zoltan_Comm, 2 for Zoltan2 Distributor object(Default 1)." << endl;
1233 cout <<
"\tMO=migration_check_option: 0 for decision on imbalance, 1 for forcing migration, >1 for avoiding migration. (Default-0)" << endl;
1234 cout <<
"\tAT=migration_processor_assignment_type. 0-for assigning procs with respect to proc ownment, otherwise, assignment with respect to proc closeness." << endl;
1235 cout <<
"Example:\n" << executable <<
" P=2,2,2 C=8 F=simple O=0" << endl;
1240 Teuchos::GlobalMPISession session(&argc, &argv);
1243 RCP<const Teuchos::Comm<int> > tcomm = Teuchos::DefaultComm<int>::getComm();
1244 int rank = tcomm->getRank();
1248 float imbalance = -1.03;
1251 string pqParts =
"";
1253 std::string fname =
"";
1254 std::string paramFile =
"";
1257 int migration_check_option = -2;
1258 int migration_all_to_all_type = -1;
1259 zscalar_t migration_imbalance_cut_off = -1.15;
1260 int migration_processor_assignment_type = -1;
1261 int migration_doMigration_type = -1;
1262 bool test_boxes =
false;
1263 bool rectilinear =
false;
1277 migration_check_option,
1278 migration_all_to_all_type,
1279 migration_imbalance_cut_off,
1280 migration_processor_assignment_type,
1281 migration_doMigration_type,
1285 catch(std::string s){
1286 if(tcomm->getRank() == 0){
1293 if(tcomm->getRank() == 0){
1298 catch(
char const * s){
1299 if(tcomm->getRank() == 0){
1311 pqParts, paramFile, k,
1312 migration_check_option,
1313 migration_all_to_all_type,
1314 migration_imbalance_cut_off,
1315 migration_processor_assignment_type,
1316 migration_doMigration_type, test_boxes, rectilinear);
1318 #ifdef hopper_separate_test 1320 ierr = testFromSeparateDataFiles(tcomm,numParts, imbalance,fname,
1321 pqParts, paramFile, k,
1322 migration_check_option,
1323 migration_all_to_all_type,
1324 migration_imbalance_cut_off,
1325 migration_processor_assignment_type,
1326 migration_doMigration_type, test_boxes, rectilinear);
1331 pqParts, paramFile, k,
1332 migration_check_option,
1333 migration_all_to_all_type,
1334 migration_imbalance_cut_off,
1335 migration_processor_assignment_type,
1336 migration_doMigration_type, test_boxes, rectilinear);
1341 if (ierr == 0) std::cout <<
"PASS" << std::endl;
1342 else std::cout <<
"FAIL" << std::endl;
1347 catch(std::string &s){
1357 catch(
char const* s){
#define CATCH_EXCEPTIONS_WITH_COUNT(ierr, pp)
void getLocalCoordinatesCopy(scalar_t **c)
string trim_right_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
void print_usage(char *executable)
void readGeoGenParams(string paramFileName, Teuchos::ParameterList &geoparams, const RCP< const Teuchos::Comm< int > > &comm)
int main(int argc, char *argv[])
A simple class that can be the User template argument for an InputAdapter.
int run_pointAssign_tests(Zoltan2::PartitioningProblem< Adapter > *problem, RCP< tMVector_t > &coords)
int testFromDataFile(RCP< const Teuchos::Comm< int > > &comm, int numParts, float imbalance, std::string fname, std::string pqParts, std::string pfname, int k, int migration_check_option, int migration_all_to_all_type, zscalar_t migration_imbalance_cut_off, int migration_processor_assignment_type, int migration_doMigration_type, bool test_boxes, bool rectilinear)
int getCoordinateDimension()
Defines the PartitioningSolution class.
common code used by tests
int GeometricGenInterface(RCP< const Teuchos::Comm< int > > &comm, int numParts, float imbalance, std::string paramFile, std::string pqParts, std::string pfname, int k, int migration_check_option, int migration_all_to_all_type, zscalar_t migration_imbalance_cut_off, int migration_processor_assignment_type, int migration_doMigration_type, bool test_boxes, bool rectilinear)
void print_boxAssign_result(const char *str, int dim, typename Adapter::scalar_t *lower, typename Adapter::scalar_t *upper, size_t nparts, typename Adapter::part_t *parts)
coordinateModelPartBox Class, represents the boundaries of the box which is a result of a geometric p...
Defines the XpetraMultiVectorAdapter.
string trim_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
Defines the EvaluatePartition class.
int run_boxAssign_tests(Zoltan2::PartitioningProblem< Adapter > *problem, RCP< tMVector_t > &coords)
void printMetrics(std::ostream &os) const
Print the array of metrics.
RCP< const Comm< int > > getComm()
Return the communicator used by the problem.
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
void printTimers() const
Return the communicator passed to the problem.
An adapter for Xpetra::MultiVector.
#define CATCH_EXCEPTIONS_AND_RETURN(pp)
static const std::string fail
string convert_to_string(char *args)
const PartitioningSolution< Adapter > & getSolution()
Get the solution to the problem.
PartitioningProblem sets up partitioning problems for the user.
void getArgVals(int argc, char **argv, int &numParts, float &imbalance, string &pqParts, int &opt, std::string &fname, std::string &pfname, int &k, int &migration_check_option, int &migration_all_to_all_type, zscalar_t &migration_imbalance_cut_off, int &migration_processor_assignment_type, int &migration_doMigration_type, bool &test_boxes, bool &rectilinear)
string trim_left_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
int getNumWeights()
##END Predistribution functions######################//
bool getArgumentValue(string &argumentid, double &argumentValue, string argumentline)
lno_t getNumLocalCoords()
Tpetra::MultiVector< zscalar_t, zlno_t, zgno_t, znode_t > tMVector_t
Defines the PartitioningProblem class.
gno_t getNumGlobalCoords()
Defines the BasicVectorAdapter class.
void solve(bool updateInputData=true)
Direct the problem to create a solution.
void getLocalWeightsCopy(scalar_t **w)
std::string testDataFilePath(".")