13 #include <Zoltan2_config.h>
15 #include <Teuchos_ParameterList.hpp>
16 #include <Teuchos_DefaultComm.hpp>
29 {
"debug_output_file",
"temp.txt",
"5"},
30 {
"timer_output_file",
"timerInfo.txt",
"10.3"},
31 {
"memory_output_file",
"memory.txt",
"3.33"}
35 #ifdef HAVE_ZOLTAN2_PULP
42 {
"error_check_level",
"basic_assertions",
"invalid_assertion_request"},
43 {
"debug_level",
"basic_status",
"invalid_status"},
44 {
"timer_type",
"no_timers",
"invalid_timers"},
45 {
"debug_output_stream",
"std::cout",
"invalid_stream"},
46 {
"timer_output_stream",
"/dev/null",
"invalid_stream"},
47 {
"memory_output_stream",
"std::cerr",
"invalid_stream"},
48 {
"debug_procs",
"all",
"not_a_valid_list_of_any_type"},
49 {
"mj_parts",
"2,3,4",
"not_a_valid_list_of_any_type"},
50 {
"memory_procs",
"2-10",
"not_a_valid_list_of_any_type"},
51 {
"order_method",
"rcm",
"invalid_method"},
52 {
"order_method_type",
"local",
"invalid_method_type"},
53 {
"order_package",
"amd",
"invalid_package"},
54 {
"partitioning_objective",
"balance_object_weight",
"invalid_objective"},
55 {
"partitioning_approach",
"repartition",
"invalid_approach"},
56 {
"objects_to_partition",
"graph_vertices",
"invalid_objects"},
57 {
"model",
"graph",
"invalid_model"},
58 {
"algorithm",
"rcb",
"invalid_algorithm"},
59 {
"symmetrize_input",
"transpose",
"invalid_option"},
60 {
"symmetrize_input",
"transpose",
"invalid_option"},
61 {
"mj_concurrent_part_count",
"0",
"invalid_value"},
62 {
"mj_recursion_depth",
"0",
"invalid_value"},
63 {
"mapping_type",
"0",
"invalid_value"},
64 {
"imbalance_tolerance",
"1.1",
"invalid_option"},
65 {
"mj_minimum_migration_imbalance",
"1.1",
"invalid_option"},
66 #ifdef HAVE_ZOLTAN2_PULP
67 {
"pulp_vert_imbalance",
"1.1",
"invalid_option"},
68 {
"pulp_edge_imbalance",
"1.1",
"invalid_option"},
69 {
"pulp_imbalance",
"1.1",
"invalid_option"},
70 #endif // HAVE_ZOLTAN2_PULP
71 {
"scotch_imbalance_ratio",
"1.1",
"invalid_option"},
72 {
"compute_metrics",
"false",
"invalid_bool_setting"},
73 {
"rectilinear",
"false",
"invalid_bool_setting"},
74 {
"subset_graph",
"false",
"invalid_bool_setting"},
75 {
"mj_enable_rcb",
"true",
"invalid_bool_setting"},
76 {
"mj_keep_part_boxes",
"true",
"invalid_bool_setting"},
77 {
"num_global_parts",
"1",
"invalid_value"},
78 {
"num_local_parts",
"0",
"invalid_value"},
79 {
"mj_premigration_option",
"1",
"invalid_value"},
80 {
"mj_migration_option",
"2",
"invalid_value"},
81 {
"mj_num_teams",
"60",
"invalid_value"},
86 string paramName, T badValue)
88 Teuchos::ParameterList validParameters;
89 pl.set(paramName, badValue);
90 std::cout << std::endl;
91 std::cout << paramName <<
" = " << badValue << std::endl;
96 pl.validateParametersAndSetDefaults(validParameters);
98 catch(std::exception &e){
99 std::cout <<
"Correctly generated an error:" << std::endl;
100 std::cout << e.what() << std::endl;
105 std::cerr <<
"Bad parameter value was not detected in parameter list." << std::endl;
118 Teuchos::ParameterList valid(
"valid parameter list");
121 typedef Teuchos::AnyNumberParameterEntryValidator validator_t;
122 Teuchos::RCP<const validator_t> anyNumVal = Teuchos::rcp(
new validator_t);
127 std::cout <<
"set good default value" << std::endl;
129 std::string parameterName(
"parameterName");
131 valid.set(parameterName, 5.0,
"parameterDoc", anyNumVal);
133 catch (std::exception &e) {
134 std::cout <<
"FAIL error setting good default value "
135 << e.what() << std::endl;
139 double dd = valid.getEntry(parameterName).getValue<
double>(&dd);
140 std::cout <<
"good default value <double> = " << dd << std::endl;
144 Teuchos::ParameterList user(
"user");
147 std::cout <<
"test good user value" << std::endl;
148 user.set(parameterName,
"0.123");
150 user.validateParametersAndSetDefaults(valid);
152 catch (std::exception &e) {
153 std::cout <<
"FAIL " << e.what() << std::endl;
157 dd = user.getEntry(parameterName).getValue<
double>(&dd);
158 std::cout <<
"good user value <double> = " << dd << std::endl;
161 std::cout <<
"test bogus user value" << std::endl;
167 user.set(parameterName,
"bogus");
169 catch(std::exception &e) {
171 std::cout <<
"Parameter list correctly rejected bogus user value."
177 std::cout <<
"FAIL parameter list accepted a bogus user value"
184 std::cout <<
"set bogus default value" << std::endl;
186 std::string parameterNameToo(
"parameterNameToo");
189 valid.set(parameterNameToo,
"bogus",
"parameterDoc", anyNumVal);
191 catch (std::exception &e) {
193 std::cout <<
"Parameter list correctly rejected bogus default value."
199 std::cout <<
"FAIL parameter list accepted a bogus default value"
204 std::cout <<
"PASS" << std::endl;
210 int main(
int narg,
char *arg[])
212 Tpetra::ScopeGuard tscope(&narg, &arg);
213 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
215 int rank = comm->getRank();
224 if( tempTest != 0 ) {
230 Teuchos::ParameterList validParameters;
231 Teuchos::ParameterList myParams(
"testParameterList");
233 for (
int i=0; i <
NUMSTR; i++){
237 for (
int i=0; i <
NUMFN; i++){
241 Teuchos::ParameterList origParams(myParams);
248 myParams.validateParametersAndSetDefaults(validParameters);
250 catch(std::exception &e){
251 std::cerr <<
"Validate parameters generated an error:" << std::endl;
252 std::cerr << e.what() << std::endl;
253 std::cerr <<
"FAIL" << std::endl;
257 std::cout << std::endl;
258 std::cout <<
"Parameters after validation: " << std::endl;
259 std::cout << myParams << std::endl;
262 for (
int i=0; i <
NUMSTR; i++){
263 Teuchos::ParameterList badParams(origParams);
265 testInvalidValue<string>(badParams,
strParams[i][0], strParams[i][2]);
267 std::cout <<
"FAIL" << std::endl;
272 for (
int i=0; i <
NUMFN; i++){
273 Teuchos::ParameterList badParams(origParams);
274 std::istringstream iss(
fnParams[i][2]);
278 testInvalidValue<double>(badParams,
fnParams[i][0], badVal);
280 std::cout <<
"FAIL" << std::endl;
288 std::cout << std::endl;
289 std::cout <<
"Parameter documentation:" << std::endl;
292 std::cout <<
"PASS" << std::endl;
void createValidatorList(const Teuchos::ParameterList &plIn, Teuchos::ParameterList &plOut)
Create a list by adding validators to the users parameter list.
int main(int narg, char **arg)
void printListDocumentation(const Teuchos::ParameterList &pl, std::ostream &os, std::string listNames)
static string fnParams[NUMFN][3]
static const std::string fail
Defines the Environment class.
int testInvalidValue(Teuchos::ParameterList &pl, string paramName, T badValue)
static string strParams[NUMSTR][3]