Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use references for parameters of type std::vector.
[simgrid.git] / src / surf / HostImpl.cpp
index 012ad13..088e848 100644 (file)
@@ -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<s4u::Host*>& 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);
@@ -103,12 +103,12 @@ void HostImpl::turn_on()
 {
   for (auto const& arg : actors_at_boot_) {
     XBT_DEBUG("Booting Actor %s(%s) right now", arg->name.c_str(), arg->host->get_cname());
-    smx_actor_t actor =
-        SIMIX_process_create(arg->name.c_str(), arg->code, nullptr, arg->host, arg->properties.get(), nullptr);
+    simgrid::kernel::actor::ActorImplPtr actor = simgrid::kernel::actor::ActorImpl::create(
+        arg->name.c_str(), arg->code, nullptr, arg->host, arg->properties.get(), nullptr);
     if (arg->kill_time >= 0)
-      simcall_process_set_kill_time(actor, arg->kill_time);
+      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.