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++) {
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){
632 inputAdapter_t *ia =
new inputAdapter_t(coordsConst,
weights, stride);
634 Teuchos::RCP<Teuchos::ParameterList> params ;
638 params = Teuchos::getParametersFromXmlFile(pfname);
641 params =RCP<Teuchos::ParameterList>(
new Teuchos::ParameterList,
true);
647 params->set(
"timer_output_stream" ,
"std::cout");
649 params->set(
"algorithm",
"multijagged");
651 params->set(
"mj_keep_part_boxes",
true);
653 params->set(
"rectilinear",
true );
656 params->set(
"imbalance_tolerance",
double(imbalance));
659 params->set(
"mj_parts", pqParts);
661 params->set(
"num_global_parts", numParts);
663 params->set(
"mj_concurrent_part_count", k);
664 if(migration_check_option >= 0)
665 params->set(
"mj_migration_option", migration_check_option);
666 if(migration_imbalance_cut_off >= 0)
667 params->set(
"mj_minimum_migration_imbalance",
668 double(migration_imbalance_cut_off));
685 RCP<quality_t> metricObject =
686 rcp(
new quality_t(ia,params.getRawPtr(),comm,&problem->
getSolution()));
688 if (comm->getRank() == 0){
689 metricObject->printMetrics(cout);
695 ierr = run_pointAssign_tests<inputAdapter_t>(problem, tmVector);
696 ierr += run_boxAssign_tests<inputAdapter_t>(problem, tmVector);
699 if(numWeightsPerCoord){
700 for(
int i = 0; i < numWeightsPerCoord; ++i)
705 for(
int i = 0; i < coord_dim; ++i)
715 RCP<
const Teuchos::Comm<int> > &comm,
722 int migration_check_option,
723 int migration_all_to_all_type,
725 int migration_processor_assignment_type,
726 int migration_doMigration_type,
739 RCP<const tMVector_t> coordsConst = rcp_const_cast<
const tMVector_t>(coords);
743 inputAdapter_t *ia =
new inputAdapter_t(coordsConst);
745 Teuchos::RCP <Teuchos::ParameterList> params ;
749 params = Teuchos::getParametersFromXmlFile(pfname);
752 params =RCP <Teuchos::ParameterList> (
new Teuchos::ParameterList,
true);
757 params->set(
"mj_keep_part_boxes",
true);
759 params->set(
"rectilinear",
true);
760 params->set(
"algorithm",
"multijagged");
762 params->set(
"imbalance_tolerance",
double(imbalance));
766 params->set(
"mj_parts", pqParts);
769 params->set(
"num_global_parts", numParts);
772 params->set(
"mj_concurrent_part_count", k);
774 if(migration_check_option >= 0){
775 params->set(
"mj_migration_option", migration_check_option);
777 if(migration_imbalance_cut_off >= 0){
778 params->set(
"mj_minimum_migration_imbalance",
779 double (migration_imbalance_cut_off));
797 const int bvme = comm->getRank();
798 const inputAdapter_t::lno_t bvlen =
799 inputAdapter_t::lno_t(coords->getLocalLength());
800 const size_t bvnvecs = coords->getNumVectors();
801 const size_t bvsize = coords->getNumVectors() * coords->getLocalLength();
803 ArrayRCP<inputAdapter_t::scalar_t> *bvtpetravectors =
804 new ArrayRCP<inputAdapter_t::scalar_t>[bvnvecs];
805 for (
size_t i = 0; i < bvnvecs; i++)
806 bvtpetravectors[i] = coords->getDataNonConst(i);
809 inputAdapter_t::gno_t *bvgids =
new 810 inputAdapter_t::gno_t[coords->getLocalLength()];
811 inputAdapter_t::scalar_t *bvcoordarr =
new inputAdapter_t::scalar_t[bvsize];
812 for (inputAdapter_t::lno_t j = 0; j < bvlen; j++) {
813 bvgids[j] = coords->getMap()->getGlobalElement(j);
814 for (
size_t i = 0; i < bvnvecs; i++) {
815 bvcoordarr[idx++] = bvtpetravectors[i][j];
820 inputAdapter_t::lno_t,
821 inputAdapter_t::gno_t> bvtypes_t;
823 std::vector<const inputAdapter_t::scalar_t *> bvcoords(bvnvecs);
824 std::vector<int> bvstrides(bvnvecs);
825 for (
size_t i = 0; i < bvnvecs; i++) {
826 bvcoords[i] = &bvcoordarr[i];
827 bvstrides[i] = bvnvecs;
829 std::vector<const inputAdapter_t::scalar_t *> bvwgts;
830 std::vector<int> bvwgtstrides;
832 bvadapter_t bvia(bvlen, bvgids, bvcoords, bvstrides,
833 bvwgts, bvwgtstrides);
849 for (inputAdapter_t::lno_t i = 0; i < bvlen; i++) {
852 cout << bvme <<
" " << i <<
" " 853 << coords->getMap()->getGlobalElement(i) <<
" " << bvgids[i]
854 <<
": XMV " << problem->
getSolution().getPartListView()[i]
855 <<
"; BMV " << bvproblem->
getSolution().getPartListView()[i]
856 <<
" : FAIL" << endl;
860 delete [] bvcoordarr;
861 delete [] bvtpetravectors;
865 if (coordsConst->getGlobalLength() < 40) {
866 int len = coordsConst->getLocalLength();
867 const inputAdapter_t::part_t *zparts =
869 for (
int i = 0; i < len; i++)
870 cout << comm->getRank()
872 <<
" gid " << coords->getMap()->getGlobalElement(i)
873 <<
" part " << zparts[i] << endl;
878 RCP<quality_t> metricObject =
879 rcp(
new quality_t(ia,params.getRawPtr(),comm,&problem->
getSolution()));
881 if (comm->getRank() == 0){
882 metricObject->printMetrics(cout);
883 cout <<
"testFromDataFile is done " << endl;
890 ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
891 ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
899 #ifdef hopper_separate_test 901 template <
typename zscalar_t,
typename zlno_t>
903 FILE *f = fopen(fileName.c_str(),
"r");
905 cout << fileName <<
" cannot be opened" << endl;
908 fscanf(f,
"%d", &numLocal);
909 fscanf(f,
"%d", &dim);
911 for (
int i = 0; i < dim; ++i){
914 for (
int i = 0; i < dim; ++i){
915 for (
zlno_t j = 0; j < numLocal; ++j){
916 fscanf(f,
"%lf", &(coords[i][j]));
922 int testFromSeparateDataFiles(
923 RCP<
const Teuchos::Comm<int> > &comm,
930 int migration_check_option,
931 int migration_all_to_all_type,
933 int migration_processor_assignment_type,
934 int migration_doMigration_type,
943 int mR = comm->getRank();
944 if (mR == 0) cout <<
"size of zscalar_t:" <<
sizeof(
zscalar_t) << endl;
945 string tFile = fname +
"_" + Teuchos::toString<int>(mR) +
".mtx";
949 getCoords<zscalar_t, zlno_t>(double_coords, numLocal, dim, tFile);
951 Teuchos::Array<Teuchos::ArrayView<const zscalar_t> > coordView(dim);
952 for (
int i=0; i < dim; i++){
954 Teuchos::ArrayView<const zscalar_t> a(double_coords[i], numLocal);
957 Teuchos::ArrayView<const zscalar_t> a;
964 Teuchos::Comm<int> *tcomm = (Teuchos::Comm<int> *)comm.getRawPtr();
966 reduceAll<int, zgno_t>(
975 RCP<Tpetra::Map<zlno_t, zgno_t, znode_t> > mp = rcp(
976 new Tpetra::Map<zlno_t, zgno_t, znode_t> (numGlobal, numLocal, 0, comm));
977 RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >coords = RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >(
978 new Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t>( mp, coordView.view(0, dim), dim));
982 RCP<const tMVector_t> coordsConst = rcp_const_cast<
const tMVector_t>(coords);
984 typedef Zoltan2::XpetraMultiVectorInput<tMVector_t> inputAdapter_t;
987 inputAdapter_t *ia =
new inputAdapter_t(coordsConst);
989 Teuchos::RCP <Teuchos::ParameterList> params ;
993 params = Teuchos::getParametersFromXmlFile(pfname);
996 params =RCP <Teuchos::ParameterList> (
new Teuchos::ParameterList,
true);
1000 params->set(
"algorithm",
"multijagged");
1002 params->set(
"imbalance_tolerance",
double(imbalance));
1006 params->set(
"mj_parts", pqParts);
1009 params->set(
"num_global_parts", numParts);
1012 params->set(
"parallel_part_calculation_count", k);
1014 if(migration_processor_assignment_type >= 0){
1015 params->set(
"migration_processor_assignment_type", migration_processor_assignment_type);
1017 if(migration_check_option >= 0){
1018 params->set(
"migration_check_option", migration_check_option);
1020 if(migration_all_to_all_type >= 0){
1021 params->set(
"migration_all_to_all_type", migration_all_to_all_type);
1023 if(migration_imbalance_cut_off >= 0){
1024 params->set(
"migration_imbalance_cut_off",
1025 double (migration_imbalance_cut_off));
1027 if (migration_doMigration_type >= 0){
1028 params->set(
"migration_doMigration_type",
int (migration_doMigration_type));
1031 params->set(
"mj_keep_part_boxes",
true);
1033 params->set(
"rectilinear",
true);
1049 if (coordsConst->getGlobalLength() < 40) {
1050 int len = coordsConst->getLocalLength();
1051 const inputAdapter_t::part_t *zparts =
1053 for (
int i = 0; i < len; i++)
1054 cout << comm->getRank()
1055 <<
" gid " << coords->getMap()->getGlobalElement(i)
1056 <<
" part " << zparts[i] << endl;
1061 RCP<quality_t> metricObject =
1062 rcp(
new quality_t(ia,params.getRawPtr(),comm,&problem->
getSolution()));
1064 if (comm->getRank() == 0){
1065 metricObject->printMetrics(cout);
1066 cout <<
"testFromDataFile is done " << endl;
1073 ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
1074 ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
1087 for(
int i = 0; args[i] != 0; i++)
1092 stringstream stream(stringstream::in | stringstream::out);
1093 stream << argumentline;
1094 getline(stream, argumentid,
'=');
1098 stream >> argumentValue;
1110 std::string &pfname,
1112 int &migration_check_option,
1113 int &migration_all_to_all_type,
1115 int &migration_processor_assignment_type,
1116 int &migration_doMigration_type,
1121 bool isCset =
false;
1122 bool isPset =
false;
1123 bool isFset =
false;
1124 bool isPFset =
false;
1126 for(
int i = 0; i < argc; ++i){
1128 string identifier =
"";
1129 long long int value = -1;
double fval = -1;
1131 value = (
long long int) (fval);
1133 if(identifier ==
"C"){
1138 throw "Invalid argument at " + tmp;
1140 }
else if(identifier ==
"P"){
1141 stringstream stream(stringstream::in | stringstream::out);
1144 getline(stream, ttmp,
'=');
1147 }
else if(identifier ==
"I"){
1151 throw "Invalid argument at " + tmp;
1153 }
else if(identifier ==
"MI"){
1155 migration_imbalance_cut_off=fval;
1157 throw "Invalid argument at " + tmp;
1159 }
else if(identifier ==
"MO"){
1161 migration_check_option = value;
1163 throw "Invalid argument at " + tmp;
1165 }
else if(identifier ==
"AT"){
1167 migration_processor_assignment_type = value;
1169 throw "Invalid argument at " + tmp;
1173 else if(identifier ==
"MT"){
1175 migration_all_to_all_type = value;
1177 throw "Invalid argument at " + tmp;
1180 else if(identifier ==
"DM"){
1182 migration_doMigration_type = value;
1184 throw "Invalid argument at " + tmp;
1187 else if(identifier ==
"F"){
1188 stringstream stream(stringstream::in | stringstream::out);
1190 getline(stream, fname,
'=');
1195 else if(identifier ==
"PF"){
1196 stringstream stream(stringstream::in | stringstream::out);
1198 getline(stream, pfname,
'=');
1204 else if(identifier ==
"O"){
1205 if(value >= 0 && value <= 3){
1208 throw "Invalid argument at " + tmp;
1211 else if(identifier ==
"K"){
1215 throw "Invalid argument at " + tmp;
1218 else if(identifier ==
"TB"){
1220 test_boxes = (value == 0 ? false :
true);
1222 throw "Invalid argument at " + tmp;
1225 else if(identifier ==
"R"){
1227 rectilinear = (value == 0 ? false :
true);
1229 throw "Invalid argument at " + tmp;
1233 throw "Invalid argument at " + tmp;
1237 if(!( (isCset || isPset || isPFset) && isFset)){
1238 throw "(C || P || PF) && F are mandatory arguments.";
1244 cout <<
"\nUsage:" << endl;
1245 cout << executable <<
" arglist" << endl;
1246 cout <<
"arglist:" << endl;
1247 cout <<
"\tC=numParts: numParts > 0" << endl;
1248 cout <<
"\tP=MultiJaggedPart: Example: P=512,512" << endl;
1249 cout <<
"\tI=imbalance: Example I=1.03 (ignored for now.)" << endl;
1250 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;
1251 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;
1252 cout <<
"\tK=concurrent part calculation input: K>0." << endl;
1253 cout <<
"\tMI=migration_imbalance_cut_off: MI=1.35. " << endl;
1254 cout <<
"\tMT=migration_all_to_all_type: 0 for alltoallv, 1 for Zoltan_Comm, 2 for Zoltan2 Distributor object(Default 1)." << endl;
1255 cout <<
"\tMO=migration_check_option: 0 for decision on imbalance, 1 for forcing migration, >1 for avoiding migration. (Default-0)" << endl;
1256 cout <<
"\tAT=migration_processor_assignment_type. 0-for assigning procs with respect to proc ownment, otherwise, assignment with respect to proc closeness." << endl;
1257 cout <<
"Example:\n" << executable <<
" P=2,2,2 C=8 F=simple O=0" << endl;
1262 Teuchos::GlobalMPISession session(&argc, &argv);
1263 Kokkos::initialize (argc, argv);
1266 RCP<const Teuchos::Comm<int> > tcomm = Teuchos::DefaultComm<int>::getComm();
1267 int rank = tcomm->getRank();
1271 float imbalance = -1.03;
1274 string pqParts =
"";
1276 std::string fname =
"";
1277 std::string paramFile =
"";
1280 int migration_check_option = -2;
1281 int migration_all_to_all_type = -1;
1282 zscalar_t migration_imbalance_cut_off = -1.15;
1283 int migration_processor_assignment_type = -1;
1284 int migration_doMigration_type = -1;
1285 bool test_boxes =
false;
1286 bool rectilinear =
false;
1300 migration_check_option,
1301 migration_all_to_all_type,
1302 migration_imbalance_cut_off,
1303 migration_processor_assignment_type,
1304 migration_doMigration_type,
1308 catch(std::string s){
1309 if(tcomm->getRank() == 0){
1316 if(tcomm->getRank() == 0){
1321 catch(
char const * s){
1322 if(tcomm->getRank() == 0){
1334 pqParts, paramFile, k,
1335 migration_check_option,
1336 migration_all_to_all_type,
1337 migration_imbalance_cut_off,
1338 migration_processor_assignment_type,
1339 migration_doMigration_type, test_boxes, rectilinear);
1341 #ifdef hopper_separate_test 1343 ierr = testFromSeparateDataFiles(tcomm,numParts, imbalance,fname,
1344 pqParts, paramFile, k,
1345 migration_check_option,
1346 migration_all_to_all_type,
1347 migration_imbalance_cut_off,
1348 migration_processor_assignment_type,
1349 migration_doMigration_type, test_boxes, rectilinear);
1354 pqParts, paramFile, k,
1355 migration_check_option,
1356 migration_all_to_all_type,
1357 migration_imbalance_cut_off,
1358 migration_processor_assignment_type,
1359 migration_doMigration_type, test_boxes, rectilinear);
1364 if (ierr == 0) std::cout <<
"PASS" << std::endl;
1365 else std::cout <<
"FAIL" << std::endl;
1370 catch(std::string &s){
1380 catch(
char const* s){
1385 Kokkos::finalize ();
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
#define CATCH_EXCEPTIONS_WITH_COUNT(ierr, pp)
void getLocalCoordinatesCopy(scalar_t **c)
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.
Defines the EvaluatePartition class.
int run_boxAssign_tests(Zoltan2::PartitioningProblem< Adapter > *problem, RCP< tMVector_t > &coords)
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...
An adapter for Xpetra::MultiVector.
#define CATCH_EXCEPTIONS_AND_RETURN(pp)
static const std::string fail
string convert_to_string(char *args)
void printTimers() const
Return the communicator passed to the problem.
const PartitioningSolution< Adapter > & getSolution()
Get the solution to the problem.
string trim_right_copy(const string &s, const string &delimiters=" \\\)
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_copy(const string &s, const string &delimiters=" \\\)
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.
A class that computes and returns quality metrics.
string trim_left_copy(const string &s, const string &delimiters=" \\\)
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(".")