4 #define USE_UNORDERED_MAP 1
5 //#undef USE_UNORDERED_MAP
8 #ifdef USE_UNORDERED_MAP
9 # include <tr1/unordered_map>
10 # define MAP_TEMPLATE std::tr1::unordered_map
13 # define MAP_TEMPLATE std::map
17 #include "communicator.h"
22 static double get_total_load_init() { return total_load_init; }
23 static double get_total_load_running() { return total_load_running; }
24 static double get_total_load_exit() { return total_load_exit; }
26 process(int argc, char* argv[]);
29 double get_load() const { return load; }
34 typedef std::vector<neighbor> neigh_type;
35 typedef std::vector<neighbor*> pneigh_type;
37 pneigh_type pneigh; // list of pointers to neighbors that
38 // we are free to reorder
40 // Returns the sum of "to_send" for all neighbors.
41 double sum_of_to_send() const;
43 // Calls neighbor::print(verbose, logp, cat) for each member of neigh.
44 void print_loads(bool verbose = false,
45 e_xbt_log_priority_t logp = xbt_log_priority_info,
46 xbt_log_category_t cat = _XBT_LOGV(default)) const;
48 // Calls neighbor::print(verbose, logp, cat) for each member of pneigh.
49 void print_loads_p(bool verbose = false,
50 e_xbt_log_priority_t logp = xbt_log_priority_info,
51 xbt_log_category_t cat = _XBT_LOGV(default)) const;
54 static double total_load_init; // sum of process loads at init
55 static double total_load_running; // summ of loads while running
56 static double total_load_exit; // sum of process loads at exit
58 typedef MAP_TEMPLATE<m_host_t, neighbor*> rev_neigh_type;
59 neigh_type neigh; // list of neighbors (do not alter
60 // after construction!)
61 rev_neigh_type rev_neigh; // map m_host_t -> neighbor
63 communicator comm; // communicator for this process
64 int ctrl_close_pending; // number of "close" messages to wait
66 int data_close_pending; // number of "close" messages to wait
68 bool close_received; // true if we received a "close" message
69 bool may_receive; // true if there remains neighbors to listen for
70 bool finalizing; // true when finalize() is running
72 unsigned lb_iter; // counter of load-balancing iterations
73 unsigned comp_iter; // counter of computation iterations
75 double prev_load_broadcast; // used to ensure that we do not send
76 // a same information messages
77 double load; // current load
78 double expected_load; // expected load in bookkeeping mode
80 // The load balancing algorithm comes here...
81 // Parameter "my_load" is the load to take into account for myself
82 // (may be load or expected load).
83 // Returns the total load sent to neighbors.
84 virtual double load_balance(double my_load);
86 // Virtually do some computation
89 // Send procedures, with helpers for bookkeeping mode or not
90 void send1_no_bookkeeping(neighbor& nb);
91 void send1_bookkeeping(neighbor& nb);
94 // Receive procedure: wait (or not) for a message to come.
95 enum recv_wait_mode { NO_WAIT = 0, WAIT, WAIT_FOR_CLOSE };
96 void receive(recv_wait_mode wait);
98 // Finalize sends a "close" message to each neighbor and wait for
99 // all of them to answer.
100 void finalize1(neighbor& nb);