4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
8 void loba_bulk::load_balance()
10 float myLoad = get_load();
12 unsigned NbNwMinLoad = 0;
13 unsigned NbNwLowerLoad = 0;
14 unsigned NbNeighbours = pneigh.size();
16 double *S = new double[NbNeighbours];
17 for (unsigned i = 0; i < NbNeighbours; i++)
20 // What is the minimum and maximum load under myLoad?
21 float minLoad = myLoad;
22 for (unsigned i = 0; i < NbNeighbours; i++) {
23 if (pneigh[i]->get_load() < minLoad) {
24 minLoad = pneigh[i]->get_load();
26 if (pneigh[i]->get_load() < myLoad) {
30 for (unsigned i = 0; i < NbNeighbours; i++)
31 if (pneigh[i]->get_load() == minLoad)
34 float maxLoad = minLoad;
35 for (unsigned i = 0; i < NbNeighbours; i++) {
36 if (pneigh[i]->get_load() > minLoad && pneigh[i]->get_load() < myLoad)
37 if (maxLoad < pneigh[i]->get_load())
38 maxLoad = pneigh[i]->get_load();
43 if (NbNwLowerLoad && NbNwMinLoad < NbNwLowerLoad) {
44 // There is one or many neighbors with minimum load but not
45 // all neighbors have minimum load
46 alpha = (1. / ((double) NbNwMinLoad + 2));
48 if (NbNwMinLoad == NbNwLowerLoad) {
49 // All neighbors have minimum load
50 alpha = (1. / ((double) NbNwMinLoad + 1));
53 // There exist underloaded neighbors
54 if (NbNwMinLoad && myLoad != 0.0) {
55 for (unsigned i = 0; i < NbNeighbours; i++) {
56 if (pneigh[i]->get_load() == minLoad) {
57 S[i] = std::floor(alpha * (myLoad - minLoad));
60 if (pneigh[i]->get_load() < myLoad) {
61 S[i] = std::floor(alpha * (myLoad - pneigh[i]->get_load()));
66 // Check assumption 4.2 (b) page 520
67 bool HaveToCorrectS = false;
68 for (unsigned i = 0; i < NbNeighbours; i++) {
69 if (pneigh[i]->get_load() < myLoad) {
71 if ((myLoad - myS) < (pneigh[i]->get_load() + S[i])) {
72 HaveToCorrectS = true;
77 for (unsigned i = 0; i < NbNeighbours; i++) {
78 while (((myLoad - myS) < pneigh[i]->get_load() + S[i])
85 } // End there are underloaded neighbors;
86 for (unsigned i = 0; i < NbNeighbours; i++) {
87 send(pneigh[i], S[i]);
88 XBT_DEBUG("sent to %s", pneigh[i]->get_name());