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
16 #include "communicator.h"
21 static double get_total_load_init() { return total_load_init; }
22 static double get_total_load_exit() { return total_load_exit; }
24 process(int argc, char* argv[]);
30 typedef std::vector<neighbor> neigh_type;
31 typedef std::vector<neighbor*> pneigh_type;
33 pneigh_type pneigh; // list of pointers to neighbors that
34 // we are free to reorder
36 // Returns the sum of "to_send" for all neighbors.
37 double sum_of_to_send() const;
40 static double total_load_init;
41 static double total_load_exit;
43 typedef MAP_TEMPLATE<m_host_t, neighbor*> rev_neigh_type;
44 neigh_type neigh; // list of neighbors (do not alter
45 // after construction!)
46 rev_neigh_type rev_neigh; // map m_host_t -> neighbor
48 communicator comm; // communicator for this process
49 int ctrl_close_pending; // number of "close" messages to wait
51 int data_close_pending; // number of "close" messages to wait
54 unsigned iter; // counter of iterations
56 double prev_load_broadcast; // used to ensure that we do not send
57 // a same information messages
58 double load; // current load
59 double expected_load; // expected load in bookkeeping mode
61 // The load balancing algorithm comes here...
62 // Parameter "my_load" is the load to take into account for myself
63 // (may be load or expected load).
64 // Returns the total load sent to neighbors.
65 virtual double load_balance(double my_load);
67 // Virtually do some computation
70 // Send procedures, with helpers for bookkeeping mode or not
71 void send1_no_bookkeeping(neighbor& nb);
72 void send1_bookkeeping(neighbor& nb);
75 // Receive procedure: wait (or not) for a message to come.
76 // Returns false if some "close" message was received, returns true
78 enum recv_wait_mode { NO_WAIT = 0, WAIT, WAIT_FOR_CLOSE };
79 bool receive(recv_wait_mode wait);
81 // Finalize sends a "close" message to each neighbor and wait for
82 // all of them to answer.
83 void finalize1(neighbor& nb);
86 // Print with given priority what we know about our neighbors' loads
87 void print_loads(e_xbt_log_priority_t logp = xbt_log_priority_info);