Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
another attempt to avoid deadlocks in wrench when using sio host model
[simgrid.git] / src / surf / sio_S22.cpp
index b8439bc..aae6f30 100644 (file)
@@ -152,8 +152,8 @@ void HostS22Model::update_actions_state(double /*now*/, double delta)
   }
 }
 
-S22Action::S22Action(Model* model, s4u::Host* src_host, s4u::Disk* src_disk, s4u::Host* dst_host, s4u::Disk* dst_disk, double size)
-    : DiskAction(model, 1.0, false)
+S22Action::S22Action(Model* model, s4u::Host* src_host, DiskImpl* src_disk, s4u::Host* dst_host, DiskImpl* dst_disk, double size)
+    : DiskAction(model, 1, false)
     , src_host_(src_host)
     , src_disk_(src_disk)
     , dst_host_(dst_host)
@@ -170,20 +170,14 @@ S22Action::S22Action(Model* model, s4u::Host* src_host, s4u::Disk* src_disk, s4u
   if (dst_disk_ != nullptr)
     disk_nb++;
 
-  if (src_host_ != dst_host_ && size_ > 0) {
-    std::unordered_set<const char*> affected_links;
-    double lat = 0.0;
-    std::vector<StandardLinkImpl*> route;
-    src_host_->route_to(dst_host_, route, &lat);
-    latency = std::max(latency, lat);
-
-    for (auto const& link : route)
-      affected_links.insert(link->get_cname());
-
-    link_nb = affected_links.size();
-  }
+  /* there should always be a route between src_host and dst_host (loopback_ for self communication at least) */
+  double lat = 0.0;
+  std::vector<StandardLinkImpl*> route;
+  src_host_->route_to(dst_host_, route, &lat);
+  latency = std::max(latency, lat);
+  link_nb = route.size();
 
-  XBT_DEBUG("Creating a stream io (%p) with %zu hosts and %zu unique links.", this, disk_nb, link_nb);
+  XBT_DEBUG("Creating a stream io (%p) with %zu disk(s) and %zu unique link(s).", this, disk_nb, link_nb);
   latency_ = latency;
 
   set_variable(model->get_maxmin_system()->variable_new(this, 1.0, -1.0, disk_nb + link_nb));
@@ -194,11 +188,11 @@ S22Action::S22Action(Model* model, s4u::Host* src_host, s4u::Disk* src_disk, s4u
   /* Expand it for the disks even if there is nothing to read/write, to make sure that it gets expended even if there is no
    * communication either */
   if (src_disk_ != nullptr)
-    model->get_maxmin_system()->expand(src_disk_->get_impl()->get_constraint(), get_variable(), size, true);
+    model->get_maxmin_system()->expand(src_disk_->get_constraint(), get_variable(), size, true);
   if (dst_disk_ != nullptr)
-    model->get_maxmin_system()->expand(dst_disk_->get_impl()->get_constraint(), get_variable(), size, true);
+    model->get_maxmin_system()->expand(dst_disk_->get_constraint(), get_variable(), size, true);
 
-  if (src_host_ != dst_host_) {
+  if (link_nb > 0) {
     std::vector<StandardLinkImpl*> route;
     src_host_->route_to(dst_host_, route, nullptr);
     for (auto const& link : route)
@@ -214,7 +208,7 @@ S22Action::S22Action(Model* model, s4u::Host* src_host, s4u::Disk* src_disk, s4u
   update_bound();
 }
 
-S22Action* HostS22Model::io_stream(s4u::Host* src_host, s4u::Disk* src_disk, s4u::Host* dst_host, s4u::Disk* dst_disk,
+DiskAction* HostS22Model::io_stream(s4u::Host* src_host, DiskImpl* src_disk, s4u::Host* dst_host, DiskImpl* dst_disk,
                                    double size)
 {
   return new S22Action(this, src_host, src_disk, dst_host, dst_disk, size);
@@ -248,7 +242,19 @@ StandardLinkImpl* NetworkS22Model::create_wifi_link(const std::string& name, con
  ************/
 DiskAction* DiskS22::io_start(sg_size_t size, s4u::Io::OpType type)
 {
-  return static_cast<S22Action*>(io_start(size, type));
+  DiskAction* res;
+  switch (type) {
+    case s4u::Io::OpType::READ:
+      res = static_cast<DiskS22Model*>(get_model())->hostModel_->io_stream(get_host(), this, get_host(), nullptr, size);
+    break;
+    case s4u::Io::OpType::WRITE:
+      res = static_cast<DiskS22Model*>(get_model())->hostModel_->io_stream(get_host(), nullptr, get_host(), this, size);
+    break;
+    default:
+      THROW_UNIMPLEMENTED;
+  }
+
+   return res;
 }
 
 void DiskS22::apply_event(kernel::profile::Event* triggered, double value)
@@ -322,6 +328,7 @@ void LinkS22::set_latency(double value)
 /**********
  * Action *
  **********/
+
 double S22Action::calculate_io_read_bound() const
 {
   double io_read_bound = std::numeric_limits<double>::max();
@@ -375,12 +382,8 @@ void S22Action::update_bound() const
   XBT_DEBUG("action (%p) : bound = %g", this, bound);
 
   /* latency has been paid (or no latency), we can set the appropriate bound for network limit */
-  if ((bound < std::numeric_limits<double>::max()) && (latency_ <= 0.0)) {
-    if (rate_ < 0)
-      get_model()->get_maxmin_system()->update_variable_bound(get_variable(), bound);
-    else
-      get_model()->get_maxmin_system()->update_variable_bound(get_variable(), std::min(rate_, bound));
-  }
-}
+  if ((bound < std::numeric_limits<double>::max()) && (latency_ <= 0.0))
+    get_model()->get_maxmin_system()->update_variable_bound(get_variable(), bound);
+ }
 
 } // namespace simgrid::kernel::resource