From: Arnaud Giersch Date: Tue, 7 Dec 2010 17:55:40 +0000 (+0100) Subject: Wip++... X-Git-Tag: v0.1~253 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/147d0e88c4da14c801d15e0875bedb474180bea2?ds=sidebyside Wip++... * add process::receive * whitespace cleanups --- diff --git a/communicator.cpp b/communicator.cpp index b78b1c3..0d724aa 100644 --- a/communicator.cpp +++ b/communicator.cpp @@ -50,7 +50,7 @@ void communicator::send(m_task_t task, const std::string& dest) } m_task_t communicator::recv() -{ +{ m_task_t task = NULL; if (comm_test_n_destroy(recv_comm)) { task = recv_task; diff --git a/main.cpp b/main.cpp index dbc5b43..314cac2 100644 --- a/main.cpp +++ b/main.cpp @@ -37,8 +37,9 @@ int main(int argc, char *argv[]) simulation_time.start(); - // Set default logging threshold. + // Set default logging parameters // xbt_log_control_set("simu.thres:verbose"); + xbt_log_control_set("simu.fmt:'[%h %r] [%c/%p] %m%n'"); // Initialize some MSG internal data. // Note: MSG_global_init() may throw an exception, but it seems @@ -60,7 +61,7 @@ int main(int argc, char *argv[]) } opt::print(); - TRY { + TRY { exit_status = EXIT_FAILURE_INIT; // ===== // Register the main function of an agent in a global table. diff --git a/options.cpp b/options.cpp index aa3bede..24ae952 100644 --- a/options.cpp +++ b/options.cpp @@ -17,8 +17,8 @@ namespace opt { int help_requested = 0; bool version_requested = false; - cost_func comp_cost("1, 0"); - cost_func comm_cost("1, 0"); + cost_func comp_cost("1e9, 0"); // fixme: find better defaults + cost_func comm_cost("1e9, 0"); // fixme: find better defaults } // namespace opt @@ -68,7 +68,7 @@ int opt::parse_args(int* argc, char* argv[]) return 1; } - + void opt::print() { INFO0(",----[ Simulation parameters ]"); diff --git a/process.cpp b/process.cpp index 7605818..d1576ce 100644 --- a/process.cpp +++ b/process.cpp @@ -40,7 +40,13 @@ process::process(int argc, char *argv[]) int process::run() { INFO0("Coucou !"); - MSG_process_sleep(100.0); // xxx + + int n = 100; + while (n--) { + compute(); + receive(); + } + // MSG_process_sleep(100.0); // xxx /* xxx: * while (there is something to do) { * compute some task; @@ -61,10 +67,25 @@ int process::run() return 0; } +void process::receive() +{ + m_task_t task; + while ((task = comm.recv())) { + message *msg = (message *)MSG_task_get_data(task); + DEBUG3("Received load: %g, info: %g from %s", + msg->transfer, msg->measure, + MSG_host_get_name(MSG_task_get_source(task))); + load += msg->transfer; + // fixme: what is xxx ??? + // neigh[xxx].setLoad(msg->measure); + } +} + void process::compute() { double duration = opt::comp_cost(load); m_task_t task = MSG_task_create("computation", duration, 0.0, NULL); + DEBUG2("Compute %g flop%s.", duration, duration > 1 ? "s" : ""); MSG_task_execute(task); MSG_task_destroy(task); } diff --git a/process.h b/process.h index 8711fca..aa1e032 100644 --- a/process.h +++ b/process.h @@ -17,6 +17,7 @@ private: std::vector neigh; double load; + void receive(); void compute(); void print_loads(e_xbt_log_priority_t logp = xbt_log_priority_info); }; diff --git a/simple_async.cpp b/simple_async.cpp index b2d8bc0..2ad0cbc 100644 --- a/simple_async.cpp +++ b/simple_async.cpp @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) MSG_global_init(&argc, argv); exit_status = EXIT_FAILURE_ARGS; // ===== - TRY { + TRY { // Parse global parameters if (argc != 3) { diff --git a/timer.h b/timer.h index 6ae15eb..0e8c7d9 100644 --- a/timer.h +++ b/timer.h @@ -66,12 +66,12 @@ public: void start() { - getrusage(RUSAGE_SELF, &before); + getrusage(RUSAGE_SELF, &before); } void stop() { - getrusage(RUSAGE_SELF, &after); + getrusage(RUSAGE_SELF, &after); difference = difference + ((after.ru_utime + after.ru_stime) - (before.ru_utime + before.ru_stime)); }