-#include "process.h"
-
#include <algorithm>
#include <tr1/functional>
#include <iterator>
#include <sstream>
#include <xbt/log.h>
#include <xbt/time.h>
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(proc);
+
#include "misc.h"
#include "options.h"
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(proc);
+#include "process.h"
double process::total_load_init = 0.0;
double process::total_load_exit = 0.0;
oss << neigh.back().get_name();
}
LOG1(logp, "Got %s.", oss.str().c_str());
- print_loads(logp);
+ print_loads(true, logp);
}
process::~process()
INFO2("(%u) current load: %g",
iter, load);
}
- print_loads(xbt_log_priority_debug);
+ print_loads(true, xbt_log_priority_debug);
if (opt::bookkeeping)
expected_load -= load_balance(expected_load);
comm.flush(true);
}
-void process::print_loads(e_xbt_log_priority_t logp)
+#define print_loads_generic(vec, verbose, logp, cat) \
+ if (_XBT_LOG_ISENABLEDV((*cat), logp)) { \
+ using namespace std::tr1; \
+ using namespace std::tr1::placeholders; \
+ XCLOG0(cat, logp, "Neighbor loads:"); \
+ std::for_each(vec.begin(), vec.end(), \
+ bind(&neighbor::print, _1, verbose, logp, cat)); \
+ } else ((void)0)
+
+void process::print_loads(bool verbose,
+ e_xbt_log_priority_t logp,
+ xbt_log_category_t cat) const
{
- if (!LOG_ISENABLED(logp))
- return;
+ print_loads_generic(neigh, verbose, logp, cat);
+}
- std::ostringstream oss;
- if (neigh.empty()) {
- oss << "no neighbor!";
- } else {
- std::transform(neigh.begin(), neigh.end() - 1,
- std::ostream_iterator<double>(oss, ", "),
- std::tr1::mem_fn(&neighbor::get_load));
- oss << neigh.back().get_load();
- }
- LOG1(logp, "Neighbor loads: %s", oss.str().c_str());
+void process::print_loads_p(bool verbose,
+ e_xbt_log_priority_t logp,
+ xbt_log_category_t cat) const
+{
+ print_loads_generic(pneigh, verbose, logp, cat);
}
+#undef print_loads_generic
+
// Local variables:
// mode: c++
// End: