]> AND Private Git Repository - loba.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Add statistics about message exchanges.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 22 Feb 2011 22:35:59 +0000 (23:35 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 22 Feb 2011 22:35:59 +0000 (23:35 +0100)
TODO
main.cpp
process.cpp
process.h

diff --git a/TODO b/TODO
index 6ed42b28eceacf20a7c627ebe4189798e1ef1cfa..b7ef5c5fd0d6c73bc6378b78d74ba3fa9ef84591 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,3 @@
-* add several metrics
-  - message exchanges : number/volume of sent/received data/ctrl messages
-
 * for automatic process topology,
    -> implement some random initial distribution of load
 
index fc0843ab28f2b3e2ee1c2725862bd932a25d0187..7af6b74759ba189fb93e9630291b0b5074eb177f 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -41,8 +41,16 @@ namespace {
     condition_t* proc_cond;
     unsigned proc_counter = 0;
 
-    statistics comps;
     statistics loads;
+    statistics comps;
+    statistics data_send_amount;
+    statistics data_recv_amount;
+    statistics data_send_count;
+    statistics data_recv_count;
+    statistics ctrl_send_amount;
+    statistics ctrl_recv_amount;
+    statistics ctrl_send_count;
+    statistics ctrl_recv_count;
 
 }
 
@@ -60,8 +68,16 @@ static int simulation_main(int argc, char* argv[])
         result = proc->run();
 
         proc_mutex->acquire();
-        comps.push(proc->get_comp());
         loads.push(proc->get_real_load());
+        comps.push(proc->get_comp_amount());
+        data_send_amount.push(proc->get_data_send_amount());
+        data_recv_amount.push(proc->get_data_recv_amount());
+        data_send_count.push(proc->get_data_send_count());
+        data_recv_count.push(proc->get_data_recv_count());
+        ctrl_send_amount.push(proc->get_ctrl_send_amount());
+        ctrl_recv_amount.push(proc->get_ctrl_recv_amount());
+        ctrl_send_count.push(proc->get_ctrl_send_count());
+        ctrl_recv_count.push(proc->get_ctrl_recv_count());
 
         // Synchronization barrier...
         // The goal is to circumvent a limitation in SimGrid (at least
@@ -239,6 +255,14 @@ int main(int argc, char* argv[])
         XBT_INFO(",----[ Results ]");
         PR_STATS("Load", loads);
         PR_STATS("Computation", comps);
+        PR_STATS("Data send", data_send_amount);
+        PR_STATS("Data recv", data_recv_amount);
+        PR_STATS("Data send #", data_send_count);
+        PR_STATS("Data recv #", data_recv_count);
+        PR_STATS("Ctrl send", ctrl_send_amount);
+        PR_STATS("Ctrl recv", ctrl_recv_amount);
+        PR_STATS("Ctrl send #", ctrl_send_count);
+        PR_STATS("Ctrl recv #", ctrl_recv_count);
         XBT_INFO("| Total simulated time...................: %g",
                  simulated_time);
         XBT_INFO("| Total simulation time..................: %g",
index 33a993ef5eb8e96041302b563acef1fafeb557b7..d0bfc21120b8cbc8ea0230b4eb9bb97e4eeb26f3 100644 (file)
@@ -46,8 +46,6 @@ process::process(int argc, char* argv[])
         rev_neigh.insert(std::make_pair(host, ptr));
     }
 
-    comp = 0.0;
-
     prev_load_broadcast = -1;   // force sending of load on first send_all()
     expected_load = real_load;
     total_load_running += real_load;
@@ -88,7 +86,7 @@ process::~process()
     XBT_INFO("Final load after %d:%d iterations: %g",
              lb_iter, comp_iter, real_load);
     XBT_VERB("Expected load was: %g", expected_load);
-    XBT_VERB("Total computation for this process: %g", comp);
+    XBT_VERB("Total computation for this process: %g", get_comp_amount());
 }
 
 int process::run()
@@ -195,7 +193,7 @@ void process::compute_loop()
         TRACE_msg_set_task_category(task, TRACE_CAT_COMP);
         XBT_DEBUG("compute %g flop%s", flops, ESSE(flops));
         MSG_task_execute(task);
-        comp += flops;
+        add_comp_amount(flops);
         MSG_task_destroy(task);
 
         sleep_until_date(next_iter_after_date, opt::min_comp_iter_duration);
@@ -284,16 +282,19 @@ void process::send(neighbor& nb, double amount)
 void process::ctrl_send(neighbor& nb)
 {
     double info_to_send = expected_load;
-    if (info_to_send != prev_load_broadcast)
-        comm.ctrl_send(nb.get_ctrl_mbox(),
-                       new message(message::INFO, info_to_send));
+    if (info_to_send != prev_load_broadcast) {
+        message* msg = new message(message::INFO, info_to_send);
+        add_ctrl_send_mesg(msg->get_size());
+        comm.ctrl_send(nb.get_ctrl_mbox(), msg);
+    }
     if (opt::bookkeeping) {
         double debt_to_send = nb.get_to_send();
         if (debt_to_send > 0.0) {
             nb.set_to_send(0.0);
             nb.set_debt(nb.get_debt() + debt_to_send);
-            comm.ctrl_send(nb.get_ctrl_mbox(),
-                           new message(message::CREDIT, debt_to_send));
+            message* msg = new message(message::CREDIT, debt_to_send);
+            add_ctrl_send_mesg(msg->get_size());
+            comm.ctrl_send(nb.get_ctrl_mbox(), msg);
         }
     }
 }
