X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1b2975e32481a9b38fe38af90db86ac5c54d8e59..e3a1cf8d29cef5eaf730b485da389cff9319fa56:/src/surf/HostImpl.cpp diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 42e84f1f87..088e84864c 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF h simgrid::surf::HostModel *surf_host_model = nullptr; /************* - * Callbacks * + * Callbacks *t *************/ namespace simgrid { @@ -22,9 +22,8 @@ namespace surf { /********* * Model * *********/ - /* Helper function for executeParallelTask */ -static inline double has_cost(double* array, size_t pos) +static inline double has_cost(const double* array, size_t pos) { if (array) return array[pos]; @@ -32,19 +31,20 @@ static inline double has_cost(double* array, size_t pos) return -1.0; } -kernel::resource::Action* HostModel::execute_parallel(size_t host_nb, s4u::Host** host_list, double* flops_amount, - double* bytes_amount, double rate) +kernel::resource::Action* HostModel::execute_parallel(const std::vector& host_list, + const double* flops_amount, const double* bytes_amount, + double rate) { kernel::resource::Action* action = nullptr; - if ((host_nb == 1) && (has_cost(bytes_amount, 0) <= 0) && (has_cost(flops_amount, 0) > 0)) { + if ((host_list.size() == 1) && (has_cost(bytes_amount, 0) <= 0) && (has_cost(flops_amount, 0) > 0)) { action = host_list[0]->pimpl_cpu->execution_start(flops_amount[0]); - } else if ((host_nb == 1) && (has_cost(flops_amount, 0) <= 0)) { + } else if ((host_list.size() == 1) && (has_cost(flops_amount, 0) <= 0)) { action = surf_network_model->communicate(host_list[0], host_list[0], bytes_amount[0], rate); - } else if ((host_nb == 2) && (has_cost(flops_amount, 0) <= 0) && (has_cost(flops_amount, 1) <= 0)) { + } else if ((host_list.size() == 2) && (has_cost(flops_amount, 0) <= 0) && (has_cost(flops_amount, 1) <= 0)) { int nb = 0; double value = 0.0; - for (size_t i = 0; i < host_nb * host_nb; i++) { + for (size_t i = 0; i < host_list.size() * host_list.size(); i++) { if (has_cost(bytes_amount, i) > 0.0) { nb++; value = has_cost(bytes_amount, i); @@ -108,7 +108,7 @@ void HostImpl::turn_on() if (arg->kill_time >= 0) actor->set_kill_time(arg->kill_time); if (arg->auto_restart) - actor->auto_restart_ = arg->auto_restart; + actor->set_auto_restart(arg->auto_restart); if (arg->daemon_) actor->daemonize(); } @@ -120,8 +120,8 @@ void HostImpl::turn_off() if (not process_list_.empty()) { for (auto& actor : process_list_) { XBT_DEBUG("Killing Actor %s@%s on behalf of %s which turned off that host.", actor.get_cname(), - actor.host_->get_cname(), SIMIX_process_self()->get_cname()); - SIMIX_process_kill(&actor, SIMIX_process_self()); + actor.get_host()->get_cname(), SIMIX_process_self()->get_cname()); + SIMIX_process_self()->kill(&actor); } } // When a host is turned off, we want to keep only the actors that should restart for when it will boot again.