61 #include "Teuchos_XMLParameterListHelpers.hpp"
63 #include <Teuchos_LAPACK.hpp>
71 #ifdef hopper_separate_test
74 #define CATCH_EXCEPTIONS_AND_RETURN(pp) \
75 catch (std::runtime_error &e) { \
76 std::cout << "Runtime exception returned from " << pp << ": " \
77 << e.what() << " FAIL" << std::endl; \
80 catch (std::logic_error &e) { \
81 std::cout << "Logic exception returned from " << pp << ": " \
82 << e.what() << " FAIL" << std::endl; \
85 catch (std::bad_alloc &e) { \
86 std::cout << "Bad_alloc exception returned from " << pp << ": " \
87 << e.what() << " FAIL" << std::endl; \
90 catch (std::exception &e) { \
91 std::cout << "Unknown exception returned from " << pp << ": " \
92 << e.what() << " FAIL" << std::endl; \
96 #define CATCH_EXCEPTIONS_WITH_COUNT(ierr, pp) \
97 catch (std::runtime_error &e) { \
98 std::cout << "Runtime exception returned from " << pp << ": " \
99 << e.what() << " FAIL" << std::endl; \
102 catch (std::logic_error &e) { \
103 std::cout << "Logic exception returned from " << pp << ": " \
104 << e.what() << " FAIL" << std::endl; \
107 catch (std::bad_alloc &e) { \
108 std::cout << "Bad_alloc exception returned from " << pp << ": " \
109 << e.what() << " FAIL" << std::endl; \
112 catch (std::exception &e) { \
113 std::cout << "Unknown exception returned from " << pp << ": " \
114 << e.what() << " FAIL" << std::endl; \
119 typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t>
tMVector_t;
130 const string& delimiters =
" \f\n\r\t\v" )
132 return s.substr( 0, s.find_last_not_of( delimiters ) + 1 );
137 const string& delimiters =
" \f\n\r\t\v" )
139 return s.substr( s.find_first_not_of( delimiters ) );
144 const string& delimiters =
" \f\n\r\t\v" )
149 template <
typename Adapter>
153 typename Adapter::scalar_t *lower,
154 typename Adapter::scalar_t *upper,
159 std::cout <<
"boxAssign test " << str <<
": Box (";
160 for (
int j = 0; j < dim; j++) std::cout << lower[j] <<
" ";
161 std::cout <<
") x (";
162 for (
int j = 0; j < dim; j++) std::cout << upper[j] <<
" ";
165 std::cout <<
") does not overlap any parts" << std::endl;
167 std::cout <<
") overlaps parts ";
168 for (
size_t k = 0; k < nparts; k++) std::cout << parts[k] <<
" ";
169 std::cout << std::endl;
173 template <
typename Adapter>
176 RCP<tMVector_t> &coords)
181 int coordDim = coords->getNumVectors();
186 sprintf(mechar,
"%d", problem->
getComm()->getRank());
194 size_t numPoints = coords->getLocalLength();
195 for (
size_t localID = 0; localID < numPoints; localID++) {
199 for (
int i = 0; i < coordDim; i++)
200 pointDrop[i] = coords->getData(i)[localID];
203 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
207 std::cout << me <<
" Point " << localID
208 <<
" gid " << coords->getMap()->getGlobalElement(localID)
209 <<
" (" << pointDrop[0];
210 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
211 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
212 std::cout <<
") in boxPart " << part
213 <<
" in solnPart " << solnPart
233 pBoxes = problem->
getSolution().getPartBoxesView();
234 for (
size_t i = 0; i < pBoxes.size(); i++) {
237 std::cout << me <<
" pBox " << i <<
" pid " << pBoxes[i].getpId()
238 <<
" (" << lmin[0] <<
"," << lmin[1] <<
","
239 << (coordDim > 2 ? lmin[2] : 0) <<
") x "
240 <<
" (" << lmax[0] <<
"," << lmax[1] <<
","
241 << (coordDim > 2 ? lmax[2] : 0) <<
")" << std::endl;
247 for (
int i = 0; i < coordDim; i++) pointDrop[i] = 0.;
249 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
252 std::cout << me <<
" OriginPoint (" << pointDrop[0];
253 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
254 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
255 std::cout <<
") part " << part << std::endl;
260 for (
int i = 0; i < coordDim; i++) pointDrop[i] = -100.+i;
262 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
265 std::cout << me <<
" NegativePoint (" << pointDrop[0];
266 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
267 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
268 std::cout <<
") part " << part << std::endl;
273 for (
int i = 0; i < coordDim; i++) pointDrop[i] = i*5;
275 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
278 std::cout << me <<
" i*5-Point (" << pointDrop[0];
279 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
280 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
281 std::cout <<
") part " << part << std::endl;
286 for (
int i = 0; i < coordDim; i++) pointDrop[i] = 10+i*5;
288 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
291 std::cout << me <<
" WoopWoop-Point (" << pointDrop[0];
292 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
293 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
294 std::cout <<
") part " << part << std::endl;
301 template <
typename Adapter>
304 RCP<tMVector_t> &coords)
309 int coordDim = coords->getNumVectors();
314 sprintf(mechar,
"%d", problem->
getComm()->getRank());
319 pBoxes = problem->
getSolution().getPartBoxesView();
320 size_t nBoxes = pBoxes.size();
326 size_t pickabox = nBoxes / 2;
327 for (
int i = 0; i < coordDim; i++) {
328 zscalar_t dd = 0.2 * (pBoxes[pickabox].getlmaxs()[i] -
329 pBoxes[pickabox].getlmins()[i]);
330 lower[i] = pBoxes[pickabox].getlmins()[i] + dd;
331 upper[i] = pBoxes[pickabox].getlmaxs()[i] - dd;
334 problem->
getSolution().boxAssign(coordDim, lower, upper,
339 std::cout << me <<
" FAIL boxAssign error: smaller test, nparts > 1"
343 print_boxAssign_result<Adapter>(
"smallerbox", coordDim,
344 lower, upper, nparts, parts);
352 size_t pickabox = nBoxes / 2;
353 for (
int i = 0; i < coordDim; i++) {
354 zscalar_t dd = 0.2 * (pBoxes[pickabox].getlmaxs()[i] -
355 pBoxes[pickabox].getlmins()[i]);
356 lower[i] = pBoxes[pickabox].getlmins()[i] - dd;
357 upper[i] = pBoxes[pickabox].getlmaxs()[i] + dd;
360 problem->
getSolution().boxAssign(coordDim, lower, upper,
366 if ((nBoxes > 1) && (nparts < 2)) {
367 std::cout << me <<
" FAIL boxAssign error: "
368 <<
"larger test, nparts < 2"
374 bool found_pickabox = 0;
375 for (
size_t i = 0; i < nparts; i++)
376 if (parts[i] == pBoxes[pickabox].getpId()) {
380 if (!found_pickabox) {
381 std::cout << me <<
" FAIL boxAssign error: "
382 <<
"larger test, pickabox not found"
387 print_boxAssign_result<Adapter>(
"largerbox", coordDim,
388 lower, upper, nparts, parts);
396 for (
int i = 0; i < coordDim; i++) {
397 lower[i] = std::numeric_limits<zscalar_t>::max();
398 upper[i] = std::numeric_limits<zscalar_t>::min();
400 for (
size_t j = 0; j < nBoxes; j++) {
401 for (
int i = 0; i < coordDim; i++) {
402 if (pBoxes[j].getlmins()[i] <= lower[i])
403 lower[i] = pBoxes[j].getlmins()[i];
404 if (pBoxes[j].getlmaxs()[i] >= upper[i])
405 upper[i] = pBoxes[j].getlmaxs()[i];
409 problem->
getSolution().boxAssign(coordDim, lower, upper,
415 if (nparts != nBoxes) {
416 std::cout << me <<
" FAIL boxAssign error: "
417 <<
"global test, nparts found " << nparts
418 <<
" != num global parts " << nBoxes
422 print_boxAssign_result<Adapter>(
"globalbox", coordDim,
423 lower, upper, nparts, parts);
433 for (
int i = 0; i < coordDim; i++) {
439 problem->
getSolution().boxAssign(coordDim, lower, upper,
445 if (nparts != nBoxes) {
446 std::cout << me <<
" FAIL boxAssign error: "
447 <<
"bigdomain test, nparts found " << nparts
448 <<
" != num global parts " << nBoxes
452 print_boxAssign_result<Adapter>(
"bigdomainbox", coordDim,
453 lower, upper, nparts, parts);
463 for (
int i = 0; i < coordDim; i++) {
464 lower[i] = upper[i] + 10;
469 problem->
getSolution().boxAssign(coordDim, lower, upper,
477 std::cout << me <<
" FAIL boxAssign error: "
478 <<
"outthere test, nparts found " << nparts
483 print_boxAssign_result<Adapter>(
"outthere box", coordDim,
484 lower, upper, nparts, parts);
493 void readGeoGenParams(
string paramFileName, Teuchos::ParameterList &geoparams,
const RCP<
const Teuchos::Comm<int> > & comm){
494 std::string input =
"";
496 for(
int i = 0; i < 25000; ++i){
501 if(comm->getRank() == 0){
503 std::fstream inParam(paramFileName.c_str());
510 std::string tmp =
"";
511 getline (inParam,tmp);
512 while (!inParam.eof()){
519 getline (inParam,tmp);
522 for (
size_t i = 0; i < input.size(); ++i){
530 int size = input.size();
534 comm->broadcast(0,
sizeof(
int), (
char*) &size);
536 throw "File " + paramFileName +
" cannot be opened.";
538 comm->broadcast(0, size, inp);
539 std::istringstream inParam(inp);
541 getline (inParam,str);
542 while (!inParam.eof()){
544 size_t pos = str.find(
'=');
545 if(pos == string::npos){
546 throw "Invalid Line:" + str +
" in parameter file";
548 string paramname =
trim_copy(str.substr(0,pos));
549 string paramvalue =
trim_copy(str.substr(pos + 1));
550 geoparams.set(paramname, paramvalue);
552 getline (inParam,str);
557 int numParts,
float imbalance,
558 std::string paramFile, std::string pqParts,
561 int migration_check_option,
562 int migration_all_to_all_type,
564 int migration_processor_assignment_type,
565 int migration_doMigration_type,
568 int mj_premigration_option
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 std::vector<const zscalar_t *>
weights;
621 if(numWeightsPerCoord){
622 for (
int i = 0; i < numWeightsPerCoord;++i){
626 std::vector<int> stride;
631 inputAdapter_t *ia =
new inputAdapter_t(coordsConst,
weights, stride);
633 Teuchos::RCP<Teuchos::ParameterList> params ;
637 params = Teuchos::getParametersFromXmlFile(pfname);
640 params =RCP<Teuchos::ParameterList>(
new Teuchos::ParameterList,
true);
646 params->set(
"timer_output_stream" ,
"std::cout");
648 params->set(
"algorithm",
"multijagged");
650 params->set(
"mj_keep_part_boxes",
true);
652 params->set(
"rectilinear",
true );
655 params->set(
"imbalance_tolerance",
double(imbalance));
656 params->set(
"mj_premigration_option", mj_premigration_option);
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(std::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,
729 int mj_premigration_option,
730 int mj_premigration_coordinate_cutoff
742 RCP<const tMVector_t> coordsConst = rcp_const_cast<const tMVector_t>(coords);
745 inputAdapter_t *ia =
new inputAdapter_t(coordsConst);
747 Teuchos::RCP <Teuchos::ParameterList> params ;
751 params = Teuchos::getParametersFromXmlFile(pfname);
754 params =RCP <Teuchos::ParameterList> (
new Teuchos::ParameterList,
true);
759 params->set(
"mj_keep_part_boxes",
true);
761 params->set(
"rectilinear",
true);
762 params->set(
"algorithm",
"multijagged");
764 params->set(
"imbalance_tolerance",
double(imbalance));
768 params->set(
"mj_parts", pqParts);
770 params->set(
"mj_premigration_option", mj_premigration_option);
773 params->set(
"num_global_parts", numParts);
776 params->set(
"mj_concurrent_part_count", k);
778 if(migration_check_option >= 0){
779 params->set(
"mj_migration_option", migration_check_option);
781 if(migration_imbalance_cut_off >= 0){
782 params->set(
"mj_minimum_migration_imbalance",
783 double (migration_imbalance_cut_off));
785 if (mj_premigration_coordinate_cutoff > 0){
786 params->set(
"mj_premigration_coordinate_count", mj_premigration_coordinate_cutoff);
804 const int bvme = comm->getRank();
805 const inputAdapter_t::lno_t bvlen =
806 inputAdapter_t::lno_t(coords->getLocalLength());
807 const size_t bvnvecs = coords->getNumVectors();
808 const size_t bvsize = coords->getNumVectors() * coords->getLocalLength();
810 ArrayRCP<inputAdapter_t::scalar_t> *bvtpetravectors =
811 new ArrayRCP<inputAdapter_t::scalar_t>[bvnvecs];
812 for (
size_t i = 0; i < bvnvecs; i++)
813 bvtpetravectors[i] = coords->getDataNonConst(i);
816 inputAdapter_t::gno_t *bvgids =
new
817 inputAdapter_t::gno_t[coords->getLocalLength()];
818 inputAdapter_t::scalar_t *bvcoordarr =
new inputAdapter_t::scalar_t[bvsize];
819 for (inputAdapter_t::lno_t j = 0; j < bvlen; j++) {
820 bvgids[j] = coords->getMap()->getGlobalElement(j);
821 for (
size_t i = 0; i < bvnvecs; i++) {
822 bvcoordarr[idx++] = bvtpetravectors[i][j];
827 inputAdapter_t::lno_t,
828 inputAdapter_t::gno_t> bvtypes_t;
830 std::vector<const inputAdapter_t::scalar_t *> bvcoords(bvnvecs);
831 std::vector<int> bvstrides(bvnvecs);
832 for (
size_t i = 0; i < bvnvecs; i++) {
833 bvcoords[i] = &bvcoordarr[i];
834 bvstrides[i] = bvnvecs;
836 std::vector<const inputAdapter_t::scalar_t *> bvwgts;
837 std::vector<int> bvwgtstrides;
839 bvadapter_t bvia(bvlen, bvgids, bvcoords, bvstrides,
840 bvwgts, bvwgtstrides);
856 for (inputAdapter_t::lno_t i = 0; i < bvlen; i++) {
859 std::cout << bvme <<
" " << i <<
" "
860 << coords->getMap()->getGlobalElement(i) <<
" " << bvgids[i]
861 <<
": XMV " << problem->
getSolution().getPartListView()[i]
862 <<
"; BMV " << bvproblem->
getSolution().getPartListView()[i]
863 <<
" : FAIL" << std::endl;
867 delete [] bvcoordarr;
868 delete [] bvtpetravectors;
872 if (coordsConst->getGlobalLength() < 40) {
873 int len = coordsConst->getLocalLength();
876 for (
int i = 0; i < len; i++)
877 std::cout << comm->getRank()
879 <<
" gid " << coords->getMap()->getGlobalElement(i)
880 <<
" part " << zparts[i] << std::endl;
885 RCP<quality_t> metricObject =
886 rcp(
new quality_t(ia,params.getRawPtr(),comm,&problem->
getSolution()));
888 if (comm->getRank() == 0){
889 metricObject->printMetrics(std::cout);
890 std::cout <<
"testFromDataFile is done " << std::endl;
897 ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
898 ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
906 #ifdef hopper_separate_test
908 template <
typename zscalar_t,
typename zlno_t>
910 FILE *f = fopen(fileName.c_str(),
"r");
912 std::cout << fileName <<
" cannot be opened" << std::endl;
915 fscanf(f,
"%d", &numLocal);
916 fscanf(f,
"%d", &dim);
918 for (
int i = 0; i < dim; ++i){
921 for (
int i = 0; i < dim; ++i){
922 for (
zlno_t j = 0; j < numLocal; ++j){
923 fscanf(f,
"%lf", &(coords[i][j]));
927 std::cout <<
"done reading:" << fileName << std::endl;
930 int testFromSeparateDataFiles(
931 RCP<
const Teuchos::Comm<int> > &comm,
938 int migration_check_option,
939 int migration_all_to_all_type,
941 int migration_processor_assignment_type,
942 int migration_doMigration_type,
945 int mj_premigration_option
952 int mR = comm->getRank();
953 if (mR == 0) std::cout <<
"size of zscalar_t:" <<
sizeof(
zscalar_t) << std::endl;
954 string tFile = fname +
"_" + Teuchos::toString<int>(mR) +
".mtx";
958 getCoords<zscalar_t, zlno_t>(double_coords, numLocal, dim, tFile);
960 Teuchos::Array<Teuchos::ArrayView<const zscalar_t> > coordView(dim);
961 for (
int i=0; i < dim; i++){
963 Teuchos::ArrayView<const zscalar_t> a(double_coords[i], numLocal);
966 Teuchos::ArrayView<const zscalar_t> a;
973 Teuchos::Comm<int> *tcomm = (Teuchos::Comm<int> *)comm.getRawPtr();
975 reduceAll<int, zgno_t>(
984 RCP<Tpetra::Map<zlno_t, zgno_t, znode_t> > mp = rcp(
985 new Tpetra::Map<zlno_t, zgno_t, znode_t> (numGlobal, numLocal, 0, comm));
986 RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >coords = RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >(
987 new Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t>( mp, coordView.view(0, dim), dim));
990 RCP<const tMVector_t> coordsConst = rcp_const_cast<const tMVector_t>(coords);
995 inputAdapter_t *ia =
new inputAdapter_t(coordsConst);
999 Teuchos::RCP <Teuchos::ParameterList> params ;
1003 params = Teuchos::getParametersFromXmlFile(pfname);
1006 params =RCP <Teuchos::ParameterList> (
new Teuchos::ParameterList,
true);
1010 params->set(
"algorithm",
"multijagged");
1012 params->set(
"imbalance_tolerance",
double(imbalance));
1015 params->set(
"mj_premigration_option", mj_premigration_option);
1017 params->set(
"mj_parts", pqParts);
1020 params->set(
"num_global_parts", numParts);
1023 params->set(
"parallel_part_calculation_count", k);
1025 if(migration_processor_assignment_type >= 0){
1026 params->set(
"migration_processor_assignment_type", migration_processor_assignment_type);
1028 if(migration_check_option >= 0){
1029 params->set(
"migration_check_option", migration_check_option);
1031 if(migration_all_to_all_type >= 0){
1032 params->set(
"migration_all_to_all_type", migration_all_to_all_type);
1034 if(migration_imbalance_cut_off >= 0){
1035 params->set(
"migration_imbalance_cut_off",
1036 double (migration_imbalance_cut_off));
1038 if (migration_doMigration_type >= 0){
1039 params->set(
"migration_doMigration_type",
int (migration_doMigration_type));
1042 params->set(
"mj_keep_part_boxes",
true);
1044 params->set(
"rectilinear",
true);
1060 if (coordsConst->getGlobalLength() < 40) {
1061 int len = coordsConst->getLocalLength();
1064 for (
int i = 0; i < len; i++)
1065 std::cout << comm->getRank()
1066 <<
" gid " << coords->getMap()->getGlobalElement(i)
1067 <<
" part " << zparts[i] << std::endl;
1072 RCP<quality_t> metricObject =
1073 rcp(
new quality_t(ia,params.getRawPtr(),comm,&problem->
getSolution()));
1075 if (comm->getRank() == 0){
1076 metricObject->printMetrics(std::cout);
1077 std::cout <<
"testFromDataFile is done " << std::endl;
1084 ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
1085 ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
1098 for(
int i = 0; args[i] != 0; i++)
1103 std::stringstream stream(std::stringstream::in | std::stringstream::out);
1104 stream << argumentline;
1105 getline(stream, argumentid,
'=');
1109 stream >> argumentValue;
1121 std::string &pfname,
1123 int &migration_check_option,
1124 int &migration_all_to_all_type,
1126 int &migration_processor_assignment_type,
1127 int &migration_doMigration_type,
1130 int &mj_premigration_option,
1131 int &mj_coordinate_cutoff
1134 bool isCset =
false;
1135 bool isPset =
false;
1136 bool isFset =
false;
1137 bool isPFset =
false;
1139 for(
int i = 0; i < narg; ++i){
1141 string identifier =
"";
1142 long long int value = -1;
double fval = -1;
1144 value = (
long long int) (fval);
1146 if(identifier ==
"C"){
1151 throw "Invalid argument at " + tmp;
1153 }
else if(identifier ==
"P"){
1154 std::stringstream stream(std::stringstream::in | std::stringstream::out);
1157 getline(stream, ttmp,
'=');
1160 }
else if(identifier ==
"I"){
1164 throw "Invalid argument at " + tmp;
1166 }
else if(identifier ==
"MI"){
1168 migration_imbalance_cut_off=fval;
1170 throw "Invalid argument at " + tmp;
1172 }
else if(identifier ==
"MO"){
1174 migration_check_option = value;
1176 throw "Invalid argument at " + tmp;
1178 }
else if(identifier ==
"AT"){
1180 migration_processor_assignment_type = value;
1182 throw "Invalid argument at " + tmp;
1186 else if(identifier ==
"MT"){
1188 migration_all_to_all_type = value;
1190 throw "Invalid argument at " + tmp;
1193 else if(identifier ==
"PCC"){
1195 mj_coordinate_cutoff = value;
1197 throw "Invalid argument at " + tmp;
1201 else if(identifier ==
"PM"){
1203 mj_premigration_option = value;
1205 throw "Invalid argument at " + tmp;
1209 else if(identifier ==
"DM"){
1211 migration_doMigration_type = value;
1213 throw "Invalid argument at " + tmp;
1216 else if(identifier ==
"F"){
1217 std::stringstream stream(std::stringstream::in | std::stringstream::out);
1219 getline(stream, fname,
'=');
1224 else if(identifier ==
"PF"){
1225 std::stringstream stream(std::stringstream::in | std::stringstream::out);
1227 getline(stream, pfname,
'=');
1233 else if(identifier ==
"O"){
1234 if(value >= 0 && value <= 3){
1237 throw "Invalid argument at " + tmp;
1240 else if(identifier ==
"K"){
1244 throw "Invalid argument at " + tmp;
1247 else if(identifier ==
"TB"){
1249 test_boxes = (value == 0 ? false :
true);
1251 throw "Invalid argument at " + tmp;
1254 else if(identifier ==
"R"){
1256 rectilinear = (value == 0 ? false :
true);
1258 throw "Invalid argument at " + tmp;
1262 throw "Invalid argument at " + tmp;
1266 if(!( (isCset || isPset || isPFset) && isFset)){
1267 throw "(C || P || PF) && F are mandatory arguments.";
1273 std::cout <<
"\nUsage:" << std::endl;
1274 std::cout << executable <<
" arglist" << std::endl;
1275 std::cout <<
"arglist:" << std::endl;
1276 std::cout <<
"\tC=numParts: numParts > 0" << std::endl;
1277 std::cout <<
"\tP=MultiJaggedPart: Example: P=512,512" << std::endl;
1278 std::cout <<
"\tI=imbalance: Example I=1.03 (ignored for now.)" << std::endl;
1279 std::cout <<
"\tF=filePath: When O=0 the path of the coordinate input file, for O>1 the path to the geometric generator parameter file." << std::endl;
1280 std::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." << std::endl;
1281 std::cout <<
"\tK=concurrent part calculation input: K>0." << std::endl;
1282 std::cout <<
"\tMI=migration_imbalance_cut_off: MI=1.35. " << std::endl;
1283 std::cout <<
"\tMT=migration_all_to_all_type: 0 for alltoallv, 1 for Zoltan_Comm, 2 for Zoltan2 Distributor object(Default 1)." << std::endl;
1284 std::cout <<
"\tMO=migration_check_option: 0 for decision on imbalance, 1 for forcing migration, >1 for avoiding migration. (Default-0)" << std::endl;
1285 std::cout <<
"\tAT=migration_processor_assignment_type. 0-for assigning procs with respect to proc ownment, otherwise, assignment with respect to proc closeness." << std::endl;
1286 std::cout <<
"Example:\n" << executable <<
" P=2,2,2 C=8 F=simple O=0" << std::endl;
1291 Tpetra::ScopeGuard tscope(&narg, &arg);
1292 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = Tpetra::getDefaultComm();
1294 int rank = tcomm->getRank();
1298 float imbalance = -1.03;
1301 string pqParts =
"";
1303 std::string fname =
"";
1304 std::string paramFile =
"";
1307 int migration_check_option = -2;
1308 int migration_all_to_all_type = -1;
1309 zscalar_t migration_imbalance_cut_off = -1.15;
1310 int migration_processor_assignment_type = -1;
1311 int migration_doMigration_type = -1;
1312 int mj_premigration_option = 0;
1313 int mj_premigration_coordinate_cutoff = 0;
1315 bool test_boxes =
false;
1316 bool rectilinear =
false;
1330 migration_check_option,
1331 migration_all_to_all_type,
1332 migration_imbalance_cut_off,
1333 migration_processor_assignment_type,
1334 migration_doMigration_type,
1336 rectilinear, mj_premigration_option, mj_premigration_coordinate_cutoff);
1338 catch(std::string s){
1339 if(tcomm->getRank() == 0){
1346 if(tcomm->getRank() == 0){
1358 pqParts, paramFile, k,
1359 migration_check_option,
1360 migration_all_to_all_type,
1361 migration_imbalance_cut_off,
1362 migration_processor_assignment_type,
1363 migration_doMigration_type, test_boxes, rectilinear, mj_premigration_option, mj_premigration_coordinate_cutoff);
1365 #ifdef hopper_separate_test
1367 ierr = testFromSeparateDataFiles(tcomm,numParts, imbalance,fname,
1368 pqParts, paramFile, k,
1369 migration_check_option,
1370 migration_all_to_all_type,
1371 migration_imbalance_cut_off,
1372 migration_processor_assignment_type,
1373 migration_doMigration_type, test_boxes, rectilinear, mj_premigration_option);
1378 pqParts, paramFile, k,
1379 migration_check_option,
1380 migration_all_to_all_type,
1381 migration_imbalance_cut_off,
1382 migration_processor_assignment_type,
1383 migration_doMigration_type, test_boxes, rectilinear, mj_premigration_option);
1388 if (ierr == 0) std::cout <<
"PASS" << std::endl;
1389 else std::cout <<
"FAIL" << std::endl;
1394 catch(std::string &s){
1396 std::cerr << s << std::endl;
1401 std::cerr << s << std::endl;