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
231 const std::vector<Zoltan2::coordinateModelPartBox>
232 pBoxes = problem->
getSolution().getPartBoxesView();
233 for (
size_t i = 0; i < pBoxes.size(); i++) {
236 std::cout << me <<
" pBox " << i <<
" pid " << pBoxes[i].getpId()
237 <<
" (" << lmin[0] <<
"," << lmin[1] <<
","
238 << (coordDim > 2 ? lmin[2] : 0) <<
") x "
239 <<
" (" << lmax[0] <<
"," << lmax[1] <<
","
240 << (coordDim > 2 ? lmax[2] : 0) <<
")" << std::endl;
246 for (
int i = 0; i < coordDim; i++) pointDrop[i] = 0.;
248 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
251 std::cout << me <<
" OriginPoint (" << pointDrop[0];
252 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
253 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
254 std::cout <<
") part " << part << std::endl;
259 for (
int i = 0; i < coordDim; i++) pointDrop[i] = -100.+i;
261 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
264 std::cout << me <<
" NegativePoint (" << pointDrop[0];
265 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
266 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
267 std::cout <<
") part " << part << std::endl;
272 for (
int i = 0; i < coordDim; i++) pointDrop[i] = i*5;
274 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
277 std::cout << me <<
" i*5-Point (" << pointDrop[0];
278 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
279 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
280 std::cout <<
") part " << part << std::endl;
285 for (
int i = 0; i < coordDim; i++) pointDrop[i] = 10+i*5;
287 part = problem->
getSolution().pointAssign(coordDim, pointDrop);
290 std::cout << me <<
" WoopWoop-Point (" << pointDrop[0];
291 if (coordDim > 1) std::cout <<
" " << pointDrop[1];
292 if (coordDim > 2) std::cout <<
" " << pointDrop[2];
293 std::cout <<
") part " << part << std::endl;
300 template <
typename Adapter>
303 RCP<tMVector_t> &coords)
308 int coordDim = coords->getNumVectors();
313 sprintf(mechar,
"%d", problem->
getComm()->getRank());
316 const std::vector<Zoltan2::coordinateModelPartBox>
317 pBoxes = problem->
getSolution().getPartBoxesView();
318 size_t nBoxes = pBoxes.size();
324 size_t pickabox = nBoxes / 2;
325 for (
int i = 0; i < coordDim; i++) {
326 zscalar_t dd = 0.2 * (pBoxes[pickabox].getlmaxs()[i] -
327 pBoxes[pickabox].getlmins()[i]);
328 lower[i] = pBoxes[pickabox].getlmins()[i] + dd;
329 upper[i] = pBoxes[pickabox].getlmaxs()[i] - dd;
332 problem->
getSolution().boxAssign(coordDim, lower, upper,
337 std::cout << me <<
" FAIL boxAssign error: smaller test, nparts > 1"
341 print_boxAssign_result<Adapter>(
"smallerbox", coordDim,
342 lower, upper, nparts, parts);
350 size_t pickabox = nBoxes / 2;
351 for (
int i = 0; i < coordDim; i++) {
352 zscalar_t dd = 0.2 * (pBoxes[pickabox].getlmaxs()[i] -
353 pBoxes[pickabox].getlmins()[i]);
354 lower[i] = pBoxes[pickabox].getlmins()[i] - dd;
355 upper[i] = pBoxes[pickabox].getlmaxs()[i] + dd;
358 problem->
getSolution().boxAssign(coordDim, lower, upper,
364 if ((nBoxes > 1) && (nparts < 2)) {
365 std::cout << me <<
" FAIL boxAssign error: "
366 <<
"larger test, nparts < 2"
372 bool found_pickabox = 0;
373 for (
size_t i = 0; i < nparts; i++)
374 if (parts[i] == pBoxes[pickabox].getpId()) {
378 if (!found_pickabox) {
379 std::cout << me <<
" FAIL boxAssign error: "
380 <<
"larger test, pickabox not found"
385 print_boxAssign_result<Adapter>(
"largerbox", coordDim,
386 lower, upper, nparts, parts);
394 for (
int i = 0; i < coordDim; i++) {
395 lower[i] = std::numeric_limits<zscalar_t>::max();
396 upper[i] = std::numeric_limits<zscalar_t>::min();
398 for (
size_t j = 0; j < nBoxes; j++) {
399 for (
int i = 0; i < coordDim; i++) {
400 if (pBoxes[j].getlmins()[i] <= lower[i])
401 lower[i] = pBoxes[j].getlmins()[i];
402 if (pBoxes[j].getlmaxs()[i] >= upper[i])
403 upper[i] = pBoxes[j].getlmaxs()[i];
407 problem->
getSolution().boxAssign(coordDim, lower, upper,
413 if (nparts != nBoxes) {
414 std::cout << me <<
" FAIL boxAssign error: "
415 <<
"global test, nparts found " << nparts
416 <<
" != num global parts " << nBoxes
420 print_boxAssign_result<Adapter>(
"globalbox", coordDim,
421 lower, upper, nparts, parts);
431 for (
int i = 0; i < coordDim; i++) {
437 problem->
getSolution().boxAssign(coordDim, lower, upper,
443 if (nparts != nBoxes) {
444 std::cout << me <<
" FAIL boxAssign error: "
445 <<
"bigdomain test, nparts found " << nparts
446 <<
" != num global parts " << nBoxes
450 print_boxAssign_result<Adapter>(
"bigdomainbox", coordDim,
451 lower, upper, nparts, parts);
461 for (
int i = 0; i < coordDim; i++) {
462 lower[i] = upper[i] + 10;
467 problem->
getSolution().boxAssign(coordDim, lower, upper,
475 std::cout << me <<
" FAIL boxAssign error: "
476 <<
"outthere test, nparts found " << nparts
481 print_boxAssign_result<Adapter>(
"outthere box", coordDim,
482 lower, upper, nparts, parts);
491 void readGeoGenParams(
string paramFileName, Teuchos::ParameterList &geoparams,
const RCP<
const Teuchos::Comm<int> > & comm){
492 std::string input =
"";
494 for(
int i = 0; i < 25000; ++i){
499 if(comm->getRank() == 0){
501 std::fstream inParam(paramFileName.c_str());
508 std::string tmp =
"";
509 getline (inParam,tmp);
510 while (!inParam.eof()){
517 getline (inParam,tmp);
520 for (
size_t i = 0; i < input.size(); ++i){
528 int size = input.size();
532 comm->broadcast(0,
sizeof(
int), (
char*) &size);
534 throw "File " + paramFileName +
" cannot be opened.";
536 comm->broadcast(0, size, inp);
537 std::istringstream inParam(inp);
539 getline (inParam,str);
540 while (!inParam.eof()){
542 size_t pos = str.find(
'=');
543 if(pos == string::npos){
544 throw "Invalid Line:" + str +
" in parameter file";
546 string paramname =
trim_copy(str.substr(0,pos));
547 string paramvalue =
trim_copy(str.substr(pos + 1));
548 geoparams.set(paramname, paramvalue);
550 getline (inParam,str);
555 int numParts,
float imbalance,
556 std::string paramFile, std::string pqParts,
559 int migration_check_option,
560 int migration_all_to_all_type,
562 int migration_processor_assignment_type,
563 int migration_doMigration_type,
566 int mj_premigration_option,
567 int mj_premigration_coordinate_cutoff
571 Teuchos::ParameterList geoparams(
"geo params");
582 for(
int i = 0; i < coord_dim; ++i){
583 coords[i] =
new zscalar_t[numLocalPoints];
587 if (numWeightsPerCoord) {
588 weight=
new zscalar_t * [numWeightsPerCoord];
589 for(
int i = 0; i < numWeightsPerCoord; ++i){
590 weight[i] =
new zscalar_t[numLocalPoints];
597 RCP<Tpetra::Map<zlno_t, zgno_t, znode_t> > mp = rcp(
598 new Tpetra::Map<zlno_t, zgno_t, znode_t>(numGlobalPoints,
599 numLocalPoints, 0, comm));
601 Teuchos::Array<Teuchos::ArrayView<const zscalar_t> > coordView(coord_dim);
602 for (
int i=0; i < coord_dim; i++){
603 if(numLocalPoints > 0){
604 Teuchos::ArrayView<const zscalar_t> a(coords[i], numLocalPoints);
608 Teuchos::ArrayView<const zscalar_t> a;
613 RCP<tMVector_t> tmVector = RCP<tMVector_t>(
new
617 RCP<const tMVector_t> coordsConst =
618 Teuchos::rcp_const_cast<
const tMVector_t>(tmVector);
619 std::vector<const zscalar_t *>
weights;
620 if(numWeightsPerCoord){
621 for (
int i = 0; i < numWeightsPerCoord;++i){
622 weights.push_back(weight[i]);
625 std::vector<int> stride;
630 inputAdapter_t *ia =
new inputAdapter_t(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");
649 params->set(
"mj_keep_part_boxes",
true);
651 params->set(
"rectilinear",
true );
654 params->set(
"imbalance_tolerance",
double(imbalance));
655 params->set(
"mj_premigration_option", mj_premigration_option);
656 if (mj_premigration_coordinate_cutoff > 0){
657 params->set(
"mj_premigration_coordinate_count",
658 mj_premigration_coordinate_cutoff);
662 params->set(
"mj_parts", pqParts);
664 params->set(
"num_global_parts", numParts);
666 params->set(
"mj_concurrent_part_count", k);
667 if(migration_check_option >= 0)
668 params->set(
"mj_migration_option", migration_check_option);
669 if(migration_imbalance_cut_off >= 0)
670 params->set(
"mj_minimum_migration_imbalance",
671 double(migration_imbalance_cut_off));
688 RCP<quality_t> metricObject =
689 rcp(
new quality_t(ia,params.getRawPtr(),comm,&problem->
getSolution()));
691 if (comm->getRank() == 0){
692 metricObject->printMetrics(std::cout);
698 ierr = run_pointAssign_tests<inputAdapter_t>(problem, tmVector);
699 ierr += run_boxAssign_tests<inputAdapter_t>(problem, tmVector);
702 if(numWeightsPerCoord){
703 for(
int i = 0; i < numWeightsPerCoord; ++i)
708 for(
int i = 0; i < coord_dim; ++i)
718 RCP<
const Teuchos::Comm<int> > &comm,
725 int migration_check_option,
726 int migration_all_to_all_type,
728 int migration_processor_assignment_type,
729 int migration_doMigration_type,
732 int mj_premigration_option,
733 int mj_premigration_coordinate_cutoff
745 RCP<const tMVector_t> coordsConst = rcp_const_cast<
const tMVector_t>(coords);
748 inputAdapter_t *ia =
new inputAdapter_t(coordsConst);
750 Teuchos::RCP <Teuchos::ParameterList> params ;
754 params = Teuchos::getParametersFromXmlFile(pfname);
757 params =RCP <Teuchos::ParameterList> (
new Teuchos::ParameterList,
true);
762 params->set(
"mj_keep_part_boxes",
true);
764 params->set(
"rectilinear",
true);
765 params->set(
"algorithm",
"multijagged");
767 params->set(
"imbalance_tolerance",
double(imbalance));
771 params->set(
"mj_parts", pqParts);
773 params->set(
"mj_premigration_option", mj_premigration_option);
776 params->set(
"num_global_parts", numParts);
779 params->set(
"mj_concurrent_part_count", k);
781 if(migration_check_option >= 0){
782 params->set(
"mj_migration_option", migration_check_option);
784 if(migration_imbalance_cut_off >= 0){
785 params->set(
"mj_minimum_migration_imbalance",
786 double (migration_imbalance_cut_off));
788 if (mj_premigration_coordinate_cutoff > 0){
789 params->set(
"mj_premigration_coordinate_count",
790 mj_premigration_coordinate_cutoff);
808 const int bvme = comm->getRank();
809 const inputAdapter_t::lno_t bvlen =
810 inputAdapter_t::lno_t(coords->getLocalLength());
811 const size_t bvnvecs = coords->getNumVectors();
812 const size_t bvsize = coords->getNumVectors() * coords->getLocalLength();
814 ArrayRCP<inputAdapter_t::scalar_t> *bvtpetravectors =
815 new ArrayRCP<inputAdapter_t::scalar_t>[bvnvecs];
816 for (
size_t i = 0; i < bvnvecs; i++)
817 bvtpetravectors[i] = coords->getDataNonConst(i);
820 inputAdapter_t::gno_t *bvgids =
new
821 inputAdapter_t::gno_t[coords->getLocalLength()];
822 inputAdapter_t::scalar_t *bvcoordarr =
new inputAdapter_t::scalar_t[bvsize];
823 for (inputAdapter_t::lno_t j = 0; j < bvlen; j++) {
824 bvgids[j] = coords->getMap()->getGlobalElement(j);
825 for (
size_t i = 0; i < bvnvecs; i++) {
826 bvcoordarr[idx++] = bvtpetravectors[i][j];
831 inputAdapter_t::lno_t,
832 inputAdapter_t::gno_t> bvtypes_t;
834 std::vector<const inputAdapter_t::scalar_t *> bvcoords(bvnvecs);
835 std::vector<int> bvstrides(bvnvecs);
836 for (
size_t i = 0; i < bvnvecs; i++) {
837 bvcoords[i] = &bvcoordarr[i];
838 bvstrides[i] = bvnvecs;
840 std::vector<const inputAdapter_t::scalar_t *> bvwgts;
841 std::vector<int> bvwgtstrides;
843 bvadapter_t bvia(bvlen, bvgids, bvcoords, bvstrides,
844 bvwgts, bvwgtstrides);
860 for (inputAdapter_t::lno_t i = 0; i < bvlen; i++) {
863 std::cout << bvme <<
" " << i <<
" "
864 << coords->getMap()->getGlobalElement(i) <<
" " << bvgids[i]
865 <<
": XMV " << problem->
getSolution().getPartListView()[i]
866 <<
"; BMV " << bvproblem->
getSolution().getPartListView()[i]
867 <<
" : FAIL" << std::endl;
871 delete [] bvcoordarr;
872 delete [] bvtpetravectors;
876 if (coordsConst->getGlobalLength() < 40) {
877 int len = coordsConst->getLocalLength();
880 for (
int i = 0; i < len; i++)
881 std::cout << comm->getRank()
883 <<
" gid " << coords->getMap()->getGlobalElement(i)
884 <<
" part " << zparts[i] << std::endl;
889 RCP<quality_t> metricObject =
890 rcp(
new quality_t(ia,params.getRawPtr(),comm,&problem->
getSolution()));
892 if (comm->getRank() == 0){
893 metricObject->printMetrics(std::cout);
894 std::cout <<
"testFromDataFile is done " << std::endl;
901 ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
902 ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
910 #ifdef hopper_separate_test
912 template <
typename zscalar_t,
typename zlno_t>
914 FILE *f = fopen(fileName.c_str(),
"r");
916 std::cout << fileName <<
" cannot be opened" << std::endl;
919 fscanf(f,
"%d", &numLocal);
920 fscanf(f,
"%d", &dim);
922 for (
int i = 0; i < dim; ++i){
925 for (
int i = 0; i < dim; ++i){
926 for (
zlno_t j = 0; j < numLocal; ++j){
927 fscanf(f,
"%lf", &(coords[i][j]));
931 std::cout <<
"done reading:" << fileName << std::endl;
934 int testFromSeparateDataFiles(
935 RCP<
const Teuchos::Comm<int> > &comm,
942 int migration_check_option,
943 int migration_all_to_all_type,
945 int migration_processor_assignment_type,
946 int migration_doMigration_type,
949 int mj_premigration_option
956 int mR = comm->getRank();
957 if (mR == 0) std::cout <<
"size of zscalar_t:" <<
sizeof(
zscalar_t) << std::endl;
958 string tFile = fname +
"_" + Teuchos::toString<int>(mR) +
".mtx";
962 getCoords<zscalar_t, zlno_t>(double_coords, numLocal, dim, tFile);
964 Teuchos::Array<Teuchos::ArrayView<const zscalar_t> > coordView(dim);
965 for (
int i=0; i < dim; i++){
967 Teuchos::ArrayView<const zscalar_t> a(double_coords[i], numLocal);
970 Teuchos::ArrayView<const zscalar_t> a;
977 Teuchos::Comm<int> *tcomm = (Teuchos::Comm<int> *)comm.getRawPtr();
979 reduceAll<int, zgno_t>(
988 RCP<Tpetra::Map<zlno_t, zgno_t, znode_t> > mp = rcp(
989 new Tpetra::Map<zlno_t, zgno_t, znode_t> (numGlobal, numLocal, 0, comm));
990 RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >coords = RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >(
991 new Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t>( mp, coordView.view(0, dim), dim));
994 RCP<const tMVector_t> coordsConst = rcp_const_cast<
const tMVector_t>(coords);
999 inputAdapter_t *ia =
new inputAdapter_t(coordsConst);
1003 Teuchos::RCP <Teuchos::ParameterList> params ;
1007 params = Teuchos::getParametersFromXmlFile(pfname);
1010 params =RCP <Teuchos::ParameterList> (
new Teuchos::ParameterList,
true);
1014 params->set(
"algorithm",
"multijagged");
1016 params->set(
"imbalance_tolerance",
double(imbalance));
1019 params->set(
"mj_premigration_option", mj_premigration_option);
1021 params->set(
"mj_parts", pqParts);
1024 params->set(
"num_global_parts", numParts);
1027 params->set(
"parallel_part_calculation_count", k);
1029 if(migration_processor_assignment_type >= 0){
1030 params->set(
"migration_processor_assignment_type", migration_processor_assignment_type);
1032 if(migration_check_option >= 0){
1033 params->set(
"migration_check_option", migration_check_option);
1035 if(migration_all_to_all_type >= 0){
1036 params->set(
"migration_all_to_all_type", migration_all_to_all_type);
1038 if(migration_imbalance_cut_off >= 0){
1039 params->set(
"migration_imbalance_cut_off",
1040 double (migration_imbalance_cut_off));
1042 if (migration_doMigration_type >= 0){
1043 params->set(
"migration_doMigration_type",
int (migration_doMigration_type));
1046 params->set(
"mj_keep_part_boxes",
true);
1048 params->set(
"rectilinear",
true);
1064 if (coordsConst->getGlobalLength() < 40) {
1065 int len = coordsConst->getLocalLength();
1068 for (
int i = 0; i < len; i++)
1069 std::cout << comm->getRank()
1070 <<
" gid " << coords->getMap()->getGlobalElement(i)
1071 <<
" part " << zparts[i] << std::endl;
1076 RCP<quality_t> metricObject =
1077 rcp(
new quality_t(ia,params.getRawPtr(),comm,&problem->
getSolution()));
1079 if (comm->getRank() == 0){
1080 metricObject->printMetrics(std::cout);
1081 std::cout <<
"testFromDataFile is done " << std::endl;
1088 ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
1089 ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
1102 for(
int i = 0; args[i] != 0; i++)
1107 std::stringstream stream(std::stringstream::in | std::stringstream::out);
1108 stream << argumentline;
1109 getline(stream, argumentid,
'=');
1113 stream >> argumentValue;
1125 std::string &pfname,
1127 int &migration_check_option,
1128 int &migration_all_to_all_type,
1130 int &migration_processor_assignment_type,
1131 int &migration_doMigration_type,
1134 int &mj_premigration_option,
1135 int &mj_coordinate_cutoff
1138 bool isCset =
false;
1139 bool isPset =
false;
1140 bool isFset =
false;
1141 bool isPFset =
false;
1143 for(
int i = 0; i < narg; ++i){
1145 string identifier =
"";
1146 long long int value = -1;
double fval = -1;
1148 value = (
long long int) (fval);
1150 if(identifier ==
"C"){
1155 throw "Invalid argument at " + tmp;
1157 }
else if(identifier ==
"P"){
1158 std::stringstream stream(std::stringstream::in | std::stringstream::out);
1161 getline(stream, ttmp,
'=');
1164 }
else if(identifier ==
"I"){
1168 throw "Invalid argument at " + tmp;
1170 }
else if(identifier ==
"MI"){
1172 migration_imbalance_cut_off=fval;
1174 throw "Invalid argument at " + tmp;
1176 }
else if(identifier ==
"MO"){
1178 migration_check_option = value;
1180 throw "Invalid argument at " + tmp;
1182 }
else if(identifier ==
"AT"){
1184 migration_processor_assignment_type = value;
1186 throw "Invalid argument at " + tmp;
1190 else if(identifier ==
"MT"){
1192 migration_all_to_all_type = value;
1194 throw "Invalid argument at " + tmp;
1197 else if(identifier ==
"PCC"){
1199 mj_coordinate_cutoff = value;
1201 throw "Invalid argument at " + tmp;
1205 else if(identifier ==
"PM"){
1207 mj_premigration_option = value;
1209 throw "Invalid argument at " + tmp;
1213 else if(identifier ==
"DM"){
1215 migration_doMigration_type = value;
1217 throw "Invalid argument at " + tmp;
1220 else if(identifier ==
"F"){
1221 std::stringstream stream(std::stringstream::in | std::stringstream::out);
1223 getline(stream, fname,
'=');
1228 else if(identifier ==
"PF"){
1229 std::stringstream stream(std::stringstream::in | std::stringstream::out);
1231 getline(stream, pfname,
'=');
1237 else if(identifier ==
"O"){
1238 if(value >= 0 && value <= 3){
1241 throw "Invalid argument at " + tmp;
1244 else if(identifier ==
"K"){
1248 throw "Invalid argument at " + tmp;
1251 else if(identifier ==
"TB"){
1253 test_boxes = (value == 0 ?
false :
true);
1255 throw "Invalid argument at " + tmp;
1258 else if(identifier ==
"R"){
1260 rectilinear = (value == 0 ?
false :
true);
1262 throw "Invalid argument at " + tmp;
1266 throw "Invalid argument at " + tmp;
1270 if(!( (isCset || isPset || isPFset) && isFset)){
1271 throw "(C || P || PF) && F are mandatory arguments.";
1277 std::cout <<
"\nUsage:" << std::endl;
1278 std::cout << executable <<
" arglist" << std::endl;
1279 std::cout <<
"arglist:" << std::endl;
1280 std::cout <<
"\tC=numParts: numParts > 0" << std::endl;
1281 std::cout <<
"\tP=MultiJaggedPart: Example: P=512,512" << std::endl;
1282 std::cout <<
"\tI=imbalance: Example I=1.03 (ignored for now.)" << std::endl;
1283 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;
1284 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;
1285 std::cout <<
"\tK=concurrent part calculation input: K>0." << std::endl;
1286 std::cout <<
"\tMI=migration_imbalance_cut_off: MI=1.35. " << std::endl;
1287 std::cout <<
"\tMT=migration_all_to_all_type: 0 for alltoallv, 1 for Zoltan_Comm, 2 for Zoltan2 Distributor object(Default 1)." << std::endl;
1288 std::cout <<
"\tMO=migration_check_option: 0 for decision on imbalance, 1 for forcing migration, >1 for avoiding migration. (Default-0)" << std::endl;
1289 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;
1290 std::cout <<
"Example:\n" << executable <<
" P=2,2,2 C=8 F=simple O=0" << std::endl;
1295 Tpetra::ScopeGuard tscope(&narg, &arg);
1296 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = Tpetra::getDefaultComm();
1298 int rank = tcomm->getRank();
1302 float imbalance = -1.03;
1305 string pqParts =
"";
1307 std::string fname =
"";
1308 std::string paramFile =
"";
1311 int migration_check_option = -2;
1312 int migration_all_to_all_type = -1;
1313 zscalar_t migration_imbalance_cut_off = -1.15;
1314 int migration_processor_assignment_type = -1;
1315 int migration_doMigration_type = -1;
1316 int mj_premigration_option = 0;
1317 int mj_premigration_coordinate_cutoff = 0;
1319 bool test_boxes =
false;
1320 bool rectilinear =
false;
1334 migration_check_option,
1335 migration_all_to_all_type,
1336 migration_imbalance_cut_off,
1337 migration_processor_assignment_type,
1338 migration_doMigration_type,
1341 mj_premigration_option, mj_premigration_coordinate_cutoff);
1343 catch(std::string s){
1344 if(tcomm->getRank() == 0){
1351 if(tcomm->getRank() == 0){
1363 pqParts, paramFile, k,
1364 migration_check_option,
1365 migration_all_to_all_type,
1366 migration_imbalance_cut_off,
1367 migration_processor_assignment_type,
1368 migration_doMigration_type, test_boxes, rectilinear,
1369 mj_premigration_option, mj_premigration_coordinate_cutoff);
1371 #ifdef hopper_separate_test
1373 ierr = testFromSeparateDataFiles(tcomm,numParts, imbalance,fname,
1374 pqParts, paramFile, k,
1375 migration_check_option,
1376 migration_all_to_all_type,
1377 migration_imbalance_cut_off,
1378 migration_processor_assignment_type,
1379 migration_doMigration_type, test_boxes, rectilinear,
1380 mj_premigration_option);
1385 pqParts, paramFile, k,
1386 migration_check_option,
1387 migration_all_to_all_type,
1388 migration_imbalance_cut_off,
1389 migration_processor_assignment_type,
1390 migration_doMigration_type, test_boxes, rectilinear,
1391 mj_premigration_option, mj_premigration_coordinate_cutoff);
1396 if (ierr == 0) std::cout <<
"PASS" << std::endl;
1397 else std::cout <<
"FAIL" << std::endl;
1402 catch(std::string &s){
1404 std::cerr << s << std::endl;
1409 std::cerr << s << std::endl;
#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 narg, char *arg[])
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 getCoordinateDimension()
Defines the PartitioningSolution class.
common code used by tests
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)
Defines the XpetraMultiVectorAdapter.
string trim_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
SparseMatrixAdapter_t::part_t part_t
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...
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.
string trim_left_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
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, int mj_premigration_option, int mj_premigration_coordinate_cutoff)
void getArgVals(int narg, char **arg, 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, int &mj_premigration_option, int &mj_coordinate_cutoff)
int getNumWeights()
##END Predistribution functions######################//
bool getArgumentValue(string &argumentid, double &argumentValue, string argumentline)
lno_t getNumLocalCoords()
Defines the PartitioningProblem class.
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 mj_premigration_option, int mj_premigration_coordinate_cutoff)
A class that computes and returns quality metrics.
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(".")