@@ -324,7 +325,9 @@ void process::data_send(neighbor& nb)
             amount = std::min(load_to_send, opt::max_transfer_amount);
         else
             amount = load_to_send;
-        comm.data_send(nb.get_data_mbox(), new message(message::LOAD, amount));
+        message* msg = new message(message::LOAD, amount);
+        add_data_send_mesg(msg->get_size());
+        comm.data_send(nb.get_data_mbox(), msg);
         load_to_send -= amount;
     }
 }
@@ -346,6 +349,8 @@ void process::ctrl_receive(double timeout)
 
     XBT_DEBUG("%sblocking receive on ctrl (%g)", "\0non-" + !timeout, timeout);
     while (ctrl_close_pending && comm.ctrl_recv(msg, from, timeout)) {
+        if (msg->get_type() != message::CTRL_CLOSE)
+            add_ctrl_recv_mesg(msg->get_size());
         handle_message(msg, from);
         timeout = 0.0;
     }
@@ -358,6 +363,8 @@ void process::data_receive(double timeout)
 
     XBT_DEBUG("%sblocking receive on data (%g)", "\0non-" + !timeout, timeout);
     while (data_close_pending && comm.data_recv(msg, from, timeout)) {
+        if (msg->get_type() != message::DATA_CLOSE)
+            add_data_recv_mesg(msg->get_size());
         handle_message(msg, from);
         timeout = 0.0;
     }
index cc10b0494ba0710994be865891af6b153acba24b..ed6e6cf6fbedffc1ab96657aadda320828ca0a2a 100644 (file)
--- a/process.h
+++ b/process.h
@@ -32,8 +32,16 @@ public:
     process(int argc, char* argv[]);
     virtual ~process();
 
-    double get_comp() const                { return comp; }
-    double get_real_load() const           { return real_load; }
+    double get_real_load() const           { return real_load;            }
+    double get_comp_amount() const         { return acc.comp_amount;      }
+    double get_data_send_amount() const    { return acc.data_send.amount; }
+    double get_data_recv_amount() const    { return acc.data_recv.amount; }
+    unsigned get_data_send_count() const   { return acc.data_send.count;  }
+    unsigned get_data_recv_count() const   { return acc.data_recv.count;  }
+    double get_ctrl_send_amount() const    { return acc.ctrl_send.amount; }
+    double get_ctrl_recv_amount() const    { return acc.ctrl_recv.amount; }
+    unsigned get_ctrl_send_count() const   { return acc.ctrl_send.count;  }
+    unsigned get_ctrl_recv_count() const   { return acc.ctrl_recv.count;  }
 
     int run();
 
@@ -90,8 +98,6 @@ private:
     unsigned lb_iter;           // counter of load-balancing iterations
     unsigned comp_iter;         // counter of computation iterations
 
-    double comp;                // total computing done so far (flops)
-
     double prev_load_broadcast; // used to ensure that we do not send
                                 // a same information messages
     double real_load;           // current load
@@ -100,6 +106,39 @@ private:
     mutex_t mutex;              // synchronization between threads
     condition_t cond;
 
+    struct mesg_accounting {
+        double amount;          // sum of message size
+        unsigned count;         // number of messages
+        mesg_accounting(): amount(0.0), count(0) { }
+    };
+    struct accounting {
+        double comp_amount;        // total computing done so far (flops)
+        mesg_accounting data_send; // data messages sent
+        mesg_accounting data_recv; // data messages received
+        mesg_accounting ctrl_send; // ctrl message sent
+        mesg_accounting ctrl_recv; // ctrl message received
+        accounting(): comp_amount(0.0) { }
+    };
+    accounting acc;
+
+    void add_comp_amount(double amount) { acc.comp_amount += amount; }
+    void add_data_send_mesg(double amount) {
+        ++acc.data_send.count;
+        acc.data_send.amount += amount;
+    }
+    void add_data_recv_mesg(double amount) {
+        ++acc.data_recv.count;
+        acc.data_recv.amount += amount;
+    }
+    void add_ctrl_send_mesg(double amount) {
+        ++acc.ctrl_send.count;
+        acc.ctrl_send.amount += amount;
+    }
+    void add_ctrl_recv_mesg(double amount) {
+        ++acc.ctrl_recv.count;
+        acc.ctrl_recv.amount += amount;
+    }
+
     // Load-balancing loop
     msg_thread* lb_thread;
     void load_balance_loop();