From: Arnaud Giersch Date: Tue, 21 Dec 2010 21:31:59 +0000 (+0100) Subject: Distinguish lb_iter and comp_iter. X-Git-Tag: v0.1~203 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/ef1ef576d25c492dc585240b8a4b36954fc00140 Distinguish lb_iter and comp_iter. --- diff --git a/options.cpp b/options.cpp index 86cec69..fe78559 100644 --- a/options.cpp +++ b/options.cpp @@ -47,7 +47,8 @@ namespace opt { // Application parameters cost_func comp_cost("1e9, 0"); // fixme: find better defaults cost_func comm_cost("1, 0"); // fixme: find better defaults - unsigned maxiter = 10; // fixme: find better defaults + unsigned comp_maxiter = 10; // fixme: find better defaults + unsigned lb_maxiter = comp_maxiter; // fixme: find better defaults bool exit_on_close = false; // Named parameters lists @@ -169,7 +170,7 @@ bool opt::parse_args(int* argc, char* argv[]) int c; opterr = 0; - while ((c = getopt(*argc, argv, "a:bc:C:ehi:l:L:N:T:vV")) != -1) { + while ((c = getopt(*argc, argv, "a:bc:C:ehi:I:l:L:N:T:vV")) != -1) { switch (c) { case 'a': opt::loba_algo = optarg; @@ -193,7 +194,12 @@ bool opt::parse_args(int* argc, char* argv[]) opt::comm_cost = cost_func(optarg); break; case 'i': - std::istringstream(optarg) >> opt::maxiter; + std::istringstream(optarg) >> opt::comp_maxiter; + break; + case 'I': + std::istringstream(optarg) >> opt::lb_maxiter; + ERROR0("option -I not implemented yet"); + result = false; break; case 'l': std::istringstream(optarg) >> opt::log_rate; @@ -267,8 +273,10 @@ void opt::print() DESCR("bookkeeping", "%s", on_off(bookkeeping)); DESCR("computation cost factors", "[%s]", comp_cost.to_string().c_str()); DESCR("communication cost factors", "[%s]", comm_cost.to_string().c_str()); - DESCR("maximum number of iterations", "%s", - val_or_string(maxiter, "infinity")); + DESCR("maximum number of comp. iterations", "%s", + val_or_string(comp_maxiter, "infinity")); + DESCR("maximum number of lb. iterations", "%s", + val_or_string(lb_maxiter, "infinity")); DESCR("exit on close", "%s", on_off(exit_on_close)); INFO0("`----"); #undef DESCR @@ -339,8 +347,11 @@ void opt::usage() << " (" << opt::comm_cost.to_string() << ")\n"; std::clog << o("-e") << "exit on reception of \"close\" message\n"; std::clog << o("-i value") - << "maximum number of iterations, 0 for infinity" - << " (" << opt::maxiter << ")\n"; + << "maximum number of comp. iterations, 0 for infinity" + << " (" << opt::comp_maxiter << ")\n"; + std::clog << o("-I value") + << "maximum number of lb. iterations, 0 for infinity" + << " (" << opt::lb_maxiter << ")\n"; if (opt::help_requested < 3) return; diff --git a/options.h b/options.h index 838dfa0..37a4d8c 100644 --- a/options.h +++ b/options.h @@ -40,7 +40,8 @@ namespace opt { // Application parameters extern cost_func comp_cost; extern cost_func comm_cost; - extern unsigned maxiter; + extern unsigned comp_maxiter; + extern unsigned lb_maxiter; extern bool exit_on_close; // Named parameters lists diff --git a/process.cpp b/process.cpp index 306687f..0b27f0b 100644 --- a/process.cpp +++ b/process.cpp @@ -75,17 +75,17 @@ int process::run() { INFO1("Initial load: %g", load); VERB0("Starting..."); - iter = 0; + comp_iter = lb_iter = 0; while (true) { if (load > 0.0) { - ++iter; - if (opt::log_rate && iter % opt::log_rate == 0) { + ++comp_iter; + if (opt::log_rate && comp_iter % opt::log_rate == 0) { if (opt::bookkeeping) - INFO3("(%u) current load: %g ; expected: %g", - iter, load, expected_load); + INFO4("(%u:%u) current load: %g ; expected: %g", + comp_iter, lb_iter, load, expected_load); else INFO2("(%u) current load: %g", - iter, load); + comp_iter, load); } if (opt::bookkeeping) @@ -98,13 +98,16 @@ int process::run() send(); compute(); - if (opt::maxiter && iter >= opt::maxiter) - break; } else { // send load information, and load when bookkeeping send(); } + if (opt::comp_maxiter && comp_iter >= opt::comp_maxiter) + break; + if (opt::lb_maxiter && lb_iter >= opt::lb_maxiter) + break; + // block on receiving unless there is something to compute or // to send bool recv_wait = (load == 0 && @@ -123,6 +126,7 @@ int process::run() // fixme: this check should be implemented with a distributed // algorithm, and not a shared global variable! + // fixme: should this chunk be moved before call to receive() ? if (100.0 * total_load_running / total_load_init <= opt::load_ratio_threshold) { VERB0("No more load to balance in system, stopping."); @@ -140,7 +144,8 @@ int process::run() */ VERB0("Done."); - INFO3("Final load after %d iteration%s: %g", iter, ESSE(iter), load); + INFO3("Final load after %d iteration%s: %g", + comp_iter, ESSE(comp_iter), load); if (opt::bookkeeping) INFO1("Expected load: %g", expected_load); return 0; @@ -159,7 +164,7 @@ double process::sum_of_to_send() const double process::load_balance(double /*my_load*/) { - if (iter == 1) + if (lb_iter == 1) // warn only once WARN0("process::load_balance is a no-op!"); return 0.0; } diff --git a/process.h b/process.h index c72fdf2..654237b 100644 --- a/process.h +++ b/process.h @@ -69,7 +69,8 @@ private: bool may_receive; // true if there remains neighbors to listen for bool finalizing; // true when finalize() is running - unsigned iter; // counter of iterations + unsigned lb_iter; // counter of load-balancing iterations + unsigned comp_iter; // counter of computation iterations double prev_load_broadcast; // used to ensure that we do not send // a same information messages