51 #include <Teuchos_ParameterList.hpp>
52 #include <Teuchos_XMLObject.hpp>
53 #include <Teuchos_XMLParameterListWriter.hpp>
54 #include <Teuchos_ParameterXMLFileReader.hpp>
55 #include <Teuchos_ValidatorXMLConverterDB.hpp>
57 #include <Teuchos_StandardParameterEntryValidators.hpp>
68 using std::ostringstream;
80 int main(
int argc,
char *argv[])
82 string xmlFile(
"initParams.xml");
83 Teuchos::XMLParameterListWriter plw;
89 RCP<irlConverter_t > converter = rcp(
new irlConverter_t);
91 RCP<const irl_t> intRangeValidatorP = rcp(
new irl_t);
93 Teuchos::ValidatorXMLConverterDB::addConverter(
97 Teuchos::ParameterList pl(
"zoltan2ValidatingParameters");
101 Teuchos::XMLObject obj = plw.toXML(pl);
103 cout <<
"Parameter list: " << endl;
107 of.open(xmlFile.c_str());
114 using Teuchos::tuple;
117 using Teuchos::AnyNumberParameterEntryValidator;
118 RCP<const AnyNumberParameterEntryValidator> anyNumValidatorP;
120 using Teuchos::EnhancedNumberValidator;
121 RCP<const EnhancedNumberValidator<int> > intValidatorP;
123 using Teuchos::StringValidator;
124 RCP<const StringValidator> strValidatorP;
126 using Teuchos::FileNameValidator;
127 RCP<const FileNameValidator > fnameValidatorP;
129 using Teuchos::StringToIntegralParameterEntryValidator;
130 typedef StringToIntegralParameterEntryValidator<int> str2intValidator;
131 RCP<const str2intValidator> str2intValidatorP;
133 Tuple<string,8> yesNoStrings =
134 tuple<string>(
"true",
"yes",
"1",
"on",
"false",
"no",
"0",
"off");
136 Tuple<int,8> yesNoIntegrals =
137 tuple<int>( 1, 1, 1, 1, 0, 0, 0, 0);
141 Tuple<string,8> ostreamStrings =
142 tuple<string>(
"std::cout",
"cout",
"stdout",
143 "std::cerr",
"cerr",
"stderr",
144 "/dev/null",
"null");
146 Tuple<int,8> ostreamIntegrals =
147 tuple<int>( 0, 0, 0, 1, 1, 1, 2, 2);
149 RCP<const Zoltan2::IntegerRangeListValidator<int> > intRangeValidatorP;
151 string parameterName;
152 std::ostringstream docString;
154 parameterName = string(
"error_check_level");
156 str2intValidatorP = rcp(
new str2intValidator(
158 tuple<string>(
"no_assertions",
160 "complex_assertions",
161 "debug_mode_assertions"),
164 "no assertions will be performed",
165 "typical checks of argument validity (fast, default)",
166 "additional checks, i.e. is input graph a valid graph)",
167 "check for everything including logic errors (slowest)"),
176 string omitInfo(
"the amount of error checking performed\n");
177 omitInfo.append(
"(If the compile flag Z2_OMIT_ALL_ERROR_CHECKING was set,\n");
178 omitInfo.append(
"then error checking code is not executed at runtime.)\n");
180 str2intValidatorP->printDoc(omitInfo, docString);
182 pList.set<
string>(parameterName,
"basic_assertions", docString.str(),
186 parameterName = string(
"debug_level");
188 str2intValidatorP = rcp(
new str2intValidator(
189 tuple<string>(
"no_status",
192 "verbose_detailed_status"),
195 "library outputs no status information",
196 "library outputs basic status information (default)",
197 "library outputs detailed information",
198 "library outputs very detailed information"),
208 omitInfo = string(
"the amount of status/warning/debugging info printed\n");
209 omitInfo.append(
"(If the compile flag Z2_OMIT_ALL_STATUS_MESSAGES was set,\n");
210 omitInfo.append(
"then message output code is not executed at runtime.)\n");
212 str2intValidatorP->printDoc(
213 "the amount of status/debugging/warning information to print\n", docString);
215 pList.set<
string>(parameterName,
"basic_status", docString.str(),
220 parameterName = string(
"timer_type");
222 str2intValidatorP = rcp(
new str2intValidator(
224 "no_timers",
"macro_timers",
"micro_timers",
"both_timers",
"test_timers"),
227 "No timing data will be collected (the default).",
228 "Time an algorithm (or other entity) as a whole.",
229 "Time the substeps of an entity.",
230 "Run both MACRO and MICRO timers.",
231 "Run timers added to code for testing, removed later"),
237 omitInfo = string(
"the type of timing information to collect\n");
238 omitInfo.append(
"(If the compile flag Z2_OMIT_ALL_PROFILING was set,\n");
239 omitInfo.append(
"then the timing code is not executed at runtime.)\n");
241 str2intValidatorP->printDoc(omitInfo, docString);
243 pList.set<
string>(parameterName,
"no_timers", docString.str(),
247 parameterName = string(
"debug_output_stream");
250 rcp(
new str2intValidator(ostreamStrings, ostreamIntegrals, parameterName));
253 str2intValidatorP->printDoc(
254 "output stream for debug/status/warning messages (default cout)\n",
257 pList.set<
string>(parameterName,
"cout", docString.str(),
261 parameterName = string(
"timer_output_stream");
264 rcp(
new str2intValidator(ostreamStrings, ostreamIntegrals, parameterName));
267 str2intValidatorP->printDoc(
268 "output stream for timing report (default cout)\n",
271 pList.set<
string>(parameterName,
"cout", docString.str(),
275 parameterName = string(
"memory_output_stream");
278 rcp(
new str2intValidator(ostreamStrings, ostreamIntegrals, parameterName));
281 str2intValidatorP->printDoc(
282 "output stream for memory usage messages (default cout)\n",
285 pList.set<
string>(parameterName,
"cout", docString.str(),
290 parameterName = string(
"debug_output_file");
292 fnameValidatorP = rcp(
new FileNameValidator(
false));
294 fnameValidatorP->printDoc(
295 "name of file to which debug/status messages should be written\n"
296 "(process rank will be included in file name)\n",
299 pList.set<
string>(parameterName,
"/dev/null", docString.str(), fnameValidatorP);
302 parameterName = string(
"timer_output_file");
305 fnameValidatorP->printDoc(
306 "name of file to which timing information should be written\n"
307 "(process rank will be included in file name)\n",
310 pList.set<
string>(parameterName,
"/dev/null", docString.str(), fnameValidatorP);
313 parameterName = string(
"memory_output_file");
316 fnameValidatorP->printDoc(
317 "name of file to which memory profiling information should be written\n"
318 "(process rank will be included in file name)\n",
321 pList.set<
string>(parameterName,
"/dev/null", docString.str(), fnameValidatorP);
324 parameterName = string(
"debug_procs");
329 intRangeValidatorUnsertedP->printDoc(
330 "list of ranks that output debugging/status messages (default \"0\")\n",
333 pList.set<
string>(parameterName,
"0", docString.str(), intRangeValidatorUnsertedP);
336 parameterName = string(
"pqParts");
341 pqRangeRangeValidatorP->printDoc(
342 "list of parts for pqJagged partitioning algorithm. As many as the dimension count.\n",
345 pList.set<
string>(parameterName,
"0", docString.str(), pqRangeRangeValidatorP);
349 parameterName = string(
"memory_procs");
352 intRangeValidatorP->printDoc(
353 "list of ranks that memory profiling information (default \"0\")\n",
356 pList.set<
string>(parameterName,
"0", docString.str(), intRangeValidatorP);
359 parameterName = string(
"speed_versus_quality");
361 strValidatorP = rcp(
new StringValidator(
362 tuple<string>(
"speed",
"balance",
"quality")));
365 strValidatorP->printDoc(
366 "When algorithm choices exist, opt for speed or solution quality?\n"
367 "(Default is a balance of speed and quality)\n",
370 pList.set<
string>(parameterName,
"balance", docString.str(), strValidatorP);
373 parameterName = string(
"memory_versus_speed");
375 strValidatorP = rcp(
new StringValidator(
376 tuple<string>(
"memory",
"balance",
"speed")));
379 strValidatorP->printDoc(
380 "When algorithm choices exist, opt for the use of less memory\n"
381 "at the expense of runtime\n"
382 "(Default is a balance of memory conservation and speed)\n",
385 pList.set<
string>(parameterName,
"balance", docString.str(), strValidatorP);
388 parameterName = string(
"random_seed");
390 anyNumValidatorP = rcp(
new AnyNumberParameterEntryValidator);
393 anyNumValidatorP->printDoc(
"random seed\n", docString);
395 pList.set<
string>(parameterName,
"0.5", docString.str(), anyNumValidatorP);
398 parameterName = string(
"order_method");
399 strValidatorP = rcp(
new StringValidator(
400 tuple<string>(
"rcm",
"minimum_degree",
"method3")));
403 strValidatorP->printDoc(
404 "Document the order_method parameter here\n"
408 pList.set<
string>(parameterName,
"rcm", docString.str(), strValidatorP);
411 parameterName = string(
"order_package");
412 strValidatorP = rcp(
new StringValidator(
413 tuple<string>(
"amd",
"package2",
"package3")));
416 strValidatorP->printDoc(
417 "Document the order_package parameter here\n"
421 pList.set<
string>(parameterName,
"amd", docString.str(), strValidatorP);
424 parameterName = string(
"compute_metrics");
427 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
430 str2intValidatorP->printDoc(
"Compute metrics after computing solution\n",
433 pList.set<
string>(parameterName,
"no", docString.str(),
437 parameterName = string(
"topology");
439 strValidatorP = rcp(
new StringValidator);
442 docString <<
"Topology of node to be used in hierarchical partitioning\n";
443 docString <<
" \"2,4\" for dual-socket quad-core\n";
444 docString <<
" \"2,2,6\" for dual-socket, dual-die, six-core\n";
445 docString <<
" \"2,2,3\" for dual-socket, dual-die, six-core but\n";
446 docString <<
" with only three partitions per die\n";
448 pList.set<
string>(parameterName,
"", docString.str(), strValidatorP);
451 parameterName = string(
"randomize_input");
454 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
457 str2intValidatorP->printDoc(
"randomize input prior to partitioning\n",
460 pList.set<
string>(parameterName,
"no", docString.str(),
464 parameterName = string(
"partitioning_objective");
466 strValidatorP = rcp(
new StringValidator(
468 "balance_object_count",
469 "balance_object_weight",
470 "multicriteria_minimize_total_weight",
471 "multicriteria_minimize_maximum_weight",
472 "multicriteria_balance_total_maximum",
473 "minimize_cut_edge_count",
474 "minimize_cut_edge_weight",
475 "minimize_neighboring_parts",
476 "minimize_boundary_vertices")));
479 strValidatorP->printDoc(
480 "objective of partitioning (default depends on algorithm)\n",
483 pList.set<
string>(parameterName,
"balance_object_weight",
484 docString.str(), strValidatorP);
487 parameterName = string(
"imbalance_tolerance");
489 anyNumValidatorP = rcp(
new AnyNumberParameterEntryValidator);
492 anyNumValidatorP->printDoc(
493 "imbalance tolerance, ratio of maximum load over average load"
497 pList.set<
string>(parameterName,
"1.1", docString.str(),
501 parameterName = string(
"num_global_parts");
503 anyNumValidatorP = rcp(
new AnyNumberParameterEntryValidator);
506 anyNumValidatorP->printDoc(
507 "global number of parts to compute (default is number of processes)\n",
510 pList.set<
string>(parameterName,
"0", docString.str(),
514 parameterName = string(
"num_local_parts");
516 anyNumValidatorP = rcp(
new AnyNumberParameterEntryValidator);
519 anyNumValidatorP->printDoc(
520 "number of parts to compute for this process(default is one)\n",
523 pList.set<
string>(parameterName,
"0", docString.str(),
527 parameterName = string(
"partitioning_approach");
529 strValidatorP = rcp(
new StringValidator(
530 tuple<string>(
"partition",
"repartition",
"maximize_overlap")));
533 strValidatorP->printDoc(
534 "Partition from scratch, partition incrementally from current\n"
535 "partition, of partition from scratch but maximize overlap\n"
536 "with the current partition (default is \"partition\" from scratch)\n",
539 pList.set<
string>(parameterName,
"partition", docString.str(),
543 parameterName = string(
"objects_to_partition");
545 strValidatorP = rcp(
new StringValidator(
558 strValidatorP->printDoc(
559 "Objects to be partitioned (defaults are \"matrix_rows\" for\n"
560 "matrix input, \"mesh_nodes\" for mesh input, and \"graph_vertices\"\n"
561 "for graph input)\n",
564 pList.set<
string>(parameterName,
"graph_vertices", docString.str(),
568 parameterName = string(
"model");
570 strValidatorP = rcp(
new StringValidator(
571 tuple<string>(
"hypergraph",
"graph",
"geometry",
"ids")));
574 strValidatorP->printDoc(
575 "This is a low level parameter. Normally the library will choose\n"
576 "a computational model based on the algorithm or objective specified\n"
580 pList.set<
string>(parameterName,
"graph", docString.str(),
584 parameterName = string(
"algorithm");
586 strValidatorP = rcp(
new StringValidator(
603 strValidatorP->printDoc(
"partitioning algorithm\n", docString);
605 pList.set<
string>(parameterName,
"random", docString.str(),
609 parameterName = string(
"rectilinear");
612 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
615 str2intValidatorP->printDoc(
616 "If true, then when a cut is made, all of the dots located on the cut\n"
617 "are moved to the same side of the cut. The resulting regions are then\n"
618 "rectilinear. The resulting load balance may not be as good as when\n"
619 "the group of dots is split by the cut. Default is false.\n",
622 pList.set<
string>(parameterName,
"no", docString.str(),
626 parameterName = string(
"average_cuts");
629 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
632 str2intValidatorP->printDoc(
633 "When true, coordinates of RCB cutting planes are computed to be \n"
634 "the average of the coordinates of the closest object on each side \n"
635 "of the cut. Otherwise, coordinates of cutting planes may equal \n"
636 "those of one of the closest objects. Default is false.\n",
639 pList.set<
string>(parameterName,
"no", docString.str(),
643 parameterName = string(
"symmetrize_input");
645 strValidatorP = rcp(
new StringValidator(
646 tuple<string>(
"no",
"transpose",
"bipartite")));
649 strValidatorP->printDoc(
650 "Symmetrize input prior to pList. If \"transpose\",\n"
651 "symmetrize A by computing A plus ATranspose. If \"bipartite\",\n"
652 "A becomes [[0 A][ATranspose 0]]. \n",
655 pList.set<
string>(parameterName,
"no", docString.str(),
659 parameterName = string(
"subset_graph");
662 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
665 str2intValidatorP->printDoc(
666 "If \"yes\", the graph input is to be subsetted. If a vertex neighbor\n"
667 "is not a valid vertex, it will be omitted from the pList. Otherwise,\n"
668 "an invalid neighbor identifier is considered an error.\n",
671 pList.set<
string>(parameterName,
"no", docString.str(),
Time an algorithm (or other entity) as a whole.
fast typical checks for valid arguments
Defines Parameter related enumerators, declares functions.
XML conversion code for IntegerRangeListValidator.
more involved, like validate a graph
int main(int narg, char **arg)
Time the substeps of an entity.
sub-steps, each method's entry and exit
Run both MACRO and MICRO timers.
A ParameterList validator for integer range lists.
no assertion checks will be done
Timers added while testing, removed later.
don't display status/debug messages
the status at each high level step
Define IntegerRangeList validator.
void createAllParameters(Teuchos::ParameterList &pList)
Gathering definitions used in software development.
include more detail about sub-steps
No timing data will be collected (the default).