15 #include <Teuchos_ParameterList.hpp>
16 #include <Teuchos_XMLObject.hpp>
17 #include <Teuchos_XMLParameterListWriter.hpp>
18 #include <Teuchos_ParameterXMLFileReader.hpp>
19 #include <Teuchos_ValidatorXMLConverterDB.hpp>
21 #include <Teuchos_StandardParameterEntryValidators.hpp>
32 using std::ostringstream;
44 int main(
int argc,
char *argv[])
46 string xmlFile(
"initParams.xml");
47 Teuchos::XMLParameterListWriter plw;
53 RCP<irlConverter_t > converter = rcp(
new irlConverter_t);
55 RCP<const irl_t> intRangeValidatorP = rcp(
new irl_t);
57 Teuchos::ValidatorXMLConverterDB::addConverter(
61 Teuchos::ParameterList pl(
"zoltan2ValidatingParameters");
65 Teuchos::XMLObject obj = plw.toXML(pl);
67 cout <<
"Parameter list: " << endl;
71 of.open(xmlFile.c_str());
81 using Teuchos::AnyNumberParameterEntryValidator;
82 RCP<const AnyNumberParameterEntryValidator> anyNumValidatorP;
84 using Teuchos::EnhancedNumberValidator;
85 RCP<const EnhancedNumberValidator<int> > intValidatorP;
87 using Teuchos::StringValidator;
88 RCP<const StringValidator> strValidatorP;
90 using Teuchos::FileNameValidator;
91 RCP<const FileNameValidator > fnameValidatorP;
93 using Teuchos::StringToIntegralParameterEntryValidator;
94 typedef StringToIntegralParameterEntryValidator<int> str2intValidator;
95 RCP<const str2intValidator> str2intValidatorP;
97 Tuple<string,8> yesNoStrings =
98 tuple<string>(
"true",
"yes",
"1",
"on",
"false",
"no",
"0",
"off");
100 Tuple<int,8> yesNoIntegrals =
101 tuple<int>( 1, 1, 1, 1, 0, 0, 0, 0);
105 Tuple<string,8> ostreamStrings =
106 tuple<string>(
"std::cout",
"cout",
"stdout",
107 "std::cerr",
"cerr",
"stderr",
108 "/dev/null",
"null");
110 Tuple<int,8> ostreamIntegrals =
111 tuple<int>( 0, 0, 0, 1, 1, 1, 2, 2);
113 RCP<const Zoltan2::IntegerRangeListValidator<int> > intRangeValidatorP;
115 string parameterName;
116 std::ostringstream docString;
118 parameterName = string(
"error_check_level");
120 str2intValidatorP = rcp(
new str2intValidator(
122 tuple<string>(
"no_assertions",
124 "complex_assertions",
125 "debug_mode_assertions"),
128 "no assertions will be performed",
129 "typical checks of argument validity (fast, default)",
130 "additional checks, i.e. is input graph a valid graph)",
131 "check for everything including logic errors (slowest)"),
140 string omitInfo(
"the amount of error checking performed\n");
141 omitInfo.append(
"(If the compile flag Z2_OMIT_ALL_ERROR_CHECKING was set,\n");
142 omitInfo.append(
"then error checking code is not executed at runtime.)\n");
144 str2intValidatorP->printDoc(omitInfo, docString);
146 pList.set<
string>(parameterName,
"basic_assertions", docString.str(),
150 parameterName = string(
"debug_level");
152 str2intValidatorP = rcp(
new str2intValidator(
153 tuple<string>(
"no_status",
156 "verbose_detailed_status"),
159 "library outputs no status information",
160 "library outputs basic status information (default)",
161 "library outputs detailed information",
162 "library outputs very detailed information"),
172 omitInfo = string(
"the amount of status/warning/debugging info printed\n");
173 omitInfo.append(
"(If the compile flag Z2_OMIT_ALL_STATUS_MESSAGES was set,\n");
174 omitInfo.append(
"then message output code is not executed at runtime.)\n");
176 str2intValidatorP->printDoc(
177 "the amount of status/debugging/warning information to print\n", docString);
179 pList.set<
string>(parameterName,
"basic_status", docString.str(),
184 parameterName = string(
"timer_type");
186 str2intValidatorP = rcp(
new str2intValidator(
188 "no_timers",
"macro_timers",
"micro_timers",
"both_timers",
"test_timers"),
191 "No timing data will be collected (the default).",
192 "Time an algorithm (or other entity) as a whole.",
193 "Time the substeps of an entity.",
194 "Run both MACRO and MICRO timers.",
195 "Run timers added to code for testing, removed later"),
201 omitInfo = string(
"the type of timing information to collect\n");
202 omitInfo.append(
"(If the compile flag Z2_OMIT_ALL_PROFILING was set,\n");
203 omitInfo.append(
"then the timing code is not executed at runtime.)\n");
205 str2intValidatorP->printDoc(omitInfo, docString);
207 pList.set<
string>(parameterName,
"no_timers", docString.str(),
211 parameterName = string(
"debug_output_stream");
214 rcp(
new str2intValidator(ostreamStrings, ostreamIntegrals, parameterName));
217 str2intValidatorP->printDoc(
218 "output stream for debug/status/warning messages (default cout)\n",
221 pList.set<
string>(parameterName,
"cout", docString.str(),
225 parameterName = string(
"timer_output_stream");
228 rcp(
new str2intValidator(ostreamStrings, ostreamIntegrals, parameterName));
231 str2intValidatorP->printDoc(
232 "output stream for timing report (default cout)\n",
235 pList.set<
string>(parameterName,
"cout", docString.str(),
239 parameterName = string(
"memory_output_stream");
242 rcp(
new str2intValidator(ostreamStrings, ostreamIntegrals, parameterName));
245 str2intValidatorP->printDoc(
246 "output stream for memory usage messages (default cout)\n",
249 pList.set<
string>(parameterName,
"cout", docString.str(),
254 parameterName = string(
"debug_output_file");
256 fnameValidatorP = rcp(
new FileNameValidator(
false));
258 fnameValidatorP->printDoc(
259 "name of file to which debug/status messages should be written\n"
260 "(process rank will be included in file name)\n",
263 pList.set<
string>(parameterName,
"/dev/null", docString.str(), fnameValidatorP);
266 parameterName = string(
"timer_output_file");
269 fnameValidatorP->printDoc(
270 "name of file to which timing information should be written\n"
271 "(process rank will be included in file name)\n",
274 pList.set<
string>(parameterName,
"/dev/null", docString.str(), fnameValidatorP);
277 parameterName = string(
"memory_output_file");
280 fnameValidatorP->printDoc(
281 "name of file to which memory profiling information should be written\n"
282 "(process rank will be included in file name)\n",
285 pList.set<
string>(parameterName,
"/dev/null", docString.str(), fnameValidatorP);
288 parameterName = string(
"debug_procs");
293 intRangeValidatorUnsertedP->printDoc(
294 "list of ranks that output debugging/status messages (default \"0\")\n",
297 pList.set<
string>(parameterName,
"0", docString.str(), intRangeValidatorUnsertedP);
300 parameterName = string(
"pqParts");
305 pqRangeRangeValidatorP->printDoc(
306 "list of parts for pqJagged partitioning algorithm. As many as the dimension count.\n",
309 pList.set<
string>(parameterName,
"0", docString.str(), pqRangeRangeValidatorP);
313 parameterName = string(
"memory_procs");
316 intRangeValidatorP->printDoc(
317 "list of ranks that memory profiling information (default \"0\")\n",
320 pList.set<
string>(parameterName,
"0", docString.str(), intRangeValidatorP);
323 parameterName = string(
"speed_versus_quality");
325 strValidatorP = rcp(
new StringValidator(
326 tuple<string>(
"speed",
"balance",
"quality")));
329 strValidatorP->printDoc(
330 "When algorithm choices exist, opt for speed or solution quality?\n"
331 "(Default is a balance of speed and quality)\n",
334 pList.set<
string>(parameterName,
"balance", docString.str(), strValidatorP);
337 parameterName = string(
"memory_versus_speed");
339 strValidatorP = rcp(
new StringValidator(
340 tuple<string>(
"memory",
"balance",
"speed")));
343 strValidatorP->printDoc(
344 "When algorithm choices exist, opt for the use of less memory\n"
345 "at the expense of runtime\n"
346 "(Default is a balance of memory conservation and speed)\n",
349 pList.set<
string>(parameterName,
"balance", docString.str(), strValidatorP);
352 parameterName = string(
"random_seed");
354 anyNumValidatorP = rcp(
new AnyNumberParameterEntryValidator);
357 anyNumValidatorP->printDoc(
"random seed\n", docString);
359 pList.set<
string>(parameterName,
"0.5", docString.str(), anyNumValidatorP);
362 parameterName = string(
"order_method");
363 strValidatorP = rcp(
new StringValidator(
364 tuple<string>(
"rcm",
"minimum_degree",
"method3")));
367 strValidatorP->printDoc(
368 "Document the order_method parameter here\n"
372 pList.set<
string>(parameterName,
"rcm", docString.str(), strValidatorP);
375 parameterName = string(
"order_package");
376 strValidatorP = rcp(
new StringValidator(
377 tuple<string>(
"amd",
"package2",
"package3")));
380 strValidatorP->printDoc(
381 "Document the order_package parameter here\n"
385 pList.set<
string>(parameterName,
"amd", docString.str(), strValidatorP);
388 parameterName = string(
"compute_metrics");
391 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
394 str2intValidatorP->printDoc(
"Compute metrics after computing solution\n",
397 pList.set<
string>(parameterName,
"no", docString.str(),
401 parameterName = string(
"topology");
403 strValidatorP = rcp(
new StringValidator);
406 docString <<
"Topology of node to be used in hierarchical partitioning\n";
407 docString <<
" \"2,4\" for dual-socket quad-core\n";
408 docString <<
" \"2,2,6\" for dual-socket, dual-die, six-core\n";
409 docString <<
" \"2,2,3\" for dual-socket, dual-die, six-core but\n";
410 docString <<
" with only three partitions per die\n";
412 pList.set<
string>(parameterName,
"", docString.str(), strValidatorP);
415 parameterName = string(
"randomize_input");
418 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
421 str2intValidatorP->printDoc(
"randomize input prior to partitioning\n",
424 pList.set<
string>(parameterName,
"no", docString.str(),
428 parameterName = string(
"partitioning_objective");
430 strValidatorP = rcp(
new StringValidator(
432 "balance_object_count",
433 "balance_object_weight",
434 "multicriteria_minimize_total_weight",
435 "multicriteria_minimize_maximum_weight",
436 "multicriteria_balance_total_maximum",
437 "minimize_cut_edge_count",
438 "minimize_cut_edge_weight",
439 "minimize_neighboring_parts",
440 "minimize_boundary_vertices")));
443 strValidatorP->printDoc(
444 "objective of partitioning (default depends on algorithm)\n",
447 pList.set<
string>(parameterName,
"balance_object_weight",
448 docString.str(), strValidatorP);
451 parameterName = string(
"imbalance_tolerance");
453 anyNumValidatorP = rcp(
new AnyNumberParameterEntryValidator);
456 anyNumValidatorP->printDoc(
457 "imbalance tolerance, ratio of maximum load over average load"
461 pList.set<
string>(parameterName,
"1.1", docString.str(),
465 parameterName = string(
"num_global_parts");
467 anyNumValidatorP = rcp(
new AnyNumberParameterEntryValidator);
470 anyNumValidatorP->printDoc(
471 "global number of parts to compute (default is number of processes)\n",
474 pList.set<
string>(parameterName,
"0", docString.str(),
478 parameterName = string(
"num_local_parts");
480 anyNumValidatorP = rcp(
new AnyNumberParameterEntryValidator);
483 anyNumValidatorP->printDoc(
484 "number of parts to compute for this process(default is one)\n",
487 pList.set<
string>(parameterName,
"0", docString.str(),
491 parameterName = string(
"partitioning_approach");
493 strValidatorP = rcp(
new StringValidator(
494 tuple<string>(
"partition",
"repartition",
"maximize_overlap")));
497 strValidatorP->printDoc(
498 "Partition from scratch, partition incrementally from current\n"
499 "partition, of partition from scratch but maximize overlap\n"
500 "with the current partition (default is \"partition\" from scratch)\n",
503 pList.set<
string>(parameterName,
"partition", docString.str(),
507 parameterName = string(
"objects_to_partition");
509 strValidatorP = rcp(
new StringValidator(
522 strValidatorP->printDoc(
523 "Objects to be partitioned (defaults are \"matrix_rows\" for\n"
524 "matrix input, \"mesh_nodes\" for mesh input, and \"graph_vertices\"\n"
525 "for graph input)\n",
528 pList.set<
string>(parameterName,
"graph_vertices", docString.str(),
532 parameterName = string(
"model");
534 strValidatorP = rcp(
new StringValidator(
535 tuple<string>(
"hypergraph",
"graph",
"geometry",
"ids")));
538 strValidatorP->printDoc(
539 "This is a low level parameter. Normally the library will choose\n"
540 "a computational model based on the algorithm or objective specified\n"
544 pList.set<
string>(parameterName,
"graph", docString.str(),
548 parameterName = string(
"algorithm");
550 strValidatorP = rcp(
new StringValidator(
567 strValidatorP->printDoc(
"partitioning algorithm\n", docString);
569 pList.set<
string>(parameterName,
"random", docString.str(),
573 parameterName = string(
"rectilinear");
576 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
579 str2intValidatorP->printDoc(
580 "If true, then when a cut is made, all of the dots located on the cut\n"
581 "are moved to the same side of the cut. The resulting regions are then\n"
582 "rectilinear. The resulting load balance may not be as good as when\n"
583 "the group of dots is split by the cut. Default is false.\n",
586 pList.set<
string>(parameterName,
"no", docString.str(),
590 parameterName = string(
"average_cuts");
593 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
596 str2intValidatorP->printDoc(
597 "When true, coordinates of RCB cutting planes are computed to be \n"
598 "the average of the coordinates of the closest object on each side \n"
599 "of the cut. Otherwise, coordinates of cutting planes may equal \n"
600 "those of one of the closest objects. Default is false.\n",
603 pList.set<
string>(parameterName,
"no", docString.str(),
607 parameterName = string(
"symmetrize_input");
609 strValidatorP = rcp(
new StringValidator(
610 tuple<string>(
"no",
"transpose",
"bipartite")));
613 strValidatorP->printDoc(
614 "Symmetrize input prior to pList. If \"transpose\",\n"
615 "symmetrize A by computing A plus ATranspose. If \"bipartite\",\n"
616 "A becomes [[0 A][ATranspose 0]]. \n",
619 pList.set<
string>(parameterName,
"no", docString.str(),
623 parameterName = string(
"subset_graph");
626 rcp(
new str2intValidator(yesNoStrings, yesNoIntegrals, parameterName));
629 str2intValidatorP->printDoc(
630 "If \"yes\", the graph input is to be subsetted. If a vertex neighbor\n"
631 "is not a valid vertex, it will be omitted from the pList. Otherwise,\n"
632 "an invalid neighbor identifier is considered an error.\n",
635 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).