Zoltan2
MultiJaggedTest.cpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Zoltan2: A package of combinatorial algorithms for scientific computing
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Karen Devine (kddevin@sandia.gov)
39 // Erik Boman (egboman@sandia.gov)
40 // Siva Rajamanickam (srajama@sandia.gov)
41 //
42 // ***********************************************************************
43 //
44 // @HEADER
45 
51 #include <Zoltan2_TestHelpers.hpp>
56 #include <GeometricGenerator.hpp>
57 #include <vector>
58 
60 
61 #include "Teuchos_XMLParameterListHelpers.hpp"
62 
63 #include <Teuchos_LAPACK.hpp>
64 #include <fstream>
65 #include <string>
66 using Teuchos::RCP;
67 using Teuchos::rcp;
68 
69 
70 //#define hopper_separate_test
71 #ifdef hopper_separate_test
72 #include "stdio.h"
73 #endif
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; \
78  return -1; \
79  } \
80  catch (std::logic_error &e) { \
81  std::cout << "Logic exception returned from " << pp << ": " \
82  << e.what() << " FAIL" << std::endl; \
83  return -1; \
84  } \
85  catch (std::bad_alloc &e) { \
86  std::cout << "Bad_alloc exception returned from " << pp << ": " \
87  << e.what() << " FAIL" << std::endl; \
88  return -1; \
89  } \
90  catch (std::exception &e) { \
91  std::cout << "Unknown exception returned from " << pp << ": " \
92  << e.what() << " FAIL" << std::endl; \
93  return -1; \
94  }
95 
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; \
100  (ierr)++; \
101  } \
102  catch (std::logic_error &e) { \
103  std::cout << "Logic exception returned from " << pp << ": " \
104  << e.what() << " FAIL" << std::endl; \
105  (ierr)++; \
106  } \
107  catch (std::bad_alloc &e) { \
108  std::cout << "Bad_alloc exception returned from " << pp << ": " \
109  << e.what() << " FAIL" << std::endl; \
110  (ierr)++; \
111  } \
112  catch (std::exception &e) { \
113  std::cout << "Unknown exception returned from " << pp << ": " \
114  << e.what() << " FAIL" << std::endl; \
115  (ierr)++; \
116  }
117 
118 
119 typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> tMVector_t;
120 
126 const char param_comment = '#';
127 
129  const string& s,
130  const string& delimiters = " \f\n\r\t\v" )
131 {
132  return s.substr( 0, s.find_last_not_of( delimiters ) + 1 );
133 }
134 
136  const string& s,
137  const string& delimiters = " \f\n\r\t\v" )
138 {
139  return s.substr( s.find_first_not_of( delimiters ) );
140 }
141 
142 string trim_copy(
143  const string& s,
144  const string& delimiters = " \f\n\r\t\v" )
145 {
146  return trim_left_copy( trim_right_copy( s, delimiters ), delimiters );
147 }
148 
149 template <typename Adapter>
151  const char *str,
152  int dim,
153  typename Adapter::scalar_t *lower,
154  typename Adapter::scalar_t *upper,
155  size_t nparts,
156  typename Adapter::part_t *parts
157 )
158 {
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] << " ";
163 
164  if (nparts == 0)
165  std::cout << ") does not overlap any parts" << std::endl;
166  else {
167  std::cout << ") overlaps parts ";
168  for (size_t k = 0; k < nparts; k++) std::cout << parts[k] << " ";
169  std::cout << std::endl;
170  }
171 }
172 
173 template <typename Adapter>
176  RCP<tMVector_t> &coords)
177 {
178  int ierr = 0;
179 
180  // pointAssign tests
181  int coordDim = coords->getNumVectors();
182  zscalar_t *pointDrop = new zscalar_t[coordDim];
183  typename Adapter::part_t part = -1;
184 
185  char mechar[10];
186  sprintf(mechar, "%d", problem->getComm()->getRank());
187  string me(mechar);
188 
189  // test correctness of pointAssign for owned points
190  {
191  const typename Adapter::part_t *solnPartView =
192  problem->getSolution().getPartListView();
193 
194  size_t numPoints = coords->getLocalLength();
195  for (size_t localID = 0; localID < numPoints; localID++) {
196 
197  typename Adapter::part_t solnPart = solnPartView[localID];
198 
199  for (int i = 0; i < coordDim; i++)
200  pointDrop[i] = coords->getData(i)[localID];
201 
202  try {
203  part = problem->getSolution().pointAssign(coordDim, pointDrop);
204  }
205  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + ": pointAssign -- OwnedPoints");
206 
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
214  << std::endl;
215 
216 // this error test does not work for points that fall on the cuts.
217 // like Zoltan's RCB, pointAssign arbitrarily picks a part along the cut.
218 // the arbitrarily chosen part will not necessarily be the one to which
219 // the coordinate was assigned in partitioning.
220 //
221 // if (part != solnPart) {
222 // std::cout << me << " pointAssign: incorrect part " << part
223 // << " found; should be " << solnPart
224 // << " for point " << j << std::endl;
225 // ierr++;
226 // }
227  }
228  }
229 
230  {
231  const std::vector<Zoltan2::coordinateModelPartBox<zscalar_t,
232  typename Adapter::part_t> >
233  pBoxes = problem->getSolution().getPartBoxesView();
234  for (size_t i = 0; i < pBoxes.size(); i++) {
235  zscalar_t *lmin = pBoxes[i].getlmins();
236  zscalar_t *lmax = pBoxes[i].getlmaxs();;
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;
242  }
243  }
244 
245  // test the origin
246  {
247  for (int i = 0; i < coordDim; i++) pointDrop[i] = 0.;
248  try {
249  part = problem->getSolution().pointAssign(coordDim, pointDrop);
250  }
251  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " pointAssign -- Origin");
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;
256  }
257 
258  // test point with negative coordinates
259  {
260  for (int i = 0; i < coordDim; i++) pointDrop[i] = -100.+i;
261  try {
262  part = problem->getSolution().pointAssign(coordDim, pointDrop);
263  }
264  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " pointAssign -- Negative Point");
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;
269  }
270 
271  // test a point that's way out there
272  {
273  for (int i = 0; i < coordDim; i++) pointDrop[i] = i*5;
274  try {
275  part = problem->getSolution().pointAssign(coordDim, pointDrop);
276  }
277  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " pointAssign -- i*5 Point");
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;
282  }
283 
284  // test a point that's way out there
285  {
286  for (int i = 0; i < coordDim; i++) pointDrop[i] = 10+i*5;
287  try {
288  part = problem->getSolution().pointAssign(coordDim, pointDrop);
289  }
290  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " pointAssign -- WoopWoop");
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;
295  }
296 
297  delete [] pointDrop;
298  return ierr;
299 }
300 
301 template <typename Adapter>
304  RCP<tMVector_t> &coords)
305 {
306  int ierr = 0;
307 
308  // boxAssign tests
309  int coordDim = coords->getNumVectors();
310  zscalar_t *lower = new zscalar_t[coordDim];
311  zscalar_t *upper = new zscalar_t[coordDim];
312 
313  char mechar[10];
314  sprintf(mechar, "%d", problem->getComm()->getRank());
315  string me(mechar);
316 
317  const std::vector<Zoltan2::coordinateModelPartBox<zscalar_t,
318  typename Adapter::part_t> >
319  pBoxes = problem->getSolution().getPartBoxesView();
320  size_t nBoxes = pBoxes.size();
321 
322  // test a box that is smaller than a part
323  {
324  size_t nparts;
325  typename Adapter::part_t *parts;
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;
332  }
333  try {
334  problem->getSolution().boxAssign(coordDim, lower, upper,
335  nparts, &parts);
336  }
337  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " boxAssign -- smaller");
338  if (nparts > 1) {
339  std::cout << me << " FAIL boxAssign error: smaller test, nparts > 1"
340  << std::endl;
341  ierr++;
342  }
343  print_boxAssign_result<Adapter>("smallerbox", coordDim,
344  lower, upper, nparts, parts);
345  delete [] parts;
346  }
347 
348  // test a box that is larger than a part
349  {
350  size_t nparts;
351  typename Adapter::part_t *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;
358  }
359  try {
360  problem->getSolution().boxAssign(coordDim, lower, upper,
361  nparts, &parts);
362  }
363  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " boxAssign -- larger");
364 
365  // larger box should have at least two parts in it for k > 1.
366  if ((nBoxes > 1) && (nparts < 2)) {
367  std::cout << me << " FAIL boxAssign error: "
368  << "larger test, nparts < 2"
369  << std::endl;
370  ierr++;
371  }
372 
373  // parts should include pickabox's part
374  bool found_pickabox = 0;
375  for (size_t i = 0; i < nparts; i++)
376  if (parts[i] == pBoxes[pickabox].getpId()) {
377  found_pickabox = 1;
378  break;
379  }
380  if (!found_pickabox) {
381  std::cout << me << " FAIL boxAssign error: "
382  << "larger test, pickabox not found"
383  << std::endl;
384  ierr++;
385  }
386 
387  print_boxAssign_result<Adapter>("largerbox", coordDim,
388  lower, upper, nparts, parts);
389  delete [] parts;
390  }
391 
392  // test a box that includes all parts
393  {
394  size_t nparts;
395  typename Adapter::part_t *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();
399  }
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];
406  }
407  }
408  try {
409  problem->getSolution().boxAssign(coordDim, lower, upper,
410  nparts, &parts);
411  }
412  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " boxAssign -- global");
413 
414  // global box should have all parts
415  if (nparts != nBoxes) {
416  std::cout << me << " FAIL boxAssign error: "
417  << "global test, nparts found " << nparts
418  << " != num global parts " << nBoxes
419  << std::endl;
420  ierr++;
421  }
422  print_boxAssign_result<Adapter>("globalbox", coordDim,
423  lower, upper, nparts, parts);
424  delete [] parts;
425  }
426 
427  // test a box that is bigger than the entire domain
428  // Assuming lower and upper are still set to the global box boundary
429  // from the previous test
430  {
431  size_t nparts;
432  typename Adapter::part_t *parts;
433  for (int i = 0; i < coordDim; i++) {
434  lower[i] -= 2.;
435  upper[i] += 2.;
436  }
437 
438  try {
439  problem->getSolution().boxAssign(coordDim, lower, upper,
440  nparts, &parts);
441  }
442  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " boxAssign -- bigdomain");
443 
444  // bigdomain box should have all parts
445  if (nparts != nBoxes) {
446  std::cout << me << " FAIL boxAssign error: "
447  << "bigdomain test, nparts found " << nparts
448  << " != num global parts " << nBoxes
449  << std::endl;
450  ierr++;
451  }
452  print_boxAssign_result<Adapter>("bigdomainbox", coordDim,
453  lower, upper, nparts, parts);
454  delete [] parts;
455  }
456 
457  // test a box that is way out there
458  // Assuming lower and upper are still set to at least the global box
459  // boundary from the previous test
460  {
461  size_t nparts;
462  typename Adapter::part_t *parts;
463  for (int i = 0; i < coordDim; i++) {
464  lower[i] = upper[i] + 10;
465  upper[i] += 20;
466  }
467 
468  try {
469  problem->getSolution().boxAssign(coordDim, lower, upper,
470  nparts, &parts);
471  }
472  CATCH_EXCEPTIONS_WITH_COUNT(ierr, me + " boxAssign -- out there");
473 
474  // For now, boxAssign returns zero if there is no box overlap.
475  // TODO: this result should be changed in boxAssign definition
476  if (nparts != 0) {
477  std::cout << me << " FAIL boxAssign error: "
478  << "outthere test, nparts found " << nparts
479  << " != zero"
480  << std::endl;
481  ierr++;
482  }
483  print_boxAssign_result<Adapter>("outthere box", coordDim,
484  lower, upper, nparts, parts);
485  delete [] parts;
486  }
487 
488  delete [] lower;
489  delete [] upper;
490  return ierr;
491 }
492 
493 void readGeoGenParams(string paramFileName, Teuchos::ParameterList &geoparams, const RCP<const Teuchos::Comm<int> > & comm){
494  std::string input = "";
495  char inp[25000];
496  for(int i = 0; i < 25000; ++i){
497  inp[i] = 0;
498  }
499 
500  bool fail = false;
501  if(comm->getRank() == 0){
502 
503  std::fstream inParam(paramFileName.c_str());
504  if (inParam.fail())
505  {
506  fail = true;
507  }
508  if(!fail)
509  {
510  std::string tmp = "";
511  getline (inParam,tmp);
512  while (!inParam.eof()){
513  if(tmp != ""){
514  tmp = trim_copy(tmp);
515  if(tmp != ""){
516  input += tmp + "\n";
517  }
518  }
519  getline (inParam,tmp);
520  }
521  inParam.close();
522  for (size_t i = 0; i < input.size(); ++i){
523  inp[i] = input[i];
524  }
525  }
526  }
527 
528 
529 
530  int size = input.size();
531  if(fail){
532  size = -1;
533  }
534  comm->broadcast(0, sizeof(int), (char*) &size);
535  if(size == -1){
536  throw "File " + paramFileName + " cannot be opened.";
537  }
538  comm->broadcast(0, size, inp);
539  std::istringstream inParam(inp);
540  string str;
541  getline (inParam,str);
542  while (!inParam.eof()){
543  if(str[0] != param_comment){
544  size_t pos = str.find('=');
545  if(pos == string::npos){
546  throw "Invalid Line:" + str + " in parameter file";
547  }
548  string paramname = trim_copy(str.substr(0,pos));
549  string paramvalue = trim_copy(str.substr(pos + 1));
550  geoparams.set(paramname, paramvalue);
551  }
552  getline (inParam,str);
553  }
554 }
555 
556 int GeometricGenInterface(RCP<const Teuchos::Comm<int> > &comm,
557  int numParts, float imbalance,
558  std::string paramFile, std::string pqParts,
559  std::string pfname,
560  int k,
561  int migration_check_option,
562  int migration_all_to_all_type,
563  zscalar_t migration_imbalance_cut_off,
564  int migration_processor_assignment_type,
565  int migration_doMigration_type,
566  bool test_boxes,
567  bool rectilinear,
568  int mj_premigration_option
569 )
570 {
571  int ierr = 0;
572  Teuchos::ParameterList geoparams("geo params");
573  readGeoGenParams(paramFile, geoparams, comm);
576  comm);
577 
578  int coord_dim = gg->getCoordinateDimension();
579  int numWeightsPerCoord = gg->getNumWeights();
580  zlno_t numLocalPoints = gg->getNumLocalCoords();
581  zgno_t numGlobalPoints = gg->getNumGlobalCoords();
582  zscalar_t **coords = new zscalar_t * [coord_dim];
583  for(int i = 0; i < coord_dim; ++i){
584  coords[i] = new zscalar_t[numLocalPoints];
585  }
586  gg->getLocalCoordinatesCopy(coords);
587  zscalar_t **weight = NULL;
588  if (numWeightsPerCoord) {
589  weight= new zscalar_t * [numWeightsPerCoord];
590  for(int i = 0; i < numWeightsPerCoord; ++i){
591  weight[i] = new zscalar_t[numLocalPoints];
592  }
593  gg->getLocalWeightsCopy(weight);
594  }
595 
596  delete gg;
597 
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));
601 
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);
606  coordView[i] = a;
607  }
608  else {
609  Teuchos::ArrayView<const zscalar_t> a;
610  coordView[i] = a;
611  }
612  }
613 
614  RCP<tMVector_t> tmVector = RCP<tMVector_t>(new
615  tMVector_t(mp, coordView.view(0, coord_dim),
616  coord_dim));
617 
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){
623  weights.push_back(weight[i]);
624  }
625  }
626  std::vector<int> stride;
627 
628  typedef Zoltan2::XpetraMultiVectorAdapter<tMVector_t> inputAdapter_t;
630  //inputAdapter_t ia(coordsConst);
631  inputAdapter_t *ia = new inputAdapter_t(coordsConst,weights, stride);
632 
633  Teuchos::RCP<Teuchos::ParameterList> params ;
634 
635  //Teuchos::ParameterList params("test params");
636  if(pfname != ""){
637  params = Teuchos::getParametersFromXmlFile(pfname);
638  }
639  else {
640  params =RCP<Teuchos::ParameterList>(new Teuchos::ParameterList, true);
641  }
642 /*
643  params->set("memory_output_stream" , "std::cout");
644  params->set("memory_procs" , 0);
645  */
646  params->set("timer_output_stream" , "std::cout");
647 
648  params->set("algorithm", "multijagged");
649  if (test_boxes)
650  params->set("mj_keep_part_boxes", true); // bool parameter
651  if (rectilinear)
652  params->set("rectilinear", true ); // bool parameter
653 
654  if(imbalance > 1)
655  params->set("imbalance_tolerance", double(imbalance));
656  params->set("mj_premigration_option", mj_premigration_option);
657 
658  if(pqParts != "")
659  params->set("mj_parts", pqParts);
660  if(numParts > 0)
661  params->set("num_global_parts", numParts);
662  if (k > 0)
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));
669 
671  try {
673  params.getRawPtr(),
674  comm);
675  }
676  CATCH_EXCEPTIONS_AND_RETURN("PartitioningProblem()")
677 
678  try {
679  problem->solve();
680  }
681  CATCH_EXCEPTIONS_AND_RETURN("solve()")
682 
683  // create metric object
684 
685  RCP<quality_t> metricObject =
686  rcp(new quality_t(ia,params.getRawPtr(),comm,&problem->getSolution()));
687 
688  if (comm->getRank() == 0){
689  metricObject->printMetrics(std::cout);
690  }
691  problem->printTimers();
692 
693  // run pointAssign tests
694  if (test_boxes) {
695  ierr = run_pointAssign_tests<inputAdapter_t>(problem, tmVector);
696  ierr += run_boxAssign_tests<inputAdapter_t>(problem, tmVector);
697  }
698 
699  if(numWeightsPerCoord){
700  for(int i = 0; i < numWeightsPerCoord; ++i)
701  delete [] weight[i];
702  delete [] weight;
703  }
704  if(coord_dim){
705  for(int i = 0; i < coord_dim; ++i)
706  delete [] coords[i];
707  delete [] coords;
708  }
709  delete problem;
710  delete ia;
711  return ierr;
712 }
713 
715  RCP<const Teuchos::Comm<int> > &comm,
716  int numParts,
717  float imbalance,
718  std::string fname,
719  std::string pqParts,
720  std::string pfname,
721  int k,
722  int migration_check_option,
723  int migration_all_to_all_type,
724  zscalar_t migration_imbalance_cut_off,
725  int migration_processor_assignment_type,
726  int migration_doMigration_type,
727  bool test_boxes,
728  bool rectilinear,
729  int mj_premigration_option,
730  int mj_premigration_coordinate_cutoff
731 
732 )
733 {
734  int ierr = 0;
735  //std::string fname("simple");
736  //std::cout << "running " << fname << std::endl;
737 
738  UserInputForTests uinput(testDataFilePath, fname, comm, true);
739 
740  RCP<tMVector_t> coords = uinput.getUICoordinates();
741 
742  RCP<const tMVector_t> coordsConst = rcp_const_cast<const tMVector_t>(coords);
743  typedef Zoltan2::XpetraMultiVectorAdapter<tMVector_t> inputAdapter_t;
745  inputAdapter_t *ia = new inputAdapter_t(coordsConst);
746 
747  Teuchos::RCP <Teuchos::ParameterList> params ;
748 
749  //Teuchos::ParameterList params("test params");
750  if(pfname != ""){
751  params = Teuchos::getParametersFromXmlFile(pfname);
752  }
753  else {
754  params =RCP <Teuchos::ParameterList> (new Teuchos::ParameterList, true);
755  }
756 
757  //params->set("timer_output_stream" , "std::cout");
758  if (test_boxes)
759  params->set("mj_keep_part_boxes", true); // bool parameter
760  if (rectilinear)
761  params->set("rectilinear", true); // bool parameter
762  params->set("algorithm", "multijagged");
763  if(imbalance > 1){
764  params->set("imbalance_tolerance", double(imbalance));
765  }
766 
767  if(pqParts != ""){
768  params->set("mj_parts", pqParts);
769  }
770  params->set("mj_premigration_option", mj_premigration_option);
771 
772  if(numParts > 0){
773  params->set("num_global_parts", numParts);
774  }
775  if (k > 0){
776  params->set("mj_concurrent_part_count", k);
777  }
778  if(migration_check_option >= 0){
779  params->set("mj_migration_option", migration_check_option);
780  }
781  if(migration_imbalance_cut_off >= 0){
782  params->set("mj_minimum_migration_imbalance",
783  double (migration_imbalance_cut_off));
784  }
785  if (mj_premigration_coordinate_cutoff > 0){
786  params->set("mj_premigration_coordinate_count", mj_premigration_coordinate_cutoff);
787  }
788 
790  try {
792  params.getRawPtr(),
793  comm);
794  }
795  CATCH_EXCEPTIONS_AND_RETURN("PartitioningProblem()")
796 
797  try {
798  problem->solve();
799  }
800  CATCH_EXCEPTIONS_AND_RETURN("solve()")
801 
802  {
803  // Run a test with BasicVectorAdapter and xyzxyz format coordinates
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();
809 
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);
814 
815  int idx = 0;
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];
823  }
824  }
825 
826  typedef Zoltan2::BasicUserTypes<inputAdapter_t::scalar_t,
827  inputAdapter_t::lno_t,
828  inputAdapter_t::gno_t> bvtypes_t;
829  typedef Zoltan2::BasicVectorAdapter<bvtypes_t> bvadapter_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;
835  }
836  std::vector<const inputAdapter_t::scalar_t *> bvwgts;
837  std::vector<int> bvwgtstrides;
838 
839  bvadapter_t bvia(bvlen, bvgids, bvcoords, bvstrides,
840  bvwgts, bvwgtstrides);
841 
843  try {
844  bvproblem = new Zoltan2::PartitioningProblem<bvadapter_t>(&bvia,
845  params.getRawPtr(),
846  comm);
847  }
848  CATCH_EXCEPTIONS_AND_RETURN("PartitioningProblem()")
849 
850  try {
851  bvproblem->solve();
852  }
853  CATCH_EXCEPTIONS_AND_RETURN("solve()")
854 
855  // Compare with MultiVectorAdapter result
856  for (inputAdapter_t::lno_t i = 0; i < bvlen; i++) {
857  if (problem->getSolution().getPartListView()[i] !=
858  bvproblem->getSolution().getPartListView()[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;
864  }
865 
866  delete [] bvgids;
867  delete [] bvcoordarr;
868  delete [] bvtpetravectors;
869  delete bvproblem;
870  }
871 
872  if (coordsConst->getGlobalLength() < 40) {
873  int len = coordsConst->getLocalLength();
874  const inputAdapter_t::part_t *zparts =
875  problem->getSolution().getPartListView();
876  for (int i = 0; i < len; i++)
877  std::cout << comm->getRank()
878  << " lid " << i
879  << " gid " << coords->getMap()->getGlobalElement(i)
880  << " part " << zparts[i] << std::endl;
881  }
882 
883  // create metric object
884 
885  RCP<quality_t> metricObject =
886  rcp(new quality_t(ia,params.getRawPtr(),comm,&problem->getSolution()));
887 
888  if (comm->getRank() == 0){
889  metricObject->printMetrics(std::cout);
890  std::cout << "testFromDataFile is done " << std::endl;
891  }
892 
893  problem->printTimers();
894 
895  // run pointAssign tests
896  if (test_boxes) {
897  ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
898  ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
899  }
900 
901  delete problem;
902  delete ia;
903  return ierr;
904 }
905 
906 #ifdef hopper_separate_test
907 
908 template <typename zscalar_t, typename zlno_t>
909 void getCoords(zscalar_t **&coords, zlno_t &numLocal, int &dim, string fileName){
910  FILE *f = fopen(fileName.c_str(), "r");
911  if (f == NULL){
912  std::cout << fileName << " cannot be opened" << std::endl;
913  exit(1);
914  }
915  fscanf(f, "%d", &numLocal);
916  fscanf(f, "%d", &dim);
917  coords = new zscalar_t *[ dim];
918  for (int i = 0; i < dim; ++i){
919  coords[i] = new zscalar_t[numLocal];
920  }
921  for (int i = 0; i < dim; ++i){
922  for (zlno_t j = 0; j < numLocal; ++j){
923  fscanf(f, "%lf", &(coords[i][j]));
924  }
925  }
926  fclose(f);
927  std::cout << "done reading:" << fileName << std::endl;
928 }
929 
930 int testFromSeparateDataFiles(
931  RCP<const Teuchos::Comm<int> > &comm,
932  int numParts,
933  float imbalance,
934  std::string fname,
935  std::string pqParts,
936  std::string pfname,
937  int k,
938  int migration_check_option,
939  int migration_all_to_all_type,
940  zscalar_t migration_imbalance_cut_off,
941  int migration_processor_assignment_type,
942  int migration_doMigration_type,
943  int test_boxes,
944  bool rectilinear,
945  int mj_premigration_option
946 )
947 {
948  //std::string fname("simple");
949  //std::cout << "running " << fname << std::endl;
950 
951  int ierr = 0;
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";
955  zscalar_t **double_coords;
956  zlno_t numLocal = 0;
957  int dim = 0;
958  getCoords<zscalar_t, zlno_t>(double_coords, numLocal, dim, tFile);
959  //UserInputForTests uinput(testDataFilePath, fname, comm, true);
960  Teuchos::Array<Teuchos::ArrayView<const zscalar_t> > coordView(dim);
961  for (int i=0; i < dim; i++){
962  if(numLocal > 0){
963  Teuchos::ArrayView<const zscalar_t> a(double_coords[i], numLocal);
964  coordView[i] = a;
965  } else{
966  Teuchos::ArrayView<const zscalar_t> a;
967  coordView[i] = a;
968  }
969  }
970 
971  zgno_t numGlobal;
972  zgno_t nL = numLocal;
973  Teuchos::Comm<int> *tcomm = (Teuchos::Comm<int> *)comm.getRawPtr();
974 
975  reduceAll<int, zgno_t>(
976  *tcomm,
977  Teuchos::REDUCE_SUM,
978  1,
979  &nL,
980  &numGlobal
981  );
982 
983 
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));
988 
989 
990  RCP<const tMVector_t> coordsConst = rcp_const_cast<const tMVector_t>(coords);
991 
992  typedef Zoltan2::XpetraMultiVectorAdapter<tMVector_t> inputAdapter_t;
994 
995  inputAdapter_t *ia = new inputAdapter_t(coordsConst);
996 
997 
998 
999  Teuchos::RCP <Teuchos::ParameterList> params ;
1000 
1001  //Teuchos::ParameterList params("test params");
1002  if(pfname != ""){
1003  params = Teuchos::getParametersFromXmlFile(pfname);
1004  }
1005  else {
1006  params =RCP <Teuchos::ParameterList> (new Teuchos::ParameterList, true);
1007  }
1008 
1009  //params->set("timer_output_stream" , "std::cout");
1010  params->set("algorithm", "multijagged");
1011  if(imbalance > 1){
1012  params->set("imbalance_tolerance", double(imbalance));
1013  }
1014 
1015  params->set("mj_premigration_option", mj_premigration_option);
1016  if(pqParts != ""){
1017  params->set("mj_parts", pqParts);
1018  }
1019  if(numParts > 0){
1020  params->set("num_global_parts", numParts);
1021  }
1022  if (k > 0){
1023  params->set("parallel_part_calculation_count", k);
1024  }
1025  if(migration_processor_assignment_type >= 0){
1026  params->set("migration_processor_assignment_type", migration_processor_assignment_type);
1027  }
1028  if(migration_check_option >= 0){
1029  params->set("migration_check_option", migration_check_option);
1030  }
1031  if(migration_all_to_all_type >= 0){
1032  params->set("migration_all_to_all_type", migration_all_to_all_type);
1033  }
1034  if(migration_imbalance_cut_off >= 0){
1035  params->set("migration_imbalance_cut_off",
1036  double (migration_imbalance_cut_off));
1037  }
1038  if (migration_doMigration_type >= 0){
1039  params->set("migration_doMigration_type", int (migration_doMigration_type));
1040  }
1041  if (test_boxes)
1042  params->set("mj_keep_part_boxes", true); // bool parameter
1043  if (rectilinear)
1044  params->set("rectilinear", true); // bool parameter
1045 
1047  try {
1048  problem =
1050  params.getRawPtr(),
1051  comm);
1052  }
1053  CATCH_EXCEPTIONS_AND_RETURN("PartitioningProblem()")
1054 
1055  try {
1056  problem->solve();
1057  }
1058  CATCH_EXCEPTIONS_AND_RETURN("solve()")
1059 
1060  if (coordsConst->getGlobalLength() < 40) {
1061  int len = coordsConst->getLocalLength();
1062  const inputAdapter_t::part_t *zparts =
1063  problem->getSolution().getPartListView();
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;
1068  }
1069 
1070  //create metric object
1071 
1072  RCP<quality_t> metricObject =
1073  rcp(new quality_t(ia,params.getRawPtr(),comm,&problem->getSolution()));
1074 
1075  if (comm->getRank() == 0){
1076  metricObject->printMetrics(std::cout);
1077  std::cout << "testFromDataFile is done " << std::endl;
1078  }
1079 
1080  problem->printTimers();
1081 
1082  // run pointAssign tests
1083  if (test_boxes) {
1084  ierr = run_pointAssign_tests<inputAdapter_t>(problem, coords);
1085  ierr += run_boxAssign_tests<inputAdapter_t>(problem, coords);
1086  }
1087 
1088  delete problem;
1089  delete ia;
1090  return ierr;
1091 }
1092 #endif
1093 
1094 
1095 
1096 string convert_to_string(char *args){
1097  string tmp = "";
1098  for(int i = 0; args[i] != 0; i++)
1099  tmp += args[i];
1100  return tmp;
1101 }
1102 bool getArgumentValue(string &argumentid, double &argumentValue, string argumentline){
1103  std::stringstream stream(std::stringstream::in | std::stringstream::out);
1104  stream << argumentline;
1105  getline(stream, argumentid, '=');
1106  if (stream.eof()){
1107  return false;
1108  }
1109  stream >> argumentValue;
1110  return true;
1111 }
1112 
1114  int narg,
1115  char **arg,
1116  int &numParts,
1117  float &imbalance ,
1118  string &pqParts,
1119  int &opt,
1120  std::string &fname,
1121  std::string &pfname,
1122  int &k,
1123  int &migration_check_option,
1124  int &migration_all_to_all_type,
1125  zscalar_t &migration_imbalance_cut_off,
1126  int &migration_processor_assignment_type,
1127  int &migration_doMigration_type,
1128  bool &test_boxes,
1129  bool &rectilinear,
1130  int &mj_premigration_option,
1131  int &mj_coordinate_cutoff
1132 )
1133 {
1134  bool isCset = false;
1135  bool isPset = false;
1136  bool isFset = false;
1137  bool isPFset = false;
1138 
1139  for(int i = 0; i < narg; ++i){
1140  string tmp = convert_to_string(arg[i]);
1141  string identifier = "";
1142  long long int value = -1; double fval = -1;
1143  if(!getArgumentValue(identifier, fval, tmp)) continue;
1144  value = (long long int) (fval);
1145 
1146  if(identifier == "C"){
1147  if(value > 0){
1148  numParts=value;
1149  isCset = true;
1150  } else {
1151  throw "Invalid argument at " + tmp;
1152  }
1153  } else if(identifier == "P"){
1154  std::stringstream stream(std::stringstream::in | std::stringstream::out);
1155  stream << tmp;
1156  string ttmp;
1157  getline(stream, ttmp, '=');
1158  stream >> pqParts;
1159  isPset = true;
1160  }else if(identifier == "I"){
1161  if(fval > 0){
1162  imbalance=fval;
1163  } else {
1164  throw "Invalid argument at " + tmp;
1165  }
1166  } else if(identifier == "MI"){
1167  if(fval > 0){
1168  migration_imbalance_cut_off=fval;
1169  } else {
1170  throw "Invalid argument at " + tmp;
1171  }
1172  } else if(identifier == "MO"){
1173  if(value >=0 ){
1174  migration_check_option = value;
1175  } else {
1176  throw "Invalid argument at " + tmp;
1177  }
1178  } else if(identifier == "AT"){
1179  if(value >=0 ){
1180  migration_processor_assignment_type = value;
1181  } else {
1182  throw "Invalid argument at " + tmp;
1183  }
1184  }
1185 
1186  else if(identifier == "MT"){
1187  if(value >=0 ){
1188  migration_all_to_all_type = value;
1189  } else {
1190  throw "Invalid argument at " + tmp;
1191  }
1192  }
1193  else if(identifier == "PCC"){
1194  if(value >=0 ){
1195  mj_coordinate_cutoff = value;
1196  } else {
1197  throw "Invalid argument at " + tmp;
1198  }
1199  }
1200 
1201  else if(identifier == "PM"){
1202  if(value >=0 ){
1203  mj_premigration_option = value;
1204  } else {
1205  throw "Invalid argument at " + tmp;
1206  }
1207  }
1208 
1209  else if(identifier == "DM"){
1210  if(value >=0 ){
1211  migration_doMigration_type = value;
1212  } else {
1213  throw "Invalid argument at " + tmp;
1214  }
1215  }
1216  else if(identifier == "F"){
1217  std::stringstream stream(std::stringstream::in | std::stringstream::out);
1218  stream << tmp;
1219  getline(stream, fname, '=');
1220 
1221  stream >> fname;
1222  isFset = true;
1223  }
1224  else if(identifier == "PF"){
1225  std::stringstream stream(std::stringstream::in | std::stringstream::out);
1226  stream << tmp;
1227  getline(stream, pfname, '=');
1228 
1229  stream >> pfname;
1230  isPFset = true;
1231  }
1232 
1233  else if(identifier == "O"){
1234  if(value >= 0 && value <= 3){
1235  opt = value;
1236  } else {
1237  throw "Invalid argument at " + tmp;
1238  }
1239  }
1240  else if(identifier == "K"){
1241  if(value >=0 ){
1242  k = value;
1243  } else {
1244  throw "Invalid argument at " + tmp;
1245  }
1246  }
1247  else if(identifier == "TB"){
1248  if(value >=0 ){
1249  test_boxes = (value == 0 ? false : true);
1250  } else {
1251  throw "Invalid argument at " + tmp;
1252  }
1253  }
1254  else if(identifier == "R"){
1255  if(value >=0 ){
1256  rectilinear = (value == 0 ? false : true);
1257  } else {
1258  throw "Invalid argument at " + tmp;
1259  }
1260  }
1261  else {
1262  throw "Invalid argument at " + tmp;
1263  }
1264 
1265  }
1266  if(!( (isCset || isPset || isPFset) && isFset)){
1267  throw "(C || P || PF) && F are mandatory arguments.";
1268  }
1269 
1270 }
1271 
1272 void print_usage(char *executable){
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;
1287 }
1288 
1289 int main(int narg, char *arg[])
1290 {
1291  Tpetra::ScopeGuard tscope(&narg, &arg);
1292  Teuchos::RCP<const Teuchos::Comm<int> > tcomm = Tpetra::getDefaultComm();
1293 
1294  int rank = tcomm->getRank();
1295 
1296 
1297  int numParts = -10;
1298  float imbalance = -1.03;
1299  int k = -1;
1300 
1301  string pqParts = "";
1302  int opt = 1;
1303  std::string fname = "";
1304  std::string paramFile = "";
1305 
1306 
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;
1314 
1315  bool test_boxes = false;
1316  bool rectilinear = false;
1317 
1318  try{
1319  try {
1320  getArgVals(
1321  narg,
1322  arg,
1323  numParts,
1324  imbalance ,
1325  pqParts,
1326  opt,
1327  fname,
1328  paramFile,
1329  k,
1330  migration_check_option,
1331  migration_all_to_all_type,
1332  migration_imbalance_cut_off,
1333  migration_processor_assignment_type,
1334  migration_doMigration_type,
1335  test_boxes,
1336  rectilinear, mj_premigration_option, mj_premigration_coordinate_cutoff);
1337  }
1338  catch(std::string s){
1339  if(tcomm->getRank() == 0){
1340  print_usage(arg[0]);
1341  }
1342  throw s;
1343  }
1344 
1345  catch(char * s){
1346  if(tcomm->getRank() == 0){
1347  print_usage(arg[0]);
1348  }
1349  throw s;
1350  }
1351 
1352  int ierr = 0;
1353 
1354  switch (opt){
1355 
1356  case 0:
1357  ierr = testFromDataFile(tcomm,numParts, imbalance,fname,
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);
1364  break;
1365 #ifdef hopper_separate_test
1366  case 1:
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);
1374  break;
1375 #endif
1376  default:
1377  ierr = GeometricGenInterface(tcomm, numParts, imbalance, fname,
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);
1384  break;
1385  }
1386 
1387  if (rank == 0) {
1388  if (ierr == 0) std::cout << "PASS" << std::endl;
1389  else std::cout << "FAIL" << std::endl;
1390  }
1391  }
1392 
1393 
1394  catch(std::string &s){
1395  if (rank == 0)
1396  std::cerr << s << std::endl;
1397  }
1398 
1399  catch(char * s){
1400  if (rank == 0)
1401  std::cerr << s << std::endl;
1402  }
1403 
1404  return 0;
1405 }
run_boxAssign_tests
int run_boxAssign_tests(Zoltan2::PartitioningProblem< Adapter > *problem, RCP< tMVector_t > &coords)
Definition: MultiJaggedTest.cpp:302
GeometricGen::GeometricGenerator::getNumLocalCoords
lno_t getNumLocalCoords()
Definition: GeometricGenerator.hpp:2680
Zoltan2_BasicVectorAdapter.hpp
Defines the BasicVectorAdapter class.
readGeoGenParams
void readGeoGenParams(string paramFileName, Teuchos::ParameterList &geoparams, const RCP< const Teuchos::Comm< int > > &comm)
Definition: MultiJaggedTest.cpp:493
param_comment
const char param_comment
Definition: MultiJaggedTest.cpp:126
GeometricGen::GeometricGenerator::getNumWeights
int getNumWeights()
Definition: GeometricGenerator.hpp:2674
Zoltan2::coordinateModelPartBox
coordinateModelPartBox Class, represents the boundaries of the box which is a result of a geometric p...
Definition: Zoltan2_CoordinatePartitioningGraph.hpp:70
GeometricGen::GeometricGenerator::getNumGlobalCoords
gno_t getNumGlobalCoords()
Definition: GeometricGenerator.hpp:2683
zscalar_t
double zscalar_t
Definition: Zoltan2_TestHelpers.hpp:141
GeometricGen::GeometricGenerator::getLocalWeightsCopy
void getLocalWeightsCopy(scalar_t **w)
Definition: GeometricGenerator.hpp:2706
testDataFilePath
std::string testDataFilePath(".")
Zoltan2::Problem::printTimers
void printTimers() const
Return the communicator passed to the problem.
Definition: Zoltan2_Problem.hpp:141
getArgumentValue
bool getArgumentValue(string &argumentid, double &argumentValue, string argumentline)
Definition: MultiJaggedTest.cpp:1102
convert_to_string
string convert_to_string(char *args)
Definition: MultiJaggedTest.cpp:1096
UserInputForTests
Definition: UserInputForTests.hpp:126
run_pointAssign_tests
int run_pointAssign_tests(Zoltan2::PartitioningProblem< Adapter > *problem, RCP< tMVector_t > &coords)
Definition: MultiJaggedTest.cpp:174
Zoltan2::XpetraMultiVectorAdapter
An adapter for Xpetra::MultiVector.
Definition: Zoltan2_XpetraMultiVectorAdapter.hpp:83
part_t
SparseMatrixAdapter_t::part_t part_t
Definition: partitioningTree.cpp:74
zgno_t
int zgno_t
Definition: Zoltan2_TestHelpers.hpp:143
print_boxAssign_result
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)
Definition: MultiJaggedTest.cpp:150
GeometricGen::GeometricGenerator::getCoordinateDimension
int getCoordinateDimension()
Definition: GeometricGenerator.hpp:2677
Zoltan2_PartitioningSolution.hpp
Defines the PartitioningSolution class.
main
int main(int narg, char *arg[])
Definition: MultiJaggedTest.cpp:1289
Zoltan2::PartitioningProblem
PartitioningProblem sets up partitioning problems for the user.
Definition: Zoltan2_PartitioningProblem.hpp:104
Zoltan2::BasicUserTypes
A simple class that can be the User template argument for an InputAdapter.
Definition: Zoltan2_InputTraits.hpp:139
zlno_t
int zlno_t
Definition: Zoltan2_TestHelpers.hpp:142
UserInputForTests::getUICoordinates
RCP< tMVector_t > getUICoordinates()
Definition: UserInputForTests.hpp:544
tMVector_t
Tpetra::MultiVector< zscalar_t, zlno_t, zgno_t, znode_t > tMVector_t
Definition: MultiJaggedTest.cpp:119
Zoltan2::PartitioningProblem::solve
void solve(bool updateInputData=true)
Direct the problem to create a solution.
Definition: Zoltan2_PartitioningProblem.hpp:526
GeometricGen::GeometricGenerator::getLocalCoordinatesCopy
void getLocalCoordinatesCopy(scalar_t **c)
Definition: GeometricGenerator.hpp:2695
GeometricGenerator.hpp
testFromDataFile
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)
Definition: MultiJaggedTest.cpp:714
trim_left_copy
string trim_left_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
Definition: MultiJaggedTest.cpp:135
getArgVals
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)
Definition: MultiJaggedTest.cpp:1113
CATCH_EXCEPTIONS_WITH_COUNT
#define CATCH_EXCEPTIONS_WITH_COUNT(ierr, pp)
Definition: MultiJaggedTest.cpp:96
fail
static const std::string fail
Definition: findUniqueGids.cpp:80
weights
static ArrayRCP< ArrayRCP< zscalar_t > > weights
Definition: rcbPerformanceZ1.cpp:82
Zoltan2::PartitioningProblem::getSolution
const PartitioningSolution< Adapter > & getSolution()
Get the solution to the problem.
Definition: Zoltan2_PartitioningProblem.hpp:171
trim_right_copy
string trim_right_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
Definition: MultiJaggedTest.cpp:128
Zoltan2_TestHelpers.hpp
common code used by tests
Zoltan2_EvaluatePartition.hpp
Defines the EvaluatePartition class.
GeometricGen::GeometricGenerator
Definition: GeometricGenerator.hpp:902
print_usage
void print_usage(char *executable)
Definition: MultiJaggedTest.cpp:1272
trim_copy
string trim_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
Definition: MultiJaggedTest.cpp:142
Zoltan2::EvaluatePartition
A class that computes and returns quality metrics.
Definition: Zoltan2_EvaluatePartition.hpp:114
CATCH_EXCEPTIONS_AND_RETURN
#define CATCH_EXCEPTIONS_AND_RETURN(pp)
Definition: MultiJaggedTest.cpp:74
Zoltan2::Problem::getComm
RCP< const Comm< int > > getComm()
Return the communicator used by the problem.
Definition: Zoltan2_Problem.hpp:116
Zoltan2_XpetraMultiVectorAdapter.hpp
Defines the XpetraMultiVectorAdapter.
GeometricGenInterface
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)
Definition: MultiJaggedTest.cpp:556
Zoltan2::BasicVectorAdapter
BasicVectorAdapter represents a vector (plus optional weights) supplied by the user as pointers to st...
Definition: Zoltan2_BasicVectorAdapter.hpp:81
Zoltan2_PartitioningProblem.hpp
Defines the PartitioningProblem class.
getCoords
void getCoords(void *data, int numGid, int numLid, int numObj, zgno_t *gids, zgno_t *lids, int dim, double *coords, int *ierr)
Definition: rcbPerformanceZ1.cpp:165