| 1 |
/* |
| 2 |
* Copyright(C) 1999-2021, 2023, 2024, 2025 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
|
| 9 |
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 10 |
* Functions contained in this file: |
| 11 |
* main() |
| 12 |
* print_input() |
| 13 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 14 |
#include <cstddef> // for size_t |
| 15 |
#include <cstdlib> // for free, exit, malloc |
| 16 |
#include <cstring> // for strcmp |
| 17 |
#include <iostream> |
| 18 |
#include <stdexcept> |
| 19 |
|
| 20 |
#include "add_to_log.h" // for add_to_log |
| 21 |
#include "elb.h" // for LB_Description<INT>, get_time, etc |
| 22 |
#include "elb_allo.h" // for array_alloc |
| 23 |
#include "elb_elem.h" // for ElementType, ::NULL_EL |
| 24 |
#include "elb_err.h" // for error_report, Gen_Error, etc |
| 25 |
#include "elb_exo.h" // for init_weight_struct, etc |
| 26 |
#include "elb_graph.h" // for generate_graph |
| 27 |
#include "elb_inp.h" // for check_inp_specs, etc |
| 28 |
#include "elb_loadbal.h" // for generate_loadbal, etc |
| 29 |
#include "elb_output.h" // for write_nemesis, write_vis |
| 30 |
#include "fmt/ostream.h" |
| 31 |
|
| 32 |
#ifdef USE_ZOLTAN |
| 33 |
#include <mpi.h> // for MPI_Finalize, etc |
| 34 |
#endif |
| 35 |
|
| 36 |
namespace { |
| 37 |
template <typename INT> |
| 38 |
void print_input(Machine_Description * /*machine*/, LB_Description<INT> * /*lb*/, |
| 39 |
Problem_Description * /*prob*/, Solver_Description * /*solver*/, |
| 40 |
Weight_Description * /*weight*/); |
| 41 |
|
| 42 |
} // namespace |
| 43 |
|
| 44 |
/*****************************************************************************/ |
| 45 |
/*****************************************************************************/ |
| 46 |
/*****************************************************************************/ |
| 47 |
/* Routine which reads in a EXODUS II mesh database and load balances the |
| 48 |
* mesh by either a nodal or element assignment. |
| 49 |
*---------------------------------------------------------------------------- |
| 50 |
* Functions called: |
| 51 |
* cmd_line_arg_parse() |
| 52 |
* read_cmd_file() |
| 53 |
* check_inp_specs() |
| 54 |
* print_input() |
| 55 |
* read_exo_weights() |
| 56 |
* read_mesh_params() |
| 57 |
* read_mesh() |
| 58 |
* generate_gaph() |
| 59 |
* generate_loadbal() |
| 60 |
* write_vis() |
| 61 |
* generate_maps() |
| 62 |
* write_nemesis() |
| 63 |
*---------------------------------------------------------------------------- |
| 64 |
* Variable Index: |
| 65 |
* machine - structure containing information about the machine |
| 66 |
* for which the load balance is to be generated. |
| 67 |
* lb - structure containing information about what type |
| 68 |
* of load balance is to be performed. |
| 69 |
* problem - structure containing information about the problem |
| 70 |
* type. Currently whether the problem is a nodal or |
| 71 |
* elemental based decomposition. |
| 72 |
* solver - structure containing various parameters for the |
| 73 |
* eigensolver used by Chaco. |
| 74 |
* weight - structure used to store parameters about how to |
| 75 |
* weight the resulting graph before it is fed into |
| 76 |
* Chaco. |
| 77 |
* graph - structure containing the graph of the problem. |
| 78 |
* mesh - structure containing a description of the FEM mesh. |
| 79 |
* exoII_inp_file - name of the ExodusII file containing the problem |
| 80 |
* geometry. |
| 81 |
* ascii_inp_file - name of the input command file. |
| 82 |
* nemI_out_file - name of the output NemesisI file. |
| 83 |
* |
| 84 |
*****************************************************************************/ |
| 85 |
template <typename INT> int internal_main(int argc, char *argv[], INT /* dummy */); |
| 86 |
|
| 87 |
int main(int argc, char *argv[]) |
| 88 |
{ |
| 89 |
fmt::print(stderr, "Beginning nem_slice execution.\n"); |
| 90 |
|
| 91 |
double start_time = get_time(); |
| 92 |
|
| 93 |
/* Initialize to just reporting the error */ |
| 94 |
error_lev = 1; |
| 95 |
|
| 96 |
/* check if the user just wants to know the version (or forcing 64-bit mode)*/ |
| 97 |
bool int64com = false; |
| 98 |
bool int32com = false; |
| 99 |
int int64db = 0; |
| 100 |
|
| 101 |
for (int cnt = 0; cnt < argc; cnt++) { |
| 102 |
if (strcmp(argv[cnt], "-V") == 0) { |
| 103 |
fmt::print("{} version {}\n", UTIL_NAME, ELB_VERSION); |
| 104 |
exit(0); |
| 105 |
} |
| 106 |
if (strcmp(argv[cnt], "-64") == 0) { |
| 107 |
int64com = true; |
| 108 |
} |
| 109 |
|
| 110 |
if (strcmp(argv[cnt], "-32") == 0) { |
| 111 |
int32com = true; |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
if (argc > 2) { |
| 116 |
/* Get the input mesh file so we can determine the integer size... */ |
| 117 |
/* Should be the last item on the command line */ |
| 118 |
char *mesh_file_name = argv[argc - 1]; |
| 119 |
|
| 120 |
/* Open file and get the integer size... */ |
| 121 |
int cpu_ws = 0; |
| 122 |
int io_ws = 0; |
| 123 |
float vers = 00.0; |
| 124 |
fmt::print(stderr, "Input Mesh File = '{}\n", mesh_file_name); |
| 125 |
int exoid = ex_open(mesh_file_name, EX_READ, &cpu_ws, &io_ws, &vers); |
| 126 |
if (exoid < 0) { |
| 127 |
std::string error("fatal: unable to open input ExodusII file "); |
| 128 |
error += mesh_file_name; |
| 129 |
Gen_Error(0, error); |
| 130 |
return 0; |
| 131 |
} |
| 132 |
|
| 133 |
int64db = ex_int64_status(exoid) & EX_ALL_INT64_DB; |
| 134 |
ex_close(exoid); |
| 135 |
|
| 136 |
ex_opts(EX_VERBOSE); |
| 137 |
} |
| 138 |
|
| 139 |
int status; |
| 140 |
if (int32com && (int64db != 0)) { |
| 141 |
fmt::print(stderr, |
| 142 |
"Forcing 32-bit integer mode for decomposition even though database is 64-bit.\n"); |
| 143 |
status = internal_main(argc, argv, int(0)); |
| 144 |
} |
| 145 |
else if ((int64db != 0) || int64com) { |
| 146 |
fmt::print(stderr, |
| 147 |
"Using 64-bit integer mode for decomposition...\n" |
| 148 |
"NOTE: Only 'linear' and 'scattered' methods are supported for 64-bit models\n"); |
| 149 |
|
| 150 |
status = internal_main(argc, argv, int64_t(0)); |
| 151 |
} |
| 152 |
else { |
| 153 |
fmt::print(stderr, "Using 32-bit integer mode for decomposition...\n"); |
| 154 |
status = internal_main(argc, argv, int(0)); |
| 155 |
} |
| 156 |
|
| 157 |
/* Report any non-fatal errors that may have occurred */ |
| 158 |
error_report(); |
| 159 |
|
| 160 |
/* Get ending time */ |
| 161 |
double end_time = get_time(); |
| 162 |
fmt::print(stderr, "The entire load balance took {} seconds.\n", end_time - start_time); |
| 163 |
add_to_log(argv[0], end_time - start_time); |
| 164 |
return status; |
| 165 |
} |
| 166 |
|
| 167 |
template <typename INT> int internal_main(int argc, char *argv[], INT /* dummy */) |
| 168 |
{ |
| 169 |
/* Local variables */ |
| 170 |
std::string exoII_inp_file; |
| 171 |
std::string ascii_inp_file; |
| 172 |
std::string nemI_out_file; |
| 173 |
|
| 174 |
Machine_Description machine; |
| 175 |
LB_Description<INT> lb; |
| 176 |
Problem_Description problem; |
| 177 |
Solver_Description solver; |
| 178 |
Weight_Description weight; |
| 179 |
Mesh_Description<INT> mesh; |
| 180 |
Sphere_Info sphere; |
| 181 |
Graph_Description<INT> graph; |
| 182 |
|
| 183 |
/*-----------------------------Execution Begins------------------------------*/ |
| 184 |
#ifdef USE_ZOLTAN |
| 185 |
MPI_Init(&argc, &argv); |
| 186 |
#endif |
| 187 |
|
| 188 |
mesh.title[0] = '\0'; |
| 189 |
|
| 190 |
if (sizeof(INT) == 8) { |
| 191 |
problem.int64api = EX_ALL_INT64_API; |
| 192 |
} |
| 193 |
|
| 194 |
/* Parse the command line */ |
| 195 |
if (!cmd_line_arg_parse(argc, argv, exoII_inp_file, ascii_inp_file, nemI_out_file, &machine, &lb, |
| 196 |
&problem, &solver, &weight)) { |
| 197 |
fmt::print(stderr, "error parsing command line\n"); |
| 198 |
error_report(); |
| 199 |
exit(1); |
| 200 |
} |
| 201 |
|
| 202 |
/* |
| 203 |
*If the information is to be taken from an ASCII input file then |
| 204 |
* read that file. |
| 205 |
*/ |
| 206 |
if (!ascii_inp_file.empty()) { |
| 207 |
if (!read_cmd_file(ascii_inp_file, exoII_inp_file, nemI_out_file, &machine, &lb, &problem, |
| 208 |
&solver, &weight)) { |
| 209 |
fmt::print(stderr, "error parsing command file\n"); |
| 210 |
error_report(); |
| 211 |
exit(1); |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
/* make sure that this type is set */ |
| 216 |
if (weight.type < 0) { |
| 217 |
weight.type = NO_WEIGHT; |
| 218 |
} |
| 219 |
|
| 220 |
/* |
| 221 |
* Perform at least some rudimentary error checks on the user |
| 222 |
* specified input. |
| 223 |
*/ |
| 224 |
if (!check_inp_specs(exoII_inp_file, nemI_out_file, &machine, &lb, &problem, &solver, &weight)) { |
| 225 |
fmt::print(stderr, "Error in user specified parameters\n"); |
| 226 |
error_report(); |
| 227 |
exit(1); |
| 228 |
} |
| 229 |
|
| 230 |
/* Output the parameters for the run to the screen */ |
| 231 |
print_input(&machine, &lb, &problem, &solver, &weight); |
| 232 |
|
| 233 |
/* Read in mesh parameters */ |
| 234 |
double time1 = get_time(); |
| 235 |
if (!read_mesh_params(exoII_inp_file, &problem, &mesh, &sphere)) { |
| 236 |
fmt::print(stderr, "Error reading mesh parameters\n"); |
| 237 |
error_report(); |
| 238 |
exit(1); |
| 239 |
} |
| 240 |
double time2 = get_time(); |
| 241 |
fmt::print("Time to read mesh parameters: {}s\n", time2 - time1); |
| 242 |
|
| 243 |
/* Check for error conditions */ |
| 244 |
if ((mesh.num_nodes) / (machine.num_procs) < 1) { |
| 245 |
Gen_Error(0, "fatal: problem divided among too many processors"); |
| 246 |
error_report(); |
| 247 |
exit(1); |
| 248 |
} |
| 249 |
else if ((problem.type == DecompType::ELEMENTAL) && |
| 250 |
((mesh.num_elems) / (machine.num_procs) < 1)) { |
| 251 |
Gen_Error(0, "fatal: problem divided among too many processors"); |
| 252 |
error_report(); |
| 253 |
exit(1); |
| 254 |
} |
| 255 |
|
| 256 |
/* If vertex weighting is turned on, prepare weight struct */ |
| 257 |
if ((weight.type & READ_EXO) || (weight.type & EL_BLK)) { |
| 258 |
time1 = get_time(); |
| 259 |
if (!init_weight_struct(&problem, &mesh, &weight)) { |
| 260 |
fmt::print(stderr, "Error during initialization of weight struct\n"); |
| 261 |
error_report(); |
| 262 |
exit(1); |
| 263 |
} |
| 264 |
time2 = get_time(); |
| 265 |
fmt::print("Time to initialize weight struct: {}s\n", time2 - time1); |
| 266 |
} |
| 267 |
|
| 268 |
/* If desired, read in the weighting factors from the ExodusII file */ |
| 269 |
if (weight.type & READ_EXO) { |
| 270 |
time1 = get_time(); |
| 271 |
if (!read_exo_weights(&problem, &weight, (INT)0)) { |
| 272 |
fmt::print(stderr, "Error during read of ExodusII weights\n"); |
| 273 |
error_report(); |
| 274 |
exit(1); |
| 275 |
} |
| 276 |
time2 = get_time(); |
| 277 |
fmt::print("Time to read ExodusII weights: {}s\n", time2 - time1); |
| 278 |
} |
| 279 |
|
| 280 |
/* Initialize various parameters */ |
| 281 |
if (lb.type == Balance::INERTIAL || lb.type == Balance::ZPINCH || lb.type == Balance::BRICK || |
| 282 |
lb.type == Balance::ZOLTAN_RCB || lb.type == Balance::ZOLTAN_RIB || |
| 283 |
lb.type == Balance::ZOLTAN_HSFC || problem.vis_out == 1 || problem.vis_out == 2) { |
| 284 |
problem.read_coords = ELB_TRUE; |
| 285 |
} |
| 286 |
else { |
| 287 |
problem.read_coords = ELB_FALSE; |
| 288 |
} |
| 289 |
|
| 290 |
if (lb.type != Balance::SPECTRAL) { |
| 291 |
problem.coarse_flag = ELB_FALSE; |
| 292 |
} |
| 293 |
else { |
| 294 |
problem.coarse_flag = ELB_TRUE; |
| 295 |
} |
| 296 |
|
| 297 |
if (lb.refine == Balance::KL_REFINE) { |
| 298 |
problem.alloc_graph = ELB_TRUE; |
| 299 |
} |
| 300 |
else if (lb.type == Balance::SPECTRAL) { |
| 301 |
problem.alloc_graph = ELB_TRUE; |
| 302 |
} |
| 303 |
else { |
| 304 |
problem.alloc_graph = ELB_FALSE; |
| 305 |
} |
| 306 |
|
| 307 |
/* if fix_columns is on, we need the face adjacency graph. So if |
| 308 |
* nothing else has asked for the full adjacency graph, ask for the |
| 309 |
* face adjacency graph. If something else did ask for the adjacency |
| 310 |
* graph, we don't know if its full or face adjacency only, so leave |
| 311 |
* the option as is */ |
| 312 |
|
| 313 |
if (problem.fix_columns) { |
| 314 |
if (problem.alloc_graph == ELB_FALSE) { |
| 315 |
problem.alloc_graph = ELB_TRUE; |
| 316 |
problem.face_adj = ELB_TRUE; |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
/* Allocate necessary memory */ |
| 321 |
if (problem.type == DecompType::NODAL) { |
| 322 |
problem.num_vertices = mesh.num_nodes; |
| 323 |
} |
| 324 |
else if (problem.type == DecompType::ELEMENTAL) { |
| 325 |
problem.num_vertices = (mesh.num_elems - sphere.num); |
| 326 |
} |
| 327 |
|
| 328 |
if (problem.read_coords == ELB_TRUE) { |
| 329 |
size_t mem_req = (size_t)(mesh.num_dims) * (mesh.num_nodes) * sizeof(float); |
| 330 |
mesh.coords.resize(mem_req); |
| 331 |
} |
| 332 |
|
| 333 |
mesh.elem_type.resize(mesh.num_elems); |
| 334 |
mesh.connect = static_cast<INT **>(array_alloc(2, mesh.num_elems, mesh.max_np_elem, sizeof(INT))); |
| 335 |
if (!(mesh.connect)) { |
| 336 |
Gen_Error(0, "fatal: insufficient memory"); |
| 337 |
error_report(); |
| 338 |
exit(1); |
| 339 |
} |
| 340 |
|
| 341 |
/* Read the mesh */ |
| 342 |
time1 = get_time(); |
| 343 |
if (!read_mesh(exoII_inp_file, &problem, &mesh, &weight)) { |
| 344 |
Gen_Error(0, "fatal: could not read mesh"); |
| 345 |
error_report(); |
| 346 |
exit(1); |
| 347 |
} |
| 348 |
time2 = get_time(); |
| 349 |
fmt::print("Time to read mesh: {}s\n", time2 - time1); |
| 350 |
|
| 351 |
/* free unneeded memory */ |
| 352 |
vec_free(weight.ow); |
| 353 |
vec_free(weight.elemblk); |
| 354 |
vec_free(weight.elemblk_wgt); |
| 355 |
|
| 356 |
/* Generate the graph for the mesh */ |
| 357 |
time1 = get_time(); |
| 358 |
if (!generate_graph(&problem, &mesh, &graph, &weight, &sphere)) { |
| 359 |
Gen_Error(0, "fatal: could not generate graph"); |
| 360 |
error_report(); |
| 361 |
exit(1); |
| 362 |
} |
| 363 |
time2 = get_time(); |
| 364 |
fmt::print("Time to generate graph: {}s\n", time2 - time1); |
| 365 |
|
| 366 |
/* Generate load balance */ |
| 367 |
try { |
| 368 |
time1 = get_time(); |
| 369 |
if (!generate_loadbal(&machine, &problem, &mesh, &lb, &solver, &graph, &weight, &sphere, argc, |
| 370 |
argv)) { |
| 371 |
Gen_Error(0, "fatal: could not generate load balance"); |
| 372 |
error_report(); |
| 373 |
exit(1); |
| 374 |
} |
| 375 |
time2 = get_time(); |
| 376 |
fmt::print("Time to generate load balance: {}s\n", time2 - time1); |
| 377 |
} |
| 378 |
catch (const std::exception &e) { |
| 379 |
fmt::print(stderr, "NEM_SLICE: Exception in generate_loadbal: {}\n", e.what()); |
| 380 |
} |
| 381 |
|
| 382 |
/* free up memory */ |
| 383 |
sphere.adjust.clear(); |
| 384 |
sphere.begin.clear(); |
| 385 |
sphere.end.clear(); |
| 386 |
|
| 387 |
#ifdef PRINT_VERT |
| 388 |
for (size_t cnt = 0; cnt < problem.num_vertices; cnt++) |
| 389 |
fmt::print("element = {}, proc = {}\n", cnt, lb.vertex2proc[cnt]); |
| 390 |
#endif |
| 391 |
|
| 392 |
/* |
| 393 |
* NOTE: in Chaco, if FREE_GRAPH is set to 1, the following arrays |
| 394 |
* are freed: graph.start |
| 395 |
* graph.adj |
| 396 |
* weight.vertices |
| 397 |
* weight.edges |
| 398 |
* |
| 399 |
* Need to take into account special case where the mesh contains |
| 400 |
* only spheres. In this case Chaco is not called, and the above |
| 401 |
* arrays are not freed |
| 402 |
*/ |
| 403 |
|
| 404 |
if (sphere.num >= mesh.num_elems) { |
| 405 |
vec_free(graph.start); |
| 406 |
vec_free(graph.adj); |
| 407 |
vec_free(weight.vertices); |
| 408 |
vec_free(weight.edges); |
| 409 |
} |
| 410 |
|
| 411 |
/* Generate the load balance maps */ |
| 412 |
time1 = get_time(); |
| 413 |
if (!generate_maps(&machine, &problem, &mesh, &lb, &graph)) { |
| 414 |
Gen_Error(0, "fatal: could not generate load-balance maps"); |
| 415 |
error_report(); |
| 416 |
exit(1); |
| 417 |
} |
| 418 |
time2 = get_time(); |
| 419 |
fmt::print("Time to generate load-balance maps: {}s\n", time2 - time1); |
| 420 |
|
| 421 |
/* Output the visualization file */ |
| 422 |
if (problem.vis_out == 1 || problem.vis_out == 2) { |
| 423 |
time1 = get_time(); |
| 424 |
if (!write_vis(nemI_out_file, exoII_inp_file, &machine, &problem, &mesh, &lb)) { |
| 425 |
Gen_Error(0, "warning: unable to output visualization file"); |
| 426 |
} |
| 427 |
time2 = get_time(); |
| 428 |
fmt::print("Time to output visualization file: {}s\n", time2 - time1); |
| 429 |
} |
| 430 |
|
| 431 |
/* Free up memory no longer needed */ |
| 432 |
if (problem.read_coords == ELB_TRUE) { |
| 433 |
mesh.coords.clear(); |
| 434 |
} |
| 435 |
|
| 436 |
mesh.elem_type.clear(); |
| 437 |
free(mesh.connect); |
| 438 |
|
| 439 |
if (!graph.sur_elem.empty()) { |
| 440 |
for (size_t cnt = 0; cnt < mesh.num_nodes; cnt++) { |
| 441 |
vec_free(graph.sur_elem[cnt]); |
| 442 |
} |
| 443 |
vec_free(graph.sur_elem); |
| 444 |
} |
| 445 |
|
| 446 |
/* Output a Nemesis load balance file */ |
| 447 |
time1 = get_time(); |
| 448 |
if (!write_nemesis(nemI_out_file, &machine, &problem, &mesh, &lb, &sphere)) { |
| 449 |
Gen_Error(0, "fatal: could not output Nemesis file"); |
| 450 |
error_report(); |
| 451 |
exit(1); |
| 452 |
} |
| 453 |
time2 = get_time() - time1; |
| 454 |
fmt::print("Time to write Nemesis file: {}s\n", time2); |
| 455 |
|
| 456 |
/* Free up unused memory for leak checking */ |
| 457 |
for (int cnt = 0; cnt < machine.num_procs; cnt++) { |
| 458 |
vec_free(lb.int_nodes[cnt]); |
| 459 |
vec_free(lb.bor_nodes[cnt]); |
| 460 |
if (problem.type == DecompType::NODAL) { |
| 461 |
vec_free(lb.ext_nodes[cnt]); |
| 462 |
vec_free(lb.ext_procs[cnt]); |
| 463 |
} |
| 464 |
|
| 465 |
vec_free(lb.int_elems[cnt]); |
| 466 |
if (problem.type == DecompType::ELEMENTAL) { |
| 467 |
vec_free(lb.bor_elems[cnt]); |
| 468 |
} |
| 469 |
} |
| 470 |
|
| 471 |
vec_free(lb.int_nodes); |
| 472 |
|
| 473 |
if (problem.type == DecompType::NODAL) { |
| 474 |
vec_free(lb.ext_nodes); |
| 475 |
vec_free(lb.ext_procs); |
| 476 |
} |
| 477 |
|
| 478 |
vec_free(lb.int_elems); |
| 479 |
|
| 480 |
if (problem.type == DecompType::ELEMENTAL) { |
| 481 |
vec_free(lb.bor_elems); |
| 482 |
for (int cnt = 0; cnt < machine.num_procs; cnt++) { |
| 483 |
for (size_t cnt1 = 0; cnt1 < lb.bor_nodes[cnt].size(); cnt1++) { |
| 484 |
vec_free(lb.born_procs[cnt][cnt1]); |
| 485 |
} |
| 486 |
|
| 487 |
if (!lb.born_procs[cnt].empty()) { |
| 488 |
vec_free(lb.born_procs[cnt]); |
| 489 |
} |
| 490 |
vec_free(lb.ext_procs[cnt]); |
| 491 |
vec_free(lb.e_cmap_elems[cnt]); |
| 492 |
vec_free(lb.e_cmap_sides[cnt]); |
| 493 |
vec_free(lb.e_cmap_procs[cnt]); |
| 494 |
vec_free(lb.e_cmap_neigh[cnt]); |
| 495 |
} |
| 496 |
vec_free(lb.e_cmap_elems); |
| 497 |
vec_free(lb.born_procs); |
| 498 |
vec_free(lb.ext_procs); |
| 499 |
} |
| 500 |
|
| 501 |
vec_free(lb.bor_nodes); |
| 502 |
free(lb.vertex2proc); |
| 503 |
|
| 504 |
#ifdef USE_ZOLTAN |
| 505 |
MPI_Finalize(); |
| 506 |
#endif |
| 507 |
|
| 508 |
return 0; |
| 509 |
} |
| 510 |
|
| 511 |
/*****************************************************************************/ |
| 512 |
/*****************************************************************************/ |
| 513 |
/*****************************************************************************/ |
| 514 |
/* This function prints out parameters as read from the command line and/or |
| 515 |
* the input ASCII load-balance file. |
| 516 |
*---------------------------------------------------------------------------*/ |
| 517 |
namespace { |
| 518 |
template <typename INT> |
| 519 |
void print_input(Machine_Description *machine, LB_Description<INT> *lb, Problem_Description *prob, |
| 520 |
Solver_Description *solver, Weight_Description *weight) |
| 521 |
{ |
| 522 |
fmt::print("{} version {}\n", UTIL_NAME, ELB_VERSION); |
| 523 |
|
| 524 |
fmt::print("Performing "); |
| 525 |
switch (prob->type) { |
| 526 |
case DecompType::NODAL: fmt::print("a nodal "); break; |
| 527 |
|
| 528 |
case DecompType::ELEMENTAL: fmt::print("an elemental "); break; |
| 529 |
} |
| 530 |
|
| 531 |
fmt::print("load balance with the following parameters...\n"); |
| 532 |
|
| 533 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 534 |
/* Machine_Description PARAMETERS */ |
| 535 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 536 |
fmt::print("Machine Description\n"); |
| 537 |
if (machine->num_boxes > 1) { |
| 538 |
fmt::print("\tCluster of {} boxes\n", machine->num_boxes); |
| 539 |
fmt::print("\tarchitecture of each box: "); |
| 540 |
} |
| 541 |
else { |
| 542 |
fmt::print("\tarchitecture: "); |
| 543 |
} |
| 544 |
switch (machine->type) { |
| 545 |
case MachineType::HCUBE: fmt::print("hypercube\n"); break; |
| 546 |
case MachineType::MESH: fmt::print("mesh\n"); break; |
| 547 |
default: fmt::print("invalid/unknown\n"); break; |
| 548 |
} |
| 549 |
|
| 550 |
if (machine->num_boxes > 1) { |
| 551 |
fmt::print("\tdimension(s) of each box: "); |
| 552 |
} |
| 553 |
else { |
| 554 |
fmt::print("\tdimension(s): "); |
| 555 |
} |
| 556 |
|
| 557 |
switch (machine->type) { |
| 558 |
case MachineType::HCUBE: fmt::print("{}\n", machine->dim[0]); break; |
| 559 |
|
| 560 |
case MachineType::MESH: |
| 561 |
for (int cnt = 0; cnt < (machine->num_dims) - 1; cnt++) { |
| 562 |
fmt::print("{}x", machine->dim[cnt]); |
| 563 |
} |
| 564 |
|
| 565 |
fmt::print("{}\n", machine->dim[(machine->num_dims) - 1]); |
| 566 |
break; |
| 567 |
default:; /* do nothing */ |
| 568 |
} |
| 569 |
fmt::print("\ttotal number of processors: {}\n", machine->num_procs); |
| 570 |
|
| 571 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 572 |
/* LOAD BALANCE PARAMETERS */ |
| 573 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 574 |
fmt::print("Load Balance Parameters\n"); |
| 575 |
switch (lb->type) { |
| 576 |
case Balance::MULTIKL: |
| 577 |
fmt::print("\ttype: multilevel\n"); |
| 578 |
fmt::print("\tnumber of sections: {}\n", lb->num_sects); |
| 579 |
break; |
| 580 |
|
| 581 |
case Balance::SPECTRAL: |
| 582 |
fmt::print("\ttype: spectral\n"); |
| 583 |
fmt::print("\tnumber of sections: {}\n", lb->num_sects); |
| 584 |
break; |
| 585 |
|
| 586 |
case Balance::INERTIAL: fmt::print("\ttype: inertial\n"); break; |
| 587 |
|
| 588 |
case Balance::ZPINCH: fmt::print("\ttype: zpinch\n"); break; |
| 589 |
|
| 590 |
case Balance::BRICK: fmt::print("\ttype: brick\n"); break; |
| 591 |
|
| 592 |
case Balance::ZOLTAN_RCB: fmt::print("\ttype: rcb\n"); break; |
| 593 |
|
| 594 |
case Balance::ZOLTAN_RIB: fmt::print("\ttype: rib\n"); break; |
| 595 |
|
| 596 |
case Balance::ZOLTAN_HSFC: fmt::print("\ttype: hsfc\n"); break; |
| 597 |
|
| 598 |
case Balance::LINEAR: fmt::print("\ttype: linear\n"); break; |
| 599 |
|
| 600 |
case Balance::RANDOM: fmt::print("\ttype: random\n"); break; |
| 601 |
|
| 602 |
case Balance::SCATTERED: fmt::print("\ttype: scattered\n"); break; |
| 603 |
|
| 604 |
case Balance::INFILE: |
| 605 |
fmt::print("\ttype: input from file\n"); |
| 606 |
fmt::print("\tfile name: {}\n", lb->file); |
| 607 |
break; |
| 608 |
default:; /* do nothing */ |
| 609 |
} |
| 610 |
fmt::print("\trefinement: "); |
| 611 |
switch (lb->refine) { |
| 612 |
case Balance::KL_REFINE: fmt::print("Kernighan-Lin\n"); break; |
| 613 |
|
| 614 |
case Balance::NO_REFINE: fmt::print("none\n"); break; |
| 615 |
default:; /* do nothing */ |
| 616 |
} |
| 617 |
if (lb->cnctd_dom) { |
| 618 |
fmt::print("\tConnected Domain enforced\n"); |
| 619 |
} |
| 620 |
if (lb->outfile) { |
| 621 |
fmt::print("\toutput assignment vector\n"); |
| 622 |
fmt::print("\tfile name: {}\n", lb->file); |
| 623 |
} |
| 624 |
|
| 625 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 626 |
/* EIGENSOLVER PARAMETERS */ |
| 627 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 628 |
if (lb->type == Balance::MULTIKL || lb->type == Balance::SPECTRAL) { |
| 629 |
fmt::print("Eigensolver Parameters\n"); |
| 630 |
fmt::print("\teignsolver tolerance: {}\n", solver->tolerance); |
| 631 |
if (solver->rqi_flag == SolverOptions::USE_RQI) { |
| 632 |
fmt::print("\tusing RQI/Symmlq eigensolver\n"); |
| 633 |
fmt::print("\tnumber of vertices to coarsen down to: {}\n", solver->vmax); |
| 634 |
} |
| 635 |
} |
| 636 |
|
| 637 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 638 |
/* WEIGHTING PARAMETERS */ |
| 639 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 640 |
fmt::print("Weighting Parameters\n"); |
| 641 |
if (weight->type == NO_WEIGHT) { |
| 642 |
fmt::print("\tno weighting\n"); |
| 643 |
} |
| 644 |
else if (weight->type & READ_EXO) { |
| 645 |
fmt::print("\tweights from: ExodusII file\n"); |
| 646 |
fmt::print("\ttime index: {}\n", weight->exo_tindx); |
| 647 |
fmt::print("\tvariable index: {}\n", weight->exo_vindx); |
| 648 |
fmt::print("\tvariable name: {}\n", weight->exo_varname); |
| 649 |
} |
| 650 |
else if (weight->type & EL_BLK) { |
| 651 |
fmt::print("\tElement Block weights specified\n"); |
| 652 |
for (size_t cnt = 0; cnt < weight->elemblk.size(); cnt++) { |
| 653 |
fmt::print("\telement block: {}, weight: {}\n", weight->elemblk[cnt], |
| 654 |
weight->elemblk_wgt[cnt]); |
| 655 |
} |
| 656 |
} |
| 657 |
else if (weight->type & EDGE_WGT) { |
| 658 |
fmt::print("\tedge weights turned on\n"); |
| 659 |
} |
| 660 |
|
| 661 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 662 |
/* WEIGHTING PARAMETERS */ |
| 663 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
| 664 |
fmt::print("Miscellaneous Options\n"); |
| 665 |
if (prob->face_adj == 1) { |
| 666 |
fmt::print("\tusing face definition of adjacency\n"); |
| 667 |
} |
| 668 |
if (prob->global_mech == 1) { |
| 669 |
fmt::print("\tlooking for global mechanisms\n"); |
| 670 |
} |
| 671 |
if (prob->local_mech == 1) { |
| 672 |
fmt::print("\tlooking for local mechanisms\n"); |
| 673 |
} |
| 674 |
if (prob->find_cnt_domains == 1) { |
| 675 |
fmt::print("\tidentifying the number of disconnected element blocks on a subdomain\n"); |
| 676 |
} |
| 677 |
if (prob->mech_add_procs == 1) { |
| 678 |
fmt::print("\tincreasing the number of processors if mechanisms are found\n"); |
| 679 |
} |
| 680 |
if (prob->dsd_add_procs == 1) { |
| 681 |
fmt::print("\tincreasing the number of processors if disconnected sudomains are found\n"); |
| 682 |
} |
| 683 |
if (prob->no_sph == 1) { |
| 684 |
fmt::print("\tSPHERES are being treated as concentrated mass - connectivity exists\n"); |
| 685 |
} |
| 686 |
if (prob->skip_checks == 1) { |
| 687 |
fmt::print("\tWARNING: side id error checks turned off\n"); |
| 688 |
} |
| 689 |
if (prob->groups != nullptr) { |
| 690 |
fmt::print("\telement block groups defined\n"); |
| 691 |
fmt::print("\tgroup string: \"{}\"\n", prob->groups); |
| 692 |
} |
| 693 |
} |
| 694 |
} // namespace |