CXX := g++
CPPFLAGS += -I $(SIMGRID_INSTALL_DIR)/include
-CPPFLAGS += -D XBT_LOG_OLD_STYLE
CPPFLAGS += $(CHECK_FLAGS)
#CFLAGS += -std=c99
{
m_task_t task;
- DEBUG0("send finalize to receiver/ctrl");
+ XBT_DEBUG("send finalize to receiver/ctrl");
task = MSG_task_create("finalize", 0.0, 0, NULL);
MSG_task_send(task, get_ctrl_mbox());
- DEBUG0("send finalize to receiver/data");
+ XBT_DEBUG("send finalize to receiver/data");
task = MSG_task_create("finalize", 0.0, 0, NULL);
MSG_task_send(task, get_data_mbox());
xbt_mutex_acquire(mutex);
while (receiver_process) {
- DEBUG0("waiting for receiver to terminate");
+ XBT_DEBUG("waiting for receiver to terminate");
xbt_cond_wait(cond, mutex);
}
xbt_mutex_release(mutex);
if (ctrl_comm)
- WARN0("ctrl_comm is pending!");
+ XBT_WARN("ctrl_comm is pending!");
if (data_comm)
- WARN0("data_comm is pending!");
+ XBT_WARN("data_comm is pending!");
if (!received.empty())
- WARN2("lost %lu received message%s!",
- (unsigned long )received.size(), ESSE(received.size()));
+ XBT_WARN("lost %lu received message%s!",
+ (unsigned long )received.size(), ESSE(received.size()));
if (!sent_comm.empty())
- WARN2("lost %lu sent message%s!",
- (unsigned long )sent_comm.size(), ESSE(sent_comm.size()));
+ XBT_WARN("lost %lu sent message%s!",
+ (unsigned long )sent_comm.size(), ESSE(sent_comm.size()));
xbt_cond_destroy(cond);
xbt_mutex_destroy(mutex);
void communicator::send(const char* dest, message* msg)
{
- DEBUG2("send %s to %s", msg->to_string().c_str(), dest);
+ XBT_DEBUG("send %s to %s", msg->to_string().c_str(), dest);
double msg_size = sizeof *msg;
if (msg->get_type() == message::LOAD)
msg_size += opt::comm_cost(msg->get_amount());
xbt_mutex_acquire(mutex);
while (received.empty() && (!deadline || deadline > MSG_get_clock())) {
xbt_ex_t e;
- DEBUG0("waiting for a message to come");
+ XBT_DEBUG("waiting for a message to come");
TRY {
if (deadline)
xbt_cond_timedwait(cond, mutex, deadline - MSG_get_clock());
from = MSG_task_get_source(task);
MSG_task_destroy(task);
- DEBUG2("received %s from %s",
+ XBT_DEBUG("received %s from %s",
msg->to_string().c_str(), MSG_host_get_name(from));
return true;
comm = static_cast<communicator*>(MSG_process_get_data(MSG_process_self()));
int result = comm->receiver();
- DEBUG0("terminate");
+ XBT_DEBUG("terminate");
xbt_mutex_acquire(comm->mutex);
comm->receiver_process = NULL;
xbt_cond_signal(comm->cond);
{
ctrl_comm = MSG_task_irecv(&ctrl_task, get_ctrl_mbox());
data_comm = MSG_task_irecv(&data_task, get_data_mbox());
- DEBUG0("receiver ready");
+ XBT_DEBUG("receiver ready");
xbt_mutex_acquire(mutex);
xbt_cond_signal(cond); // signal master that we are ready
xbt_mutex_release(mutex);
if (ctrl_comm && comm_test_n_destroy(ctrl_comm)) {
if (strcmp(MSG_task_get_name(ctrl_task), "finalize")) {
- DEBUG0("received message from ctrl");
+ XBT_DEBUG("received message from ctrl");
xbt_mutex_acquire(mutex);
received.push(ctrl_task);
xbt_mutex_release(mutex);
ctrl_task = NULL;
ctrl_comm = MSG_task_irecv(&ctrl_task, get_ctrl_mbox());
} else {
- DEBUG0("received finalize from ctrl");
+ XBT_DEBUG("received finalize from ctrl");
MSG_task_destroy(ctrl_task);
ctrl_task = NULL;
ctrl_comm = NULL;
if (data_comm && comm_test_n_destroy(data_comm)) {
if (strcmp(MSG_task_get_name(data_task), "finalize")) {
- DEBUG0("received message from data");
+ XBT_DEBUG("received message from data");
xbt_mutex_acquire(mutex);
received.push(data_task);
xbt_mutex_release(mutex);
data_task = NULL;
data_comm = MSG_task_irecv(&data_task, get_data_mbox());
} else {
- DEBUG0("received finalize from data");
+ XBT_DEBUG("received finalize from data");
MSG_task_destroy(data_task);
data_task = NULL;
data_comm = NULL;
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(depl);
#include "hostdata.h"
+#include "misc.h"
#include "options.h"
#include "deployment.h"
std::ostringstream oss;
oss << std::setprecision(12) << hosts[i].load;
std::string strload = oss.str();
- DEBUG2("%s/load -> \"%s\"", hostname, strload.c_str());
+ XBT_DEBUG("%s/load -> \"%s\"", hostname, strload.c_str());
xbt_dynar_push_as(args, const char*, strload.c_str());
for (unsigned j = 0 ; j < hosts[i].neighbors.size() ; ++j) {
int neighbor = hosts[i].neighbors[j];
const char* neighbor_name = hostdata::at(neighbor).get_name();
- DEBUG2("%s/neighbor -> \"%s\"", hostname, neighbor_name);
+ XBT_DEBUG("%s/neighbor -> \"%s\"", hostname, neighbor_name);
xbt_dynar_push_as(args, const char*, neighbor_name);
}
MSG_set_function(hostname, "loba", args);
// here width == ceil(sqrt(size))
unsigned first_on_last_line = (size() - 1) - (size() - 1) % width;
- DEBUG4("torus size = %u ; width = %u ; height = %u ; foll = %u",
- (unsigned )size(), width,
- (unsigned )(size() / width + !!(size() % width)),
- first_on_last_line);
+ XBT_DEBUG("torus size = %u ; width = %u ; height = %u ; foll = %u",
+ (unsigned )size(), width,
+ (unsigned )(size() / width + !!(size() % width)),
+ first_on_last_line);
for (unsigned i = 0; i < size(); i++) {
unsigned next_line;
unsigned prev_line;
e_xbt_log_priority_t logp = xbt_log_priority_verbose;
if (!LOG_ISENABLED(logp))
return;
- LOG1(logp, "Got %lu hosts.", (unsigned long)hosts.size());
+ XBT_LOG(logp, "Got %lu hosts.", (unsigned long)hosts.size());
for (int i = 0; i < nhosts; i++) {
- LOG2(logp, "Host #%d named \"%s\".", i, hosts[i].get_name());
+ XBT_LOG(logp, "Host #%d named \"%s\".", i, hosts[i].get_name());
}
}
if (pneigh[i]->get_load() <= get_load() - 2 * delta) {
found = true;
send(pneigh[i], delta);
- DEBUG1("sent to %s", pneigh[i]->get_name());
+ XBT_DEBUG("sent to %s", pneigh[i]->get_name());
}
}
}
if (imin != -1) {
// found someone
double balance = (get_load() - max) / 2;
- DEBUG6("%d:%g %d:%g %g %g", imin, min, imax, max, get_load(), balance);
+ XBT_DEBUG("%d:%g %d:%g %g %g", imin, min, imax, max, get_load(), balance);
send(pneigh[imin], balance);
}
}
double lost = total_init - total_exit;
double lost_ratio = 100.0 * lost / total_init;
if (lost_ratio < -opt::load_ratio_threshold)
- CRITICAL2("Gained load at exit! %g (%g%%) <============",
- -lost, -lost_ratio);
+ XBT_CRITICAL("Gained load at exit! %g (%g%%) <============",
+ -lost, -lost_ratio);
else if (lost_ratio > opt::load_ratio_threshold)
- CRITICAL2("Lost load at exit! %g (%g%%) <============",
- lost, lost_ratio);
+ XBT_CRITICAL("Lost load at exit! %g (%g%%) <============",
+ lost, lost_ratio);
else
- VERB2("Total load at exit looks good: %g (%g%%)", lost, lost_ratio);
+ XBT_VERB("Total load at exit looks good: %g (%g%%)", lost, lost_ratio);
double total_running = process::get_total_load_running();
double running_ratio = 100.0 * total_running / total_init;
if (running_ratio < -opt::load_ratio_threshold)
- CRITICAL2("Negative running load at exit! %g (%g%%) <============",
- total_running, running_ratio);
+ XBT_CRITICAL("Negative running load at exit! %g (%g%%) <============",
+ total_running, running_ratio);
else if (running_ratio > opt::load_ratio_threshold)
- CRITICAL2("Remaining running load at exit! %g (%g%%) <============",
- total_running, running_ratio);
+ XBT_CRITICAL("Remaining running load at exit! %g (%g%%) <============",
+ total_running, running_ratio);
else
- VERB2("Running load at exit looks good: %g (%g%%)",
- total_running, running_ratio);
+ XBT_VERB("Running load at exit looks good: %g (%g%%)",
+ total_running, running_ratio);
}
#define PR_STATS(descr, st) \
- INFO5("| %.*s: %g / %g / %g", 39, \
- descr " total/avg./stddev. at exit.........................", \
- st.get_sum(), st.get_mean(), st.get_stddev())
+ XBT_INFO("| %.*s: %g / %g / %g", 39, \
+ descr " total/avg./stddev. at exit.........................", \
+ st.get_sum(), st.get_mean(), st.get_stddev())
int main(int argc, char* argv[])
{
MSG_clean();
exit(parse_res ? EXIT_NO_FAILURE : EXIT_FAILURE_ARGS);
}
- INFO3("%s v%s (%s)", opt::program_name.c_str(), version::num.c_str(),
+ XBT_INFO("%s v%s (%s)", opt::program_name.c_str(), version::num.c_str(),
version::date.c_str());
opt::print();
if (!opt::auto_depl::nhosts)
opt::auto_depl::nhosts = hostdata::size();
if (opt::auto_depl::nhosts > hostdata::size()) {
- WARN2("%u hosts is too much: limiting to %u",
- opt::auto_depl::nhosts, (unsigned )hostdata::size());
+ XBT_WARN("%u hosts is too much: limiting to %u",
+ opt::auto_depl::nhosts, (unsigned )hostdata::size());
opt::auto_depl::nhosts = hostdata::size();
}
if (!opt::auto_depl::load)
proc_counter = 0;
// Launch the MSG simulation.
- INFO1("Starting simulation at %f...", MSG_get_clock());
+ XBT_INFO("Starting simulation at %f...", MSG_get_clock());
res = MSG_main();
simulated_time = MSG_get_clock();
- INFO1("Simulation ended at %f.", simulated_time);
+ XBT_INFO("Simulation ended at %f.", simulated_time);
xbt_cond_destroy(proc_cond);
xbt_mutex_destroy(proc_mutex);
int len = strlen(ex.msg);
if (len > 0 && ex.msg[len - 1] == '\n')
ex.msg[len - 1] = '\0'; // strip the ending '\n'
- ERROR1("%s", ex.msg);
- DEBUG3("Error from %s() in %s:%d", ex.func, ex.file, ex.line);
+ XBT_ERROR("%s", ex.msg);
+ XBT_DEBUG("Error from %s() in %s:%d", ex.func, ex.file, ex.line);
xbt_ex_free(ex);
}
hostdata::destroy();
res = MSG_clean();
if (res != MSG_OK) {
- ERROR1("MSG_clean() failed with status %#x", res);
+ XBT_ERROR("MSG_clean() failed with status %#x", res);
exit_status |= EXIT_FAILURE_CLEAN;
}
if (simulated_time >= 0.0) {
simulation_time.stop();
check_for_lost_load();
- INFO0(",----[ Results ]");
+ XBT_INFO(",----[ Results ]");
PR_STATS("Load", loads);
PR_STATS("Computation", comps);
- INFO1("| Total simulated time...................: %g", simulated_time);
- INFO1("| Total simulation time..................: %g",
- simulation_time.duration());
- INFO0("`----");
+ XBT_INFO("| Total simulated time...................: %g",
+ simulated_time);
+ XBT_INFO("| Total simulation time..................: %g",
+ simulation_time.duration());
+ XBT_INFO("`----");
}
if (exit_status)
- ERROR1("Simulation failed (%#x).", exit_status);
+ XBT_ERROR("Simulation failed (%#x).", exit_status);
else
- INFO0("Simulation succeeded.");
+ XBT_INFO("Simulation succeeded.");
return exit_status;
}
e_xbt_log_priority_t logp, xbt_log_category_t cat) const
{
if (verbose)
- XCLOG4(cat, logp, "%s: load = %g ; debt = %g ; to_send = %g",
- get_name(), get_load(), get_debt(), get_to_send());
+ XBT_XCLOG(cat, logp, "%s: load = %g ; debt = %g ; to_send = %g",
+ get_name(), get_load(), get_debt(), get_to_send());
else
- XCLOG2(cat, logp, "%s: load = %g", get_name(), get_load());
+ XBT_XCLOG(cat, logp, "%s: load = %g", get_name(), get_load());
}
#include "loba_simple.h"
#include "loba_fairstrategy.h"
#include "loba_makhoul.h"
+#include "misc.h"
#include "options.h"
}
switch (candidates.size()) {
case 0:
- ERROR2("unknownw %s -- %s", descr, name.c_str());
+ XBT_ERROR("unknownw %s -- %s", descr, name.c_str());
break;
case 1:
name = candidates.top();
candidates.pop();
result = true;
- DEBUG2("infered %s -- %s", descr, name.c_str());
+ XBT_DEBUG("infered %s -- %s", descr, name.c_str());
break;
default:
- ERROR2("ambiguous %s -- %s", descr, name.c_str());
+ XBT_ERROR("ambiguous %s -- %s", descr, name.c_str());
while (!candidates.empty()) {
- ERROR1(" candidates are -- %s", candidates.top().c_str());
+ XBT_ERROR(" candidates are -- %s", candidates.top().c_str());
candidates.pop();
}
break;
opt::version_requested = true;
break;
case '?':
- ERROR1("invalid option -- '%c'", optopt);
+ XBT_ERROR("invalid option -- '%c'", optopt);
result = false;
break;
}
if (optind < *argc) {
opt::platform_file = argv[optind++];
} else {
- ERROR0("missing parameter -- <plaform_file>");
+ XBT_ERROR("missing parameter -- <plaform_file>");
result = false;
}
if (optind < *argc) {
opt::auto_depl::enabled = opt::deployment_file.empty();
while (optind < *argc) {
- ERROR1("unused parameter -- \"%s\"", argv[optind++]);
+ XBT_ERROR("unused parameter -- \"%s\"", argv[optind++]);
result = false;
}
opt_helper h;
#define DESCR(description, format, value) \
- INFO2("| %s: " format, h.descr(description), value)
+ XBT_INFO("| %s: " format, h.descr(description), value)
- INFO0(",----[ Simulation parameters ]");
+ XBT_INFO(",----[ Simulation parameters ]");
DESCR("log rate", "%s", h.val_or_string(log_rate, "disabled"));
DESCR("platform file", "\"%s\"", platform_file.c_str());
if (auto_depl::enabled) {
- INFO0("| automatic deployment enabled");
+ XBT_INFO("| automatic deployment enabled");
DESCR("- topology", "%s", auto_depl::topology.c_str());
DESCR("- number of hosts", "%s", h.val_or_string(auto_depl::nhosts,
"auto"));
h.val_or_string(comp_maxiter, "infinity"));
DESCR("time limit", "%s", h.val_or_string(time_limit, "infinity"));
DESCR("exit on close", "%s", h.on_off(exit_on_close));
- INFO0("`----");
+ XBT_INFO("`----");
#undef DESCR
}
std::tr1::mem_fn(&neighbor::get_name));
oss << neigh.back().get_name();
}
- LOG1(logp, "Got %s.", oss.str().c_str());
+ XBT_LOG(logp, "Got %s.", oss.str().c_str());
print_loads(false, logp);
}
{
total_load_exit += real_load;
if (opt::bookkeeping) {
- INFO4("Final load after %d:%d iterations: %g ; expected: %g",
- lb_iter, comp_iter, real_load, expected_load);
+ XBT_INFO("Final load after %d:%d iterations: %g ; expected: %g",
+ lb_iter, comp_iter, real_load, expected_load);
} else {
- INFO2("Final load after %d iterations: %g",
- lb_iter, real_load);
+ XBT_INFO("Final load after %d iterations: %g",
+ lb_iter, real_load);
if (lb_iter != comp_iter)
- WARN2("lb_iter (%d) and comp_iter (%d) differ!",
- lb_iter, comp_iter);
+ XBT_WARN("lb_iter (%d) and comp_iter (%d) differ!",
+ lb_iter, comp_iter);
}
- VERB1("Total computation for this process: %g", comp);
+ XBT_VERB("Total computation for this process: %g", comp);
}
int process::run()
{
double next_iter_after_date = 0.0;
- INFO1("Initial load: %g", real_load);
- VERB0("Starting...");
+ XBT_INFO("Initial load: %g", real_load);
+ XBT_VERB("Starting...");
while (true) {
if (get_load() > 0.0) {
double now = MSG_get_clock();
if (opt::log_rate && lb_iter % opt::log_rate == 0) {
if (opt::bookkeeping)
- INFO4("(%u:%u) current load: %g ; expected: %g",
- lb_iter, comp_iter, real_load, expected_load);
+ XBT_INFO("(%u:%u) current load: %g ; expected: %g",
+ lb_iter, comp_iter, real_load, expected_load);
else
- INFO2("(%u) current load: %g",
- lb_iter, real_load);
+ XBT_INFO("(%u) current load: %g",
+ lb_iter, real_load);
}
load_balance();
}
if (opt::lb_maxiter && lb_iter >= opt::lb_maxiter) {
- VERB2("Reached lb_maxiter: %d/%d", lb_iter, opt::lb_maxiter);
+ XBT_VERB("Reached lb_maxiter: %d/%d", lb_iter, opt::lb_maxiter);
break;
}
if (opt::comp_maxiter && comp_iter >= opt::comp_maxiter) {
- VERB2("Reached comp_maxiter: %d/%d", comp_iter, opt::comp_maxiter);
+ XBT_VERB("Reached comp_maxiter: %d/%d", comp_iter, opt::comp_maxiter);
break;
}
if (opt::time_limit && MSG_get_clock() >= opt::time_limit) {
- VERB2("Reached time limit: %g/%g", MSG_get_clock(), opt::time_limit);
+ XBT_VERB("Reached time limit: %g/%g", MSG_get_clock(), opt::time_limit);
break;
}
// one of our neighbor is finalizing
if (opt::exit_on_close && close_received) {
- VERB0("Close received");
+ XBT_VERB("Close received");
break;
}
// have no load and cannot receive anything
if (real_load == 0.0 && !may_receive()) {
- VERB0("I'm a poor lonesome process, and I have no load...");
+ XBT_VERB("I'm a poor lonesome process, and I have no load...");
break;
}
// 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.");
+ XBT_VERB("No more load to balance in system.");
break;
} else {
- DEBUG1("still %g load to balance, continuing...", total_load_running);
+ XBT_DEBUG("still %g load to balance, continuing...", total_load_running);
}
}
- VERB0("Going to finalize...");
+ XBT_VERB("Going to finalize...");
finalize();
/* Open Questions :
* - how to manage link failures ?
*/
- VERB0("Done.");
+ XBT_VERB("Done.");
return 0;
}
void process::load_balance()
{
if (lb_iter == 1) // warn only once
- WARN0("process::load_balance() is a no-op!");
+ XBT_WARN("process::load_balance() is a no-op!");
}
void process::compute()
double flops = opt::comp_cost(real_load);
m_task_t task = MSG_task_create("computation", flops, 0.0, NULL);
TRACE_msg_set_task_category(task, TRACE_CAT_COMP);
- DEBUG2("compute %g flop%s", flops, ESSE(flops));
+ XBT_DEBUG("compute %g flop%s", flops, ESSE(flops));
MSG_task_execute(task);
comp += flops;
MSG_task_destroy(task);
} else {
- DEBUG0("nothing to compute !");
+ XBT_DEBUG("nothing to compute !");
}
}
message* msg;
m_host_t from;
- DEBUG2("%sblocking receive (%g)", "\0non-" + !timeout, timeout);
+ XBT_DEBUG("%sblocking receive (%g)", "\0non-" + !timeout, timeout);
while (may_receive() && comm.recv(msg, from, timeout)) {
switch (msg->get_type()) {
case message::INFO: {
finalizing = true;
total_load_running -= real_load;
- DEBUG2("send CLOSE to %lu neighbor%s",
- (unsigned long )neigh.size(), ESSE(neigh.size()));
+ XBT_DEBUG("send CLOSE to %lu neighbor%s",
+ (unsigned long )neigh.size(), ESSE(neigh.size()));
std::for_each(neigh.begin(), neigh.end(),
bind(&process::finalize1, this, _1));
while (may_receive()) {
comm.flush(false);
- DEBUG2("waiting for %d CTRL and %d DATA CLOSE",
- ctrl_close_pending, data_close_pending);
+ XBT_DEBUG("waiting for %d CTRL and %d DATA CLOSE",
+ ctrl_close_pending, data_close_pending);
receive(-1.0);
}
if (_XBT_LOG_ISENABLEDV((*cat), logp)) { \
using std::tr1::bind; \
using std::tr1::placeholders::_1; \
- XCLOG0(cat, logp, "Neighbor loads:"); \
+ XBT_XCLOG(cat, logp, "Neighbor loads:"); \
std::for_each(vec.begin(), vec.end(), \
bind(&neighbor::print, _1, verbose, logp, cat)); \
} else ((void)0)
#include <msg/msg.h>
#include <xbt/log.h>
#include "communicator.h"
+#include "misc.h"
#include "neighbor.h"
#include "options.h"
#include <cstdio> // sprintf
#include <time.h> // clock()
#include <msg/msg.h>
+#define XBT_LOG_OLD_STYLE
#include <xbt/log.h>
#include "simgrid_features.h"