// 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
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;
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;
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
<< " (" << 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;
// 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
{
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)
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 &&
// 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.");
*/
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;
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;
}
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