X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/fdc3237504c68a8f89faf2c56fa281df7f2bb972..0c55251c3227ee5608f07d61bf4c1392b4985c72:/options.cpp?ds=sidebyside diff --git a/options.cpp b/options.cpp index e413470..1420566 100644 --- a/options.cpp +++ b/options.cpp @@ -1,17 +1,24 @@ -#include "options.h" - #include #include #include #include // getopt #include + +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(main); + #include "loba_simple.h" #include "loba_fairstrategy.h" -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(main); +#include "options.h" namespace opt { + // Constants + + // A sum of loads if considered null if it is less than + // load_ratio_threshold percent of the sum of loads at init. + const double load_ratio_threshold = 1e-4; + // Global options std::string program_name; int help_requested = 0; @@ -47,14 +54,14 @@ namespace opt { loba_algorithms_type::loba_algorithms_type() { NOL_INSERT("fairstrategy", "balance with fair strategy", loba_fairstrategy); - NOL_INSERT("none", "no load-balancing (for testing)", process); + NOL_INSERT("none", "no load-balancing (for testing only)", process); NOL_INSERT("simple", "balance with least loaded neighbor", loba_simple); } topologies_type topologies; topologies_type::topologies_type() { - NOL_INSERT("btree", "binary tree topologym intiial load at root", + NOL_INSERT("btree", "binary tree topology, initial load at root", deployment_btree); NOL_INSERT("clique", "all connected topology", deployment_clique); NOL_INSERT("hcube", "hypercube topology", deployment_hcube); @@ -68,9 +75,9 @@ namespace opt { } // namespace opt -int opt::parse_args(int* argc, char* argv[]) +bool opt::parse_args(int* argc, char* argv[]) { - int result = 1; + bool result = true; opt::program_name = argv[0]; opt::program_name.erase(0, 1 + opt::program_name.find_last_of('/')); @@ -84,7 +91,7 @@ int opt::parse_args(int* argc, char* argv[]) if (!opt::loba_algorithms.exists(opt::loba_algo)) { ERROR1("unknownw load balancing algorithm -- %s", opt::loba_algo.c_str()); - result = 0; + result = false; } break; case 'b': @@ -119,7 +126,7 @@ int opt::parse_args(int* argc, char* argv[]) if (!opt::topologies.exists(opt::auto_depl::topology)) { ERROR1("unknownw topology -- %s", opt::auto_depl::topology.c_str()); - result = 0; + result = false; } break; case 'v': @@ -131,7 +138,7 @@ int opt::parse_args(int* argc, char* argv[]) break; case '?': ERROR1("invalid option -- '%c'", optopt); - result = 0; + result = false; break; } } @@ -143,7 +150,7 @@ int opt::parse_args(int* argc, char* argv[]) opt::platform_file = argv[optind++]; } else { ERROR0("missing parameter -- "); - result = 0; + result = false; } if (optind < *argc) { opt::deployment_file = argv[optind++]; @@ -152,7 +159,7 @@ int opt::parse_args(int* argc, char* argv[]) while (optind < *argc) { ERROR1("unused parameter -- \"%s\"", argv[optind++]); - result = 0; + result = false; } return result;