From: Arnaud Giersch Date: Mon, 3 Oct 2011 12:30:38 +0000 (+0200) Subject: New parameter: "-k value", to specify divisor for algorithms *best*. X-Git-Tag: exp_20120216~26 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/43bc22b6612b96aae16aa8f955edfbfe83dab39b?hp=03905d3412f2a4f915f4a1a1564b87ef7adff11a New parameter: "-k value", to specify divisor for algorithms *best*. Define and use opt::loba_best_divisor instead of opt::option_x to specify the divisor for algorithms besteffort and 2besteffort. The command line parameter "-k" is used to change its value. --- diff --git a/TODO b/TODO index e99ae98..dfa7779 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,5 @@ * Remove usage of opt::option_x in loba_besteffort.cpp and loba_2besteffort.cpp - Either simply remove it, or change it to a real option. + Use -k instead (done). Remove hack marked "FIXME" in opt::parse_args(). * Support heterogeneous platforms? Not sure yet. diff --git a/loba_2besteffort.cpp b/loba_2besteffort.cpp index 820c7a5..82fcd36 100644 --- a/loba_2besteffort.cpp +++ b/loba_2besteffort.cpp @@ -31,8 +31,8 @@ void loba_2besteffort::load_balance() // don't continue if get_load() <= mean, or pneigh[i]->get_load >= mean if (transfer <= 0.0) break; - if (opt::option_x) - transfer /= opt::option_x; // HACK!!! + if (opt::loba_best_divisor) + transfer /= opt::loba_best_divisor; send(pneigh[i], transfer); XBT_DEBUG("sent %g to %s", transfer, pneigh[i]->get_name()); } diff --git a/loba_besteffort.cpp b/loba_besteffort.cpp index 22343e0..f3a8c33 100644 --- a/loba_besteffort.cpp +++ b/loba_besteffort.cpp @@ -26,8 +26,8 @@ void loba_besteffort::load_balance() double mean = sum / (bound + 1); for (unsigned i = 0 ; i < bound ; ++i) { double transfer = mean - pneigh[i]->get_load(); - if (opt::option_x) - transfer /= opt::option_x; // HACK!!! + if (opt::loba_best_divisor) + transfer /= opt::loba_best_divisor; send(pneigh[i], transfer); XBT_DEBUG("sent %g to %s", transfer, pneigh[i]->get_name()); } diff --git a/options.cpp b/options.cpp index b440f7c..5ca56d7 100644 --- a/options.cpp +++ b/options.cpp @@ -66,6 +66,7 @@ namespace opt { double min_transfer_amount = 0.0; double max_transfer_amount = 0.0; bool integer_transfer = false; + unsigned loba_best_divisor = 1; // Application parameters cost_func comp_cost("1e9, 0"); // fixme: find better defaults @@ -230,7 +231,7 @@ bool opt::parse_args(int* argc, char* argv[]) int c; opterr = 0; while ((c = getopt(*argc, argv, - "a:bc:C:d:D:eEhi:I:l:L:m:M:N:r:Rs:S:t:T:vVx:X:Z")) + "a:bc:C:d:D:eEhi:I:k:l:L:m:M:N:r:Rs:S:t:T:vVx:X:Z")) != -1) { switch (c) { case 'a': @@ -279,6 +280,9 @@ bool opt::parse_args(int* argc, char* argv[]) case 'i': PARSE_ARG(opt::lb_maxiter); break; + case 'k': + PARSE_ARG(opt::loba_best_divisor); + break; case 'I': PARSE_ARG(opt::comp_maxiter); break; @@ -346,6 +350,13 @@ bool opt::parse_args(int* argc, char* argv[]) #undef PARSE_ARG + if (opt::option_x) { // FIXME: remove this one day... + opt::loba_best_divisor = opt::option_x; + XBT_WARN("divisor for algorithms *best* set from option -x (%d => %u)," + " use -k instead", + opt::option_x, opt::loba_best_divisor); + } + if (opt::version_requested || opt::help_requested) return 1; @@ -373,6 +384,12 @@ bool opt::parse_args(int* argc, char* argv[]) result = false; } + if (opt::loba_best_divisor <= 0) { + XBT_ERROR("divisor for algorithms *best* (%u) should be positive", + opt::loba_best_divisor); + result = false; + } + if (!opt::auto_depl::random_seed) opt::auto_depl::random_seed = time(NULL); @@ -417,6 +434,7 @@ void opt::print() h.val_or_string(max_transfer_amount, "no limit")); DESCR("only transfer integer data shares", "%s", h.on_off(integer_transfer)); + DESCR("divisor for algorithms *best*", "%u", loba_best_divisor); DESCR("minimum duration between comp. iterations", "%g", min_comp_iter_duration); DESCR("computations start after lb. iter", "%u", comp_iter_delay); @@ -503,6 +521,8 @@ void opt::usage() if (opt::help_requested > 1) std::clog << o("") << "(a not so good idea introduced by git commit f5336c5)\n"; + std::clog << o("-k value") << "divisor for algorithms *best*" + << " [" << opt::loba_best_divisor << "]\n"; std::clog << "\nLb. and comp. iterations:\n"; std::clog << o("-s value") diff --git a/options.h b/options.h index 89a3f12..ef7a73e 100644 --- a/options.h +++ b/options.h @@ -49,6 +49,7 @@ namespace opt { extern double max_transfer_amount; extern double min_lb_iter_duration; extern bool integer_transfer; + extern unsigned loba_best_divisor; // Application parameters extern cost_func comp_cost;