Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Useless test; TODO--.
[simgrid.git] / src / s4u / s4u_Host.cpp
index c11256d..02684f9 100644 (file)
@@ -134,7 +134,7 @@ std::vector<ActorPtr> Host::get_all_actors() const
 }
 
 /** @brief Returns how many actors (daemonized or not) have been launched on this host */
-int Host::get_actor_count() const
+size_t Host::get_actor_count() const
 {
   return pimpl_->get_actor_count();
 }
@@ -172,7 +172,7 @@ void Host::route_to(const Host* dest, std::vector<kernel::resource::LinkImpl*>&
 }
 
 /** @brief Returns the networking zone englobing that host */
-NetZone* Host::get_englobing_zone()
+NetZone* Host::get_englobing_zone() const
 {
   return pimpl_netpoint_->get_englobing_zone()->get_iface();
 }
@@ -277,7 +277,7 @@ std::vector<double> Host::convert_pstate_speed_vector(const std::vector<std::str
   speed_list.reserve(speed_per_state.size());
   for (const auto& speed_str : speed_per_state) {
     try {
-      double speed = xbt_parse_get_speed("", 0, speed_str.c_str(), nullptr, "");
+      double speed = xbt_parse_get_speed("", 0, speed_str, "");
       speed_list.push_back(speed);
     } catch (const simgrid::ParseError&) {
       throw std::invalid_argument(std::string("Invalid speed value: ") + speed_str);
@@ -305,6 +305,12 @@ int Host::get_pstate() const
   return this->pimpl_cpu->get_pstate();
 }
 
+Host* Host::set_coordinates(const std::string& coords)
+{
+  if (not coords.empty())
+    kernel::actor::simcall([this, coords] { this->pimpl_netpoint_->set_coordinates(coords); });
+  return this;
+}
 std::vector<Disk*> Host::get_disks() const
 {
   return this->pimpl_->get_disks();
@@ -312,9 +318,30 @@ std::vector<Disk*> Host::get_disks() const
 
 Disk* Host::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
 {
-  auto disk =
-      this->get_netpoint()->get_englobing_zone()->get_disk_model()->create_disk(name, read_bandwidth, write_bandwidth);
-  return disk->set_host(this)->get_iface();
+  return kernel::actor::simcall([this, &name, read_bandwidth, write_bandwidth] {
+    auto* disk = pimpl_->create_disk(name, read_bandwidth, write_bandwidth);
+    pimpl_->add_disk(disk);
+    return disk;
+  });
+}
+
+Disk* Host::create_disk(const std::string& name, const std::string& read_bandwidth, const std::string& write_bandwidth)
+{
+  double d_read;
+  try {
+    d_read = xbt_parse_get_bandwidth("", 0, read_bandwidth, "");
+  } catch (const simgrid::ParseError&) {
+    throw std::invalid_argument(std::string("Impossible to create disk: ") + name +
+                                std::string(". Invalid read bandwidth: ") + read_bandwidth);
+  }
+  double d_write;
+  try {
+    d_write = xbt_parse_get_bandwidth("", 0, write_bandwidth, "");
+  } catch (const simgrid::ParseError&) {
+    throw std::invalid_argument(std::string("Impossible to create disk: ") + name +
+                                std::string(". Invalid write bandwidth: ") + write_bandwidth);
+  }
+  return create_disk(name, d_read, d_write);
 }
 
 void Host::add_disk(const Disk* disk)
@@ -347,10 +374,11 @@ void Host::execute(double flops, double priority) const
   this_actor::exec_init(flops)->set_priority(1 / priority)->vetoable_start()->wait();
 }
 
-void Host::seal()
+Host* Host::seal()
 {
   kernel::actor::simcall([this]() { this->pimpl_->seal(); });
   simgrid::s4u::Host::on_creation(*this); // notify the signal
+  return this;
 }
 
 } // namespace s4u