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

Private GIT Repository
Define process::lb_load(), and use it.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 18 Jan 2011 10:25:38 +0000 (11:25 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 18 Jan 2011 10:28:59 +0000 (11:28 +0100)
process.cpp
process.h

index ac9ab244dfd65103da9cfd2705f2948ad65372d3..0afbf2950781c4ac33139c2cbfbb3f2bf0a70ebe 100644 (file)
@@ -91,10 +91,9 @@ int process::run()
                           comp_iter, load);
             }
 
-            if (opt::bookkeeping)
-                expected_load -= load_balance(expected_load);
-            else
-                load -= load_balance(load);
+            double ld = lb_load();
+            ld -= load_balance(ld);
+            lb_load() = ld;
 
             print_loads(true, xbt_log_priority_debug);
 
@@ -121,9 +120,7 @@ int process::run()
 
         // block on receiving unless there is something to compute or
         // to send
-        bool wait = (load == 0 &&
-                     ((opt::bookkeeping ? expected_load : load)
-                      == prev_load_broadcast));
+        bool wait = (load == 0 && lb_load() == prev_load_broadcast);
         receive(wait);
 
         // one of our neighbor is finalizing
index b15f98297cc540481516b4fa0bd3052e5a4d57f2..1b4f9caa8ad72e1e0ed209598981dee60ae93deb 100644 (file)
--- a/process.h
+++ b/process.h
@@ -16,6 +16,7 @@
 #include <xbt/log.h>
 #include "communicator.h"
 #include "neighbor.h"
+#include "options.h"
 
 class process {
 public:
@@ -76,6 +77,8 @@ private:
     double load;                // current load
     double expected_load;       // expected load in bookkeeping mode
 
+    double& lb_load() { return opt::bookkeeping ? expected_load : load; }
+
     // The load balancing algorithm comes here...
     // Parameter "my_load" is the load to take into account for myself
     // (may be load or expected load).