========================================================================
-En mode entier (-Z), aucune vérification n'est faite sur la charge
-totale, ni sur la répartition initiale!
-
-Il faut vérifier, et arrondir et émettre un warning dans le cas contraire :
-- que la charge totale est entière, dans main.cpp ;
-- au début de chaque process que la charge initiale est entière.
-
-Il faut également s'assurer que la répartition aléatoire produit une
-distribution entière.
-
========================================================================
##### RESOLVED BUGS COME AFTER THIS ####################################
========================================================================
std::accumulate(loads.begin(), loads.end(), 0.0);
std::transform(loads.begin(), loads.end(), loads.begin(),
std::bind(std::multiplies<double>(), _1, factor));
- for (unsigned i = 0 ; i < hosts.size() ; ++i)
- set_load(i, loads[i]);
+ if (opt::integer_transfer) {
+ // round the loads
+ std::vector<double> iloads(hosts.size());
+ std::transform(loads.begin(), loads.end(), iloads.begin(), round);
+ // compute the differences between each load and its rounded value
+ std::vector<double> diffs(hosts.size());
+ std::transform(loads.begin(), loads.end(), iloads.begin(),
+ diffs.begin(), std::minus<double>());
+ // compute the absolute values of the diffs
+ std::vector<double> adiffs(hosts.size());
+ std::transform(diffs.begin(), diffs.end(), adiffs.begin(), fabs);
+ // find i, index of the element farthest from its rounded value
+ unsigned i;
+ i = std::max_element(adiffs.begin(), adiffs.end()) - adiffs.begin();
+ // remove element i from diffs, and compute the residual part...
+ diffs[i] = diffs.back();
+ diffs.pop_back();
+ double residue = std::accumulate(diffs.begin(), diffs.end(), 0.0);
+ // ... and compute element i (rounded to avoid numerical errors)
+ iloads[i] = fabs(round(loads[i] + residue));
+ // final sanity check
+ xbt_assert(opt::auto_depl::load ==
+ std::accumulate(iloads.begin(), iloads.end(), 0.0));
+ for (unsigned i = 0 ; i < hosts.size() ; ++i)
+ set_load(i, iloads[i]);
+ } else {
+ for (unsigned i = 0 ; i < hosts.size() ; ++i)
+ set_load(i, loads[i]);
+ }
}
void deployment_generator::deploy()
} else if (opt::auto_depl::load < 0.0)
opt::auto_depl::load =
-opt::auto_depl::load * opt::auto_depl::nhosts;
+ double iload = trunc(opt::auto_depl::load);
+ if (opt::integer_transfer && opt::auto_depl::load != iload) {
+ XBT_WARN("Total load %g is not an integer. Truncate it.",
+ opt::auto_depl::load);
+ opt::auto_depl::load = iload;
+ }
MY_launch_application(); // it is already opt::* aware...
} else {
MSG_launch_application(opt::deployment_file.c_str());
if (argc < 2 || !(std::istringstream(argv[1]) >> real_load))
throw std::invalid_argument("bad or missing initial load parameter");
+ double iload = trunc(real_load);
+ if (opt::integer_transfer && real_load != iload) {
+ XBT_WARN("Initial load %g is not an integer. Truncate it.",
+ real_load);
+ real_load = iload;
+ }
+
neigh.assign(argv + 2, argv + argc);
pneigh.reserve(neigh.size());