Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
partition/rcbPerformanceZ1.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Zoltan2: A package of combinatorial algorithms for scientific computing
4 //
5 // Copyright 2012 NTESS and the Zoltan2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
17 #include <Zoltan2_TestHelpers.hpp>
18 
19 #include <zoltan.h>
20 #include <Teuchos_CommandLineProcessor.hpp>
21 
22 #include <vector>
23 #include <ostream>
24 #include <sstream>
25 #include <string>
26 
27 #include <Zoltan2_TestHelpers.hpp>
31 #include <GeometricGenerator.hpp>
33 
34 using std::vector;
35 using std::bad_alloc;
36 using Teuchos::RCP;
37 using Teuchos::rcp;
38 using Teuchos::Comm;
39 using Teuchos::ArrayView;
40 using Teuchos::ArrayRCP;
41 using Teuchos::CommandLineProcessor;
42 
43 typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> tMVector_t;
44 typedef Tpetra::Map<zlno_t, zgno_t, znode_t> tMap_t;
45 
46 static ArrayRCP<ArrayRCP<zscalar_t> > weights;
47 static RCP<tMVector_t> coordinates;
48 
49 
50 const char param_comment = '#';
51 
52 std::string trim_right_copy(
53  const std::string& s,
54  const std::string& delimiters = " \f\n\r\t\v" )
55 {
56  return s.substr( 0, s.find_last_not_of( delimiters ) + 1 );
57 }
58 
59 std::string trim_left_copy(
60  const std::string& s,
61  const std::string& delimiters = " \f\n\r\t\v" )
62 {
63  return s.substr( s.find_first_not_of( delimiters ) );
64 }
65 
66 std::string trim_copy(
67  const std::string& s,
68  const std::string& delimiters = " \f\n\r\t\v" )
69 {
70  return trim_left_copy( trim_right_copy( s, delimiters ), delimiters );
71 }
72 
73 // Zoltan1 query functions
74 bool getArgumentValue(std::string &argumentid, double &argumentValue, std::string argumentline){
75  std::stringstream stream(std::stringstream::in | std::stringstream::out);
76  stream << argumentline;
77  getline(stream, argumentid, '=');
78  if (stream.eof()){
79  return false;
80  }
81  stream >> argumentValue;
82  return true;
83 }
84 
85 std::string convert_to_string(char *args){
86  std::string tmp = "";
87  for(int i = 0; args[i] != 0; i++)
88  tmp += args[i];
89  return tmp;
90 }
91 int getNumObj(void *data, int *ierr)
92 {
93  *ierr = 0;
94 
95  return coordinates->getLocalLength();
96 }
97 
98 int getDim(void *data, int *ierr)
99 {
100  *ierr = 0;
101  return 3;
102 }
103 
104 void getObjList(void *data, int numGid, int numLid,
105  zgno_t * gids, zgno_t * lids,
106  int num_wgts, float *obj_wgts, int *ierr)
107 {
108  *ierr = 0;
109  size_t localLen = coordinates->getLocalLength();
110  const zgno_t *ids = coordinates->getMap()->getLocalElementList().getRawPtr();
111  zgno_t *idsNonConst = const_cast<zgno_t *>(ids);
112 
113  if (sizeof(zgno_t) == sizeof(zgno_t)){
114  memcpy(gids, idsNonConst, sizeof(zgno_t) * localLen);
115  }
116  else{
117  for (size_t i=0; i < localLen; i++)
118  gids[i] = static_cast<zgno_t>(idsNonConst[i]);
119  }
120 
121  if (num_wgts > 0){
122  float *wgts = obj_wgts;
123  for (size_t i=0; i < localLen; i++)
124  for (int w=0; w < num_wgts; w++)
125  *wgts++ = static_cast<float>(weights[w][i]);
126  }
127 }
128 
129 void getCoords(void *data, int numGid, int numLid,
130  int numObj, zgno_t * gids, zgno_t * lids,
131  int dim, double *coords, int *ierr)
132 {
133  // I know that Zoltan asks for coordinates in gid order.
134  *ierr = 0;
135  double *val = coords;
136  const zscalar_t *x = coordinates->getData(0).getRawPtr();
137  const zscalar_t *y = coordinates->getData(1).getRawPtr();
138  const zscalar_t *z = coordinates->getData(2).getRawPtr();
139  for (zlno_t i=0; i < numObj; i++){
140  *val++ = static_cast<double>(x[i]);
141  *val++ = static_cast<double>(y[i]);
142  *val++ = static_cast<double>(z[i]);
143  }
144 }
145 
146 
147 
153 };
154 
155 ArrayRCP<zscalar_t> makeWeights(
156  const RCP<const Teuchos::Comm<int> > & comm,
157  zlno_t len, weightTypes how, zscalar_t scale, int rank)
158 {
159  zscalar_t *wgts = new zscalar_t [len];
160  if (!wgts)
161  throw bad_alloc();
162 
163  ArrayRCP<zscalar_t> wgtArray(wgts, 0, len, true);
164 
165  if (how == upDown){
166  zscalar_t val = scale + rank%2;
167  for (zlno_t i=0; i < len; i++)
168  wgts[i] = val;
169  }
170  else if (how == roundRobin){
171  for (int i=0; i < 10; i++){
172  zscalar_t val = (i + 10)*scale;
173  for (int j=i; j < len; j += 10)
174  wgts[j] = val;
175  }
176  }
177  else if (how == increasing){
178  zscalar_t val = scale + rank;
179  for (zlno_t i=0; i < len; i++)
180  wgts[i] = val;
181  }
182 
183  return wgtArray;
184 }
185 
190 const RCP<tMVector_t> getMeshCoordinates(
191  const RCP<const Teuchos::Comm<int> > & comm,
192  zgno_t numGlobalCoords)
193 {
194  int rank = comm->getRank();
195  int nprocs = comm->getSize();
196 
197  double k = log(numGlobalCoords) / 3;
198  double xdimf = exp(k) + 0.5;
199  zgno_t xdim = static_cast<int>(floor(xdimf));
200  zgno_t ydim = xdim;
201  zgno_t zdim = numGlobalCoords / (xdim*ydim);
202  zgno_t num=xdim*ydim*zdim;
203  zgno_t diff = numGlobalCoords - num;
204  zgno_t newdiff = 0;
205 
206  while (diff > 0){
207  if (zdim > xdim && zdim > ydim){
208  zdim++;
209  newdiff = diff - (xdim*ydim);
210  if (newdiff < 0)
211  if (diff < -newdiff)
212  zdim--;
213  }
214  else if (ydim > xdim && ydim > zdim){
215  ydim++;
216  newdiff = diff - (xdim*zdim);
217  if (newdiff < 0)
218  if (diff < -newdiff)
219  ydim--;
220  }
221  else{
222  xdim++;
223  newdiff = diff - (ydim*zdim);
224  if (newdiff < 0)
225  if (diff < -newdiff)
226  xdim--;
227  }
228 
229  diff = newdiff;
230  }
231 
232  num=xdim*ydim*zdim;
233  diff = numGlobalCoords - num;
234  if (diff < 0)
235  diff /= -numGlobalCoords;
236  else
237  diff /= numGlobalCoords;
238 
239  if (rank == 0){
240  if (diff > .01)
241  std::cout << "Warning: Difference " << diff*100 << " percent" << std::endl;
242  std::cout << "Mesh size: " << xdim << "x" << ydim << "x" <<
243  zdim << ", " << num << " vertices." << std::endl;
244  }
245 
246  // Divide coordinates.
247 
248  zgno_t numLocalCoords = num / nprocs;
249  zgno_t leftOver = num % nprocs;
250  zgno_t gid0 = 0;
251 
252  if (rank <= leftOver)
253  gid0 = zgno_t(rank) * (numLocalCoords+1);
254  else
255  gid0 = (leftOver * (numLocalCoords+1)) +
256  ((zgno_t(rank) - leftOver) * numLocalCoords);
257 
258  if (rank < leftOver)
259  numLocalCoords++;
260 
261  zgno_t gid1 = gid0 + numLocalCoords;
262 
263  zgno_t *ids = new zgno_t [numLocalCoords];
264  if (!ids)
265  throw bad_alloc();
266  ArrayRCP<zgno_t> idArray(ids, 0, numLocalCoords, true);
267 
268  for (zgno_t i=gid0; i < gid1; i++)
269  *ids++ = i;
270 
271  RCP<const tMap_t> idMap = rcp(
272  new tMap_t(num, idArray.view(0, numLocalCoords), 0, comm));
273 
274  // Create a Tpetra::MultiVector of coordinates.
275 
276  zscalar_t *x = new zscalar_t [numLocalCoords*3];
277  if (!x)
278  throw bad_alloc();
279  ArrayRCP<zscalar_t> coordArray(x, 0, numLocalCoords*3, true);
280 
281  zscalar_t *y = x + numLocalCoords;
282  zscalar_t *z = y + numLocalCoords;
283 
284  zgno_t xStart = 0;
285  zgno_t yStart = 0;
286  zgno_t xyPlane = xdim*ydim;
287  zgno_t zStart = gid0 / xyPlane;
288  zgno_t rem = gid0 % xyPlane;
289  if (rem > 0){
290  yStart = rem / xdim;
291  xStart = rem % xdim;
292  }
293 
294  zlno_t next = 0;
295  for (zscalar_t zval=zStart; next < numLocalCoords && zval < zdim; zval++){
296  for (zscalar_t yval=yStart; next < numLocalCoords && yval < ydim; yval++){
297  for (zscalar_t xval=xStart; next < numLocalCoords && xval < xdim; xval++){
298  x[next] = xval;
299  y[next] = yval;
300  z[next] = zval;
301  next++;
302  }
303  xStart = 0;
304  }
305  yStart = 0;
306  }
307 
308  ArrayView<const zscalar_t> xArray(x, numLocalCoords);
309  ArrayView<const zscalar_t> yArray(y, numLocalCoords);
310  ArrayView<const zscalar_t> zArray(z, numLocalCoords);
311  ArrayRCP<ArrayView<const zscalar_t> > coordinates =
312  arcp(new ArrayView<const zscalar_t> [3], 0, 3);
313  coordinates[0] = xArray;
314  coordinates[1] = yArray;
315  coordinates[2] = zArray;
316 
317  ArrayRCP<const ArrayView<const zscalar_t> > constCoords =
318  coordinates.getConst();
319 
320  RCP<tMVector_t> meshCoords = rcp(new tMVector_t(
321  idMap, constCoords.view(0,3), 3));
322 
323  return meshCoords;
324 }
325 
326 
327 void getArgVals(int narg, char **arg, int &numParts,
328  std::string &paramFile){
329 
330  for(int i = 0; i < narg; ++i){
331  std::string tmp = convert_to_string(arg[i]);
332  std::string identifier = "";
333  long long int value = -1; double fval = -1;
334  if(!getArgumentValue(identifier, fval, tmp)) continue;
335  value = (long long int) (fval);
336  if(identifier == "C"){
337  if(value > 0){
338  numParts=value;
339  } else {
340  throw "Invalid argument at " + tmp;
341  }
342  }
343  else if(identifier == "PF"){
344  std::stringstream stream(std::stringstream::in | std::stringstream::out);
345  stream << tmp;
346  getline(stream, paramFile, '=');
347  stream >> paramFile;
348  }
349  else {
350  throw "Invalid argument at " + tmp;
351  }
352 
353  }
354 
355 }
356 
357 void readGeoGenParams(std::string paramFileName, Teuchos::ParameterList &geoparams, const RCP<const Teuchos::Comm<int> > & comm){
358  std::string input = "";
359  char inp[25000];
360  for(int i = 0; i < 25000; ++i){
361  inp[i] = 0;
362  }
363  if(comm->getRank() == 0){
364  std::fstream inParam(paramFileName.c_str());
365 
366  std::string tmp = "";
367  getline (inParam,tmp);
368  while (!inParam.eof()){
369  if(tmp != ""){
370  tmp = trim_copy(tmp);
371  if(tmp != ""){
372  input += tmp + "\n";
373  }
374  }
375  getline (inParam,tmp);
376  }
377  inParam.close();
378  for (size_t i = 0; i < input.size(); ++i){
379  inp[i] = input[i];
380  }
381  }
382 
383 
384  int size = input.size();
385 
386  //MPI_Bcast(&size,1,MPI_INT, 0, MPI_COMM_WORLD);
387  //MPI_Bcast(inp,size,MPI_CHAR, 0, MPI_COMM_WORLD);
388  //Teuchos::broadcast<int, char>(comm, 0,inp);
389 
390  comm->broadcast(0, sizeof(int), (char*) &size);
391  comm->broadcast(0, size, inp);
392  //Teuchos::broadcast<int,std::string>(comm,0, &input);
393  std::istringstream inParam(inp);
394  std::string str;
395  getline (inParam,str);
396  while (!inParam.eof()){
397  if(str[0] != param_comment){
398  size_t pos = str.find('=');
399  if(pos == std::string::npos){
400  throw "Invalid Line:" + str + " in parameter file";
401  }
402  std::string paramname = trim_copy(str.substr(0,pos));
403  std::string paramvalue = trim_copy(str.substr(pos + 1));
404  geoparams.set(paramname, paramvalue);
405  }
406  getline (inParam,str);
407  }
408 }
409 
410 int main(int narg, char *arg[])
411 {
412  // MEMORY_CHECK(true, "Before initializing MPI");
413  Tpetra::ScopeGuard tscope(&narg, &arg);
414  Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
415 
416  int rank = comm->getRank();
417  int nprocs = comm->getSize();
418 
419  MEMORY_CHECK(rank==0 || rank==nprocs-1, "After initializing MPI");
420 
421  if (rank==0)
422  std::cout << "Number of processes: " << nprocs << std::endl;
423 
424  // Default values
425  //double numGlobalCoords = 1000;
426  //int nWeights = 0;
427  int debugLevel=2; // for timing
428  std::string memoryOn("memoryOn");
429  std::string memoryOff("memoryOff");
430  bool doMemory=false;
431 
432  int numGlobalParts = 512 * 512;
433  std::string paramFile = "p2.txt";
434  //getArgVals(narg, arg, numGlobalParts, paramFile);
435 
436  int dummyTimer=0;
437 
438 
439 
440  Teuchos::ParameterList geoparams("geo params");
441 
442  readGeoGenParams(paramFile, geoparams, comm);
443 #ifdef HAVE_ZOLTAN2_OMP
444  double begin = omp_get_wtime();
445 #endif
446  GeometricGenerator<zscalar_t, zlno_t, zgno_t, znode_t> *gg = new GeometricGenerator<zscalar_t, zlno_t, zgno_t, znode_t>(geoparams,comm);
447 #ifdef HAVE_ZOLTAN2_OMP
448  double end = omp_get_wtime();
449  std::cout << "GeometricGen Time:" << end - begin << std::endl;
450 #endif
451  int coord_dim = gg->getCoordinateDimension();
452  int nWeights = gg->getNumWeights();
453  zlno_t numLocalPoints = gg->getNumLocalCoords();
454  zgno_t numGlobalPoints = gg->getNumGlobalCoords();
455  zscalar_t **coords = new zscalar_t * [coord_dim];
456  for(int i = 0; i < coord_dim; ++i){
457  coords[i] = new zscalar_t[numLocalPoints];
458  }
459  gg->getLocalCoordinatesCopy(coords);
460  zscalar_t **weight = NULL;
461  if(nWeights){
462  weight= new zscalar_t * [nWeights];
463  for(int i = 0; i < nWeights; ++i){
464  weight[i] = new zscalar_t[numLocalPoints];
465  }
466  gg->getLocalWeightsCopy(weight);
467  }
468 
469  zgno_t globalSize = static_cast<zgno_t>(numGlobalPoints);
470  delete gg;
471 
472  std::cout << "coord_dim:" << coord_dim << " nWeights:" << nWeights << " numLocalPoints:" << numLocalPoints << " numGlobalPoints:" << numGlobalPoints << std::endl;
473 
474  CommandLineProcessor commandLine(false, true);
475  commandLine.setOption("size", &numGlobalPoints,
476  "Approximate number of global coordinates.");
477  commandLine.setOption("numParts", &numGlobalParts,
478  "Number of parts (default is one per proc).");
479  commandLine.setOption("numWeights", &nWeights,
480  "Number of weights per coordinate, zero implies uniform weights.");
481  commandLine.setOption("debug", &debugLevel, "Zoltan1 debug level");
482  commandLine.setOption("timers", &dummyTimer, "ignored");
483  commandLine.setOption(memoryOn.c_str(), memoryOff.c_str(), &doMemory,
484  "do memory profiling");
485 
486  std::string balanceCount("balance_object_count");
487  std::string balanceWeight("balance_object_weight");
488  std::string mcnorm1("multicriteria_minimize_total_weight");
489  std::string mcnorm2("multicriteria_balance_total_maximum");
490  std::string mcnorm3("multicriteria_minimize_maximum_weight");
491 
492  std::string objective(balanceWeight); // default
493 
494  std::string doc(balanceCount);
495  doc.append(": ignore weights\n");
496 
497  doc.append(balanceWeight);
498  doc.append(": balance on first weight\n");
499 
500  doc.append(mcnorm1);
501  doc.append(": given multiple weights, balance their total.\n");
502 
503  doc.append(mcnorm3);
504  doc.append(": given multiple weights, balance the maximum for each coordinate.\n");
505 
506  doc.append(mcnorm2);
507  doc.append(": given multiple weights, balance the L2 norm of the weights.\n");
508 
509  commandLine.setOption("objective", &objective, doc.c_str());
510 
511  CommandLineProcessor::EParseCommandLineReturn rc =
512  commandLine.parse(narg, arg);
513 
514  if (rc != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL){
515  if (rc == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED){
516  if (rank==0)
517  std::cout << "PASS" << std::endl;
518  return 1;
519  }
520  else{
521  if (rank==0)
522  std::cout << "FAIL" << std::endl;
523  return 0;
524  }
525  }
526 
527  //MEMORY_CHECK(doMemory && rank==0, "After processing parameters");
528 
529 
530 
531 
532  RCP<Tpetra::Map<zlno_t, zgno_t, znode_t> > mp = rcp(
533  new Tpetra::Map<zlno_t, zgno_t, znode_t> (numGlobalPoints, numLocalPoints, 0, comm));
534 
535  Teuchos::Array<Teuchos::ArrayView<const zscalar_t> > coordView(coord_dim);
536  for (int i=0; i < coord_dim; i++){
537  if(numLocalPoints > 0){
538  Teuchos::ArrayView<const zscalar_t> a(coords[i], numLocalPoints);
539  coordView[i] = a;
540  } else{
541  Teuchos::ArrayView<const zscalar_t> a;
542  coordView[i] = a;
543  }
544  }
545 
546  coordinates = RCP< Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> >(
547  new Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t>( mp, coordView.view(0, coord_dim), coord_dim));
548 
549  //typedef Tpetra::MultiVector<zscalar_t, zlno_t, zgno_t, znode_t> tMVector_t;
550 
551  RCP<const tMVector_t> coordsConst = Teuchos::rcp_const_cast<const tMVector_t>(coordinates);
552 
553 
554 
555  //coordinates = getMeshCoordinates(comm, globalSize);
556  size_t numLocalCoords = coordinates->getLocalLength();
557 
558 #if 0
559  comm->barrier();
560  for (int p=0; p < nprocs; p++){
561  if (p==rank){
562  std::cout << "Rank " << rank << ", " << numLocalCoords << "coords" << std::endl;
563  const zscalar_t *x = coordinates->getData(0).getRawPtr();
564  const zscalar_t *y = coordinates->getData(1).getRawPtr();
565  const zscalar_t *z = coordinates->getData(2).getRawPtr();
566  for (zlno_t i=0; i < numLocalCoords; i++)
567  std::cout << " " << x[i] << " " << y[i] << " " << z[i] << std::endl;
568  }
569  std::cout.flush();
570  comm->barrier();
571  }
572 #endif
573 
574  if (nWeights > 0){
575 
576  weights = arcp(new ArrayRCP<zscalar_t> [nWeights],
577  0, nWeights, true);
578  for(int i = 0; i < nWeights; ++i){
579  //weights[i] = ArrayRCP<zscalar_t>(weight[i]);
580  }
581  }
582 
583  MEMORY_CHECK(doMemory && rank==0, "After creating input");
584 
585  // Now call Zoltan to partition the problem.
586 
587  float ver;
588  int aok = Zoltan_Initialize(narg, arg, &ver);
589 
590  if (aok != 0){
591  printf("sorry...\n");
592  exit(0);
593  }
594 
595  struct Zoltan_Struct *zz;
596  zz = Zoltan_Create(MPI_COMM_WORLD);
597 
598  Zoltan_Set_Param(zz, "LB_METHOD", "RCB");
599  Zoltan_Set_Param(zz, "LB_APPROACH", "PARTITION");
600  Zoltan_Set_Param(zz, "CHECK_GEOM", "0");
601  Zoltan_Set_Param(zz, "NUM_GID_ENTRIES", "1"); // compiled with ULONG option
602  Zoltan_Set_Param(zz, "NUM_LID_ENTRIES", "0");
603  Zoltan_Set_Param(zz, "RETURN_LISTS", "ALL");
604 
605  //Zoltan_Set_Param(zz, "FINAL_OUTPUT", "1");
606  Zoltan_Set_Param(zz, "IMBALANCE_TOL", "1.0");
607  std::ostringstream oss;
608  oss << numGlobalParts;
609  Zoltan_Set_Param(zz, "NUM_GLOBAL_PARTS", oss.str().c_str());
610  oss.str("");
611  oss << debugLevel;
612  Zoltan_Set_Param(zz, "DEBUG_LEVEL", oss.str().c_str());
613 
614  if (objective != balanceCount){
615  oss.str("");
616  oss << nWeights;
617  Zoltan_Set_Param(zz, "OBJ_WEIGHT_DIM", oss.str().c_str());
618 
619  if (objective == mcnorm1)
620  Zoltan_Set_Param(zz, "RCB_MULTICRITERIA_NORM", "1");
621  else if (objective == mcnorm2)
622  Zoltan_Set_Param(zz, "RCB_MULTICRITERIA_NORM", "2");
623  else if (objective == mcnorm3)
624  Zoltan_Set_Param(zz, "RCB_MULTICRITERIA_NORM", "3");
625  }
626  else{
627  Zoltan_Set_Param(zz, "OBJ_WEIGHT_DIM", "0");
628  }
629 
630  Zoltan_Set_Num_Obj_Fn(zz, getNumObj, NULL);
631  Zoltan_Set_Obj_List_Fn(zz, getObjList,NULL);
632  Zoltan_Set_Num_Geom_Fn(zz, getDim, NULL);
633  Zoltan_Set_Geom_Multi_Fn(zz, getCoords, NULL);
634 
635  int changes, numGidEntries, numLidEntries, numImport, numExport;
636  zgno_t * importGlobalGids, * importLocalGids;
637  zgno_t * exportGlobalGids, * exportLocalGids;
638  int *importProcs, *importToPart, *exportProcs, *exportToPart;
639 
640  MEMORY_CHECK(doMemory && rank==0, "Before Zoltan_LB_Partition");
641 
642 
643  aok = Zoltan_LB_Partition(zz, /* input (all remaining fields are output) */
644  &changes, /* 1 if partitioning was changed, 0 otherwise */
645  &numGidEntries, /* Number of integers used for a global ID */
646  &numLidEntries, /* Number of integers used for a local ID */
647  &numImport, /* Number of vertices to be sent to me */
648  &importGlobalGids, /* Global IDs of vertices to be sent to me */
649  &importLocalGids, /* Local IDs of vertices to be sent to me */
650  &importProcs, /* Process rank for source of each incoming vertex */
651  &importToPart, /* New partition for each incoming vertex */
652  &numExport, /* Number of vertices I must send to other processes*/
653  &exportGlobalGids, /* Global IDs of the vertices I must send */
654  &exportLocalGids, /* Local IDs of the vertices I must send */
655  &exportProcs, /* Process to which I send each of the vertices */
656  &exportToPart); /* Partition to which each vertex will belong */
657 
658  MEMORY_CHECK(doMemory && rank==0, "After Zoltan_LB_Partition");
659  Zoltan_LB_Free_Part(importGlobalGids, importLocalGids, importProcs, importToPart);
660  Zoltan_LB_Free_Part(exportGlobalGids, exportLocalGids, exportProcs, exportToPart);
661  Zoltan_Destroy(&zz);
662  MEMORY_CHECK(doMemory && rank==0, "After Zoltan_Destroy");
663 
664  if (rank==0){
665  if (aok != 0)
666  std::cout << "FAIL" << std::endl;
667  else
668  std::cout << "PASS" << std::endl;
669  }
670 
671  return 0;
672 }
void getCoords(void *data, int numGid, int numLid, int numObj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int dim, double *coords_, int *ierr)
const RCP< tMVector_t > getMeshCoordinates(const RCP< const Teuchos::Comm< int > > &comm, zgno_t numGlobalCoords)
Create a mesh of approximately the desired size.
string trim_right_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
static ArrayRCP< ArrayRCP< zscalar_t > > weights
void readGeoGenParams(string paramFileName, Teuchos::ParameterList &geoparams, const RCP< const Teuchos::Comm< int > > &comm)
int main(int narg, char **arg)
Definition: coloring1.cpp:164
Defines the PartitioningSolution class.
common code used by tests
Defines the XpetraMultiVectorAdapter.
string trim_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
const char param_comment
ArrayRCP< zscalar_t > makeWeights(const RCP< const Teuchos::Comm< int > > &comm, zlno_t len, weightTypes how, zscalar_t scale, int rank)
int getNumObj(void *data, int *ierr)
Defines the EvaluatePartition class.
static RCP< tMVector_t > coordinates
int getDim(void *data, int *ierr)
void getObjList(void *data, int numGid, int numLid, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_wgts, float *obj_wgts, int *ierr)
void getArgVals(int narg, char **arg, int &numTeams, 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 &uvm, bool &print_details, bool &test_boxes, bool &rectilinear, int &mj_premigration_option, int &mj_coordinate_cutoff)
Tpetra::Map::local_ordinal_type zlno_t
Tpetra::Map< zlno_t, zgno_t, znode_t > tMap_t
string convert_to_string(char *args)
string trim_left_copy(const string &s, const string &delimiters=" \f\n\r\t\v")
bool getArgumentValue(string &argumentid, double &argumentValue, string argumentline)
Defines the PartitioningProblem class.
float zscalar_t
Tpetra::MultiVector< zscalar_t, zlno_t, zgno_t, znode_t > tMVector_t
Tpetra::Map::global_ordinal_type zgno_t
#define MEMORY_CHECK(iPrint, msg)