Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into 'master'
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 25 Feb 2021 22:40:12 +0000 (22:40 +0000)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 25 Feb 2021 22:40:12 +0000 (22:40 +0000)
Add option to delay wifi zone start time

See merge request simgrid/simgrid!47

24 files changed:
include/simgrid/kernel/resource/Resource.hpp
include/simgrid/kernel/routing/NetZoneImpl.hpp
include/simgrid/kernel/routing/WifiZone.hpp
include/simgrid/s4u/Disk.hpp
include/simgrid/s4u/Host.hpp
include/simgrid/s4u/Link.hpp
src/kernel/resource/DiskImpl.cpp
src/kernel/resource/DiskImpl.hpp
src/kernel/resource/Resource.cpp
src/kernel/resource/profile/Profile_test.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/WifiZone.cpp
src/s4u/s4u_Disk.cpp
src/s4u/s4u_Host.cpp
src/s4u/s4u_Link.cpp
src/simix/smx_global.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/mpi/smpi_group.cpp
src/surf/cpu_interface.cpp
src/surf/disk_s19.cpp
src/surf/disk_s19.hpp
src/surf/network_interface.cpp
src/surf/sg_platf.cpp
src/xbt_modinter.h

index fc8d09a..526237b 100644 (file)
@@ -22,11 +22,11 @@ namespace resource {
  * @details This is the ancestor class of every resources in SimGrid, such as links, CPU or disk
  */
 class XBT_PUBLIC Resource {
-  std::string name_;
-  Model* model_;
-  bool is_on_ = true;
+  std::string name_ = "unnamed";
+  Model* model_     = nullptr;
+  bool is_on_       = true;
 
-  lmm::Constraint* const constraint_;
+  lmm::Constraint* constraint_ = nullptr;
 
 protected:
   struct Metric {
@@ -37,27 +37,22 @@ protected:
   profile::Event* state_event_ = nullptr;
 
 public:
-  /**
-   * @brief Constructor of LMM Resources
-   *
-   * @param model Model associated to this Resource
-   * @param name The name of the Resource
-   * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component
-   */
-  Resource(Model* model, const std::string& name, lmm::Constraint* constraint)
-      : name_(name), model_(model), constraint_(constraint)
-  {
-  }
-
+  Resource() = default;
   virtual ~Resource() = default;
 
   /** @brief Get the Model of the current Resource */
   Model* get_model() const { return model_; }
+  Resource* set_model(Model* model);
 
   /** @brief Get the name of the current Resource */
   const std::string& get_name() const { return name_; }
   /** @brief Get the name of the current Resource */
   const char* get_cname() const { return name_.c_str(); }
+  Resource* set_name(const std::string& name);
+
+  /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
+  lmm::Constraint* get_constraint() const { return constraint_; }
+  Resource* set_constraint(lmm::Constraint* constraint);
 
   bool operator==(const Resource& other) const { return name_ == other.name_; }
 
@@ -81,8 +76,6 @@ public:
   /** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */
   virtual void set_state_profile(profile::Profile* profile);
 
-  /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
-  lmm::Constraint* get_constraint() const { return constraint_; }
 };
 } // namespace resource
 } // namespace kernel
index 52b88e4..62c25c3 100644 (file)
@@ -120,12 +120,10 @@ public:
   int get_host_count() const;
 
   /** @brief Make a host within that NetZone */
-  s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count,
-                         const std::unordered_map<std::string, std::string>* props);
+  s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count);
   /** @brief Make a link within that NetZone */
   virtual s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
-                                 s4u::Link::SharingPolicy policy,
-                                 const std::unordered_map<std::string, std::string>* props);
+                                 s4u::Link::SharingPolicy policy);
   /** @brief Creates a new route in this NetZone */
   virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                                 std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
index c695e6e..f08aa1f 100644 (file)
@@ -28,8 +28,7 @@ public:
   void seal() override;
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
   s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
-                         s4u::Link::SharingPolicy policy,
-                         const std::unordered_map<std::string, std::string>* props) override;
+                         s4u::Link::SharingPolicy policy) override;
   NetPoint* get_access_point() {return access_point_;}
 
 private:
index 7ccbe6c..f0542c7 100644 (file)
@@ -43,7 +43,7 @@ protected:
 
 public:
 #ifndef DOXYGEN
-  explicit Disk(const std::string& name, kernel::resource::DiskImpl* pimpl) : pimpl_(pimpl), name_(name) {}
+  explicit Disk(kernel::resource::DiskImpl* pimpl) : pimpl_(pimpl) {}
 #endif
 
   /** @brief Callback signal fired when a new Disk is created */
@@ -54,11 +54,17 @@ public:
   static xbt::signal<void(Disk const&)> on_state_change;
 
   /** @brief Retrieves the name of that disk as a C++ string */
+  Disk* set_name(std::string const& name);
   std::string const& get_name() const { return name_; }
   /** @brief Retrieves the name of that disk as a C string */
   const char* get_cname() const { return name_.c_str(); }
+
+  Disk* set_read_bandwidth(double read_bw);
   double get_read_bandwidth() const;
+
+  Disk* set_write_bandwidth(double write_bw);
   double get_write_bandwidth() const;
+
   const std::unordered_map<std::string, std::string>* get_properties() const;
   const char* get_property(const std::string& key) const;
   void set_property(const std::string&, const std::string& value);
index fe1dcc4..13e4544 100644 (file)
@@ -46,7 +46,7 @@ public:
 
 protected:
   virtual ~Host(); // Call destroy() instead of manually deleting it.
-  void set_netpoint(kernel::routing::NetPoint* netpoint) { pimpl_netpoint_ = netpoint; }
+  Host* set_netpoint(kernel::routing::NetPoint* netpoint);
 #endif
 
 public:
@@ -100,9 +100,9 @@ public:
   bool is_on() const;
 
   const char* get_property(const std::string& key) const;
-  void set_property(const std::string& key, const std::string& value);
+  Host* set_property(const std::string& key, const std::string& value);
   const std::unordered_map<std::string, std::string>* get_properties() const;
-  void set_properties(const std::unordered_map<std::string, std::string>& properties);
+  Host* set_properties(const std::unordered_map<std::string, std::string>& properties);
 
   void set_state_profile(kernel::profile::Profile* p);
   void set_speed_profile(kernel::profile::Profile* p);
@@ -143,6 +143,7 @@ public:
   int get_pstate() const;
 
   std::vector<Disk*> get_disks() const;
+  Disk* create_disk();
   void add_disk(const Disk* disk);
   void remove_disk(const std::string& disk_name);
 
index d3f06f4..58e2612 100644 (file)
@@ -101,7 +101,9 @@ public:
   void set_latency_profile(kernel::profile::Profile* profile);
 
   const char* get_property(const std::string& key) const;
-  void set_property(const std::string& key, const std::string& value);
+  Link* set_property(const std::string& key, const std::string& value);
+  const std::unordered_map<std::string, std::string>* get_properties() const;
+  Link* set_properties(const std::unordered_map<std::string, std::string>& properties);
 
   /* The signals */
   /** @brief Callback signal fired when a new Link is created */
index f9d1b3a..8907216 100644 (file)
@@ -35,17 +35,28 @@ DiskModel::~DiskModel()
  * Resource *
  ************/
 
-DiskImpl::DiskImpl(kernel::resource::Model* model, const std::string& name, kernel::lmm::System* maxminSystem,
-                   double read_bw, double write_bw)
-    : Resource(model, name, maxminSystem->constraint_new(this, std::max(read_bw, write_bw)))
-    , piface_(name, this)
-    , read_bw_(read_bw)
-    , write_bw_(write_bw)
+DiskImpl* DiskImpl::set_read_bandwidth(double read_bw)
 {
-  DiskImpl::turn_on();
-  XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw_, write_bw_);
-  constraint_read_  = maxminSystem->constraint_new(this, read_bw);
-  constraint_write_ = maxminSystem->constraint_new(this, write_bw);
+  read_bw_ = read_bw;
+  return this;
+}
+
+DiskImpl* DiskImpl::set_write_bandwidth(double write_bw)
+{
+  write_bw_ = write_bw;
+  return this;
+}
+
+DiskImpl* DiskImpl::set_read_constraint(lmm::Constraint* constraint_read)
+{
+  constraint_read_  = constraint_read;
+  return this;
+}
+
+DiskImpl* DiskImpl::set_write_constraint(lmm::Constraint* constraint_write)
+{
+  constraint_write_  = constraint_write;
+  return this;
 }
 
 /** @brief Fire the required callbacks and destroy the object
index 2a2d85d..ce9563d 100644 (file)
@@ -41,7 +41,7 @@ public:
   DiskModel& operator=(const DiskModel&) = delete;
   ~DiskModel() override;
 
-  virtual DiskImpl* createDisk(const std::string& id, double read_bw, double write_bw) = 0;
+  virtual DiskImpl* create_disk() = 0;
 };
 
 /************
@@ -50,16 +50,16 @@ public:
 class DiskImpl : public Resource, public xbt::PropertyHolder {
   s4u::Host* host_           = nullptr;
   s4u::Disk piface_;
-  double read_bw_;
-  double write_bw_;
-  lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/
-  lmm::Constraint* constraint_read_;  /* Constraint for maximum read bandwidth*/
+  double read_bw_ = -1.0;
+  double write_bw_ = 1.0;
+  lmm::Constraint* constraint_write_ = nullptr; /* Constraint for maximum write bandwidth*/
+  lmm::Constraint* constraint_read_ = nullptr;  /* Constraint for maximum read bandwidth*/
 
 protected:
   ~DiskImpl() override = default; // Disallow direct deletion. Call destroy() instead.
 
 public:
-  DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
+  DiskImpl() : piface_(this){}
   DiskImpl(const DiskImpl&) = delete;
   DiskImpl& operator=(const DiskImpl&) = delete;
 
@@ -69,9 +69,16 @@ public:
   s4u::Host* get_host() const { return host_; }
   void set_host(s4u::Host* host) { host_ = host; }
 
+  DiskImpl* set_read_bandwidth(double read_bw);
   double get_read_bandwidth() const { return read_bw_; }
+
+  DiskImpl* set_write_bandwidth(double write_bw);
   double get_write_bandwidth() const { return write_bw_; }
+
+  DiskImpl* set_read_constraint(lmm::Constraint* constraint_read);
   lmm::Constraint* get_read_constraint() const { return constraint_read_; }
+
+  DiskImpl* set_write_constraint(lmm::Constraint* constraint_write);
   lmm::Constraint* get_write_constraint() const { return constraint_write_; }
 
   /** @brief Check if the Disk is used (if an action currently uses its resources) */
index 581d6c7..590db09 100644 (file)
@@ -13,6 +13,24 @@ namespace simgrid {
 namespace kernel {
 namespace resource {
 
+Resource* Resource::set_name(const std::string& name)
+{
+  name_ = name;
+  return this;
+}
+
+Resource* Resource::set_model(Model* model)
+{
+  model_ = model;
+  return this;
+}
+
+Resource* Resource::set_constraint(lmm::Constraint* constraint)
+{
+  constraint_ = constraint;
+  return this;
+}
+
 double Resource::get_load() const
 {
   return constraint_->get_usage();
index 5776a1e..283de0f 100644 (file)
@@ -24,7 +24,7 @@ class MockedResource : public simgrid::kernel::resource::Resource {
 public:
   static double the_date;
 
-  explicit MockedResource() : simgrid::kernel::resource::Resource(nullptr, "fake", nullptr) {}
+  explicit MockedResource() { this->set_name("fake"); }
   void apply_event(simgrid::kernel::profile::Event* event, double value) override
   {
     XBT_VERB("t=%.1f: Change value to %lg (idx: %u)", the_date, value, event->idx);
index ec9c601..215fe47 100644 (file)
@@ -66,8 +66,7 @@ int NetZoneImpl::get_host_count() const
 }
 
 s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
-                                    s4u::Link::SharingPolicy policy,
-                                    const std::unordered_map<std::string, std::string>* props)
+                                    s4u::Link::SharingPolicy policy)
 {
   static double last_warned_latency = sg_surf_precision;
   if (latency != 0.0 && latency < last_warned_latency) {
@@ -79,28 +78,19 @@ s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<d
 
   auto* l = surf_network_model->create_link(name, bandwidths, latency, policy);
 
-  if (props)
-    l->set_properties(*props);
-
   return l->get_iface();
 }
+
 s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate,
-                                    int coreAmount, const std::unordered_map<std::string, std::string>* props)
+                                    int coreAmount)
 {
-  auto* res = new s4u::Host(name);
-
   if (hierarchy_ == RoutingMode::unset)
     hierarchy_ = RoutingMode::base;
 
-  res->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
+  auto* res = (new s4u::Host(name))->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
 
   surf_cpu_model_pm->create_cpu(res, speed_per_pstate, coreAmount);
 
-  if (props != nullptr)
-    res->set_properties(*props);
-
-  s4u::Host::on_creation(*res); // notify the signal
-
   return res;
 }
 
index 5eae791..5296561 100644 (file)
@@ -56,15 +56,14 @@ void WifiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
   }
 }
 s4u::Link* WifiZone::create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
-                                 s4u::Link::SharingPolicy policy,
-                                 const std::unordered_map<std::string, std::string>* props)
+                                 s4u::Link::SharingPolicy policy)
 {
   xbt_assert(wifi_link_ == nullptr,
              "WIFI netzone %s contains more than one link. Please only declare one, the wifi link.", get_cname());
   xbt_assert(policy == s4u::Link::SharingPolicy::WIFI, "Link %s in WIFI zone %s must follow the WIFI sharing policy.",
              name.c_str(), get_cname());
 
-  auto s4u_link = NetZoneImpl::create_link(name, bandwidths, latency, policy, props);
+  auto s4u_link = NetZoneImpl::create_link(name, bandwidths, latency, policy);
   wifi_link_    = s4u_link->get_impl();
   return s4u_link;
 }
index 2cc158a..937e537 100644 (file)
@@ -20,6 +20,24 @@ xbt::signal<void(Disk&)> Disk::on_creation;
 xbt::signal<void(Disk const&)> Disk::on_destruction;
 xbt::signal<void(Disk const&)> Disk::on_state_change;
 
+Disk* Disk::set_name(const std::string& name)
+{
+  name_ = name;
+  return this;
+}
+
+Disk* Disk::set_read_bandwidth(double read_bw)
+{
+  pimpl_->set_read_bandwidth(read_bw);
+  return this;
+}
+
+Disk* Disk::set_write_bandwidth(double write_bw)
+{
+  pimpl_->set_write_bandwidth(write_bw);
+  return this;
+}
+
 double Disk::get_read_bandwidth() const
 {
   return this->pimpl_->get_read_bandwidth();
index becb093..b9da40c 100644 (file)
@@ -37,6 +37,12 @@ Host::Host(const std::string& name) : name_(name)
   new surf::HostImpl(this);
 }
 
+Host* Host::set_netpoint(kernel::routing::NetPoint* netpoint)
+{
+  pimpl_netpoint_ = netpoint;
+  return this;
+}
+
 Host::~Host()
 {
   delete pimpl_;
@@ -192,14 +198,16 @@ const char* Host::get_property(const std::string& key) const
   return this->pimpl_->get_property(key);
 }
 
-void Host::set_property(const std::string& key, const std::string& value)
+Host* Host::set_property(const std::string& key, const std::string& value)
 {
   kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+  return this;
 }
 
-void Host::set_properties(const std::unordered_map<std::string, std::string>& properties)
+Host* Host::set_properties(const std::unordered_map<std::string, std::string>& properties)
 {
   kernel::actor::simcall([this, &properties] { this->pimpl_->set_properties(properties); });
+  return this;
 }
 
 /** Specify a profile turning the host on and off according to an exhaustive list or a stochastic law.
@@ -259,6 +267,12 @@ std::vector<Disk*> Host::get_disks() const
   return kernel::actor::simcall([this] { return this->pimpl_->get_disks(); });
 }
 
+Disk* Host::create_disk()
+{
+  auto pimpl = surf_disk_model->create_disk();
+  return pimpl->get_iface();
+}
+
 void Host::add_disk(const Disk* disk)
 {
   kernel::actor::simcall([this, disk] { this->pimpl_->add_disk(disk); });
index 6d71cf2..59cee96 100644 (file)
@@ -126,10 +126,23 @@ const char* Link::get_property(const std::string& key) const
 {
   return this->pimpl_->get_property(key);
 }
-void Link::set_property(const std::string& key, const std::string& value)
+Link* Link::set_property(const std::string& key, const std::string& value)
 {
   simgrid::kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+  return this;
 }
+
+const std::unordered_map<std::string, std::string>* Link::get_properties() const
+{
+  return this->pimpl_->get_properties();
+}
+
+Link* Link::set_properties(const std::unordered_map<std::string, std::string>& properties)
+{
+  kernel::actor::simcall([this, &properties] { this->pimpl_->set_properties(properties); });
+  return this;
+}
+
 } // namespace s4u
 } // namespace simgrid
 
index b8a4412..3d2ec1d 100644 (file)
@@ -307,7 +307,6 @@ void SIMIX_global_init(int *argc, char **argv)
     atexit(SIMIX_clean);
 }
 
-int smx_cleaned = 0;
 /**
  * @ingroup SIMIX_API
  * @brief Clean the SIMIX simulation
@@ -316,10 +315,11 @@ int smx_cleaned = 0;
  */
 void SIMIX_clean()
 {
+  static bool smx_cleaned = false;
   if (smx_cleaned)
     return; // to avoid double cleaning by java and C
 
-  smx_cleaned = 1;
+  smx_cleaned = true;
   XBT_DEBUG("SIMIX_clean called. Simulation's over.");
   if (not simix_global->actors_to_run.empty() && SIMIX_get_clock() <= 0.0) {
     XBT_CRITICAL("   ");
index 112ca0f..ca57aba 100644 (file)
@@ -635,21 +635,20 @@ void SMPI_finalize()
 
   if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP)
     smpi_destroy_global_memory_segments();
-  if (simgrid::smpi::F2C::lookup() != nullptr){
-    if (simgrid::smpi::F2C::lookup()->size() > simgrid::smpi::F2C::get_num_default_handles()){
-      XBT_WARN("Probable Leaks in your code: SMPI detected %zu unfreed MPI handles : "
-               "display types and addresses (n max) with --cfg=smpi/list-leaks:n.\n"
-               "Running smpirun with -wrapper \"valgrind --leak-check=full\" can provide more information",
-               simgrid::smpi::F2C::lookup()->size() - simgrid::smpi::F2C::get_num_default_handles());
-      int n = simgrid::config::get_value<int>("smpi/list-leaks");
-      for (auto const& p : *simgrid::smpi::F2C::lookup()) {
-        static int printed = 0;
-        if (printed >= n)
-          break;
-        if (p.first >= simgrid::smpi::F2C::get_num_default_handles()) {
-          XBT_WARN("Leak %p of type %s", p.second, boost::core::demangle(typeid(*(p.second)).name()).c_str());
-          printed++;
-        }
+  if (simgrid::smpi::F2C::lookup() != nullptr &&
+      simgrid::smpi::F2C::lookup()->size() > simgrid::smpi::F2C::get_num_default_handles()) {
+    XBT_WARN("Probable Leaks in your code: SMPI detected %zu unfreed MPI handles : "
+             "display types and addresses (n max) with --cfg=smpi/list-leaks:n.\n"
+             "Running smpirun with -wrapper \"valgrind --leak-check=full\" can provide more information",
+             simgrid::smpi::F2C::lookup()->size() - simgrid::smpi::F2C::get_num_default_handles());
+    int n = simgrid::config::get_value<int>("smpi/list-leaks");
+    for (auto const& p : *simgrid::smpi::F2C::lookup()) {
+      static int printed = 0;
+      if (printed >= n)
+        break;
+      if (p.first >= simgrid::smpi::F2C::get_num_default_handles()) {
+        XBT_WARN("Leak %p of type %s", p.second, boost::core::demangle(typeid(*(p.second)).name()).c_str());
+        printed++;
       }
     }
   }
index 0423a62..a4e1738 100644 (file)
@@ -276,7 +276,8 @@ int Group::range_excl(int n, int ranges[][3], MPI_Group* newgroup)
   } else {
     *newgroup = new Group(newsize);
 
-    for (int j = 0, rank = 0; rank < size_; rank++) {
+    int j = 0;
+    for (int rank = 0; rank < size_; rank++) {
       if (not to_excl[rank]) {
         s4u::Actor* actor = this->actor(rank);
         (*newgroup)->set_mapping(actor, j);
index e60ece1..c826944 100644 (file)
@@ -58,11 +58,12 @@ Cpu::Cpu(Model* model, s4u::Host* host, const std::vector<double>& speed_per_pst
 
 Cpu::Cpu(Model* model, s4u::Host* host, lmm::Constraint* constraint, const std::vector<double>& speed_per_pstate,
          int core)
-    : Resource(model, host->get_cname(), constraint)
-    , core_count_(core)
+    : core_count_(core)
     , host_(host)
     , speed_per_pstate_(speed_per_pstate)
 {
+  this->set_name(host->get_cname())->set_model(model)->set_constraint(constraint);
+
   xbt_assert(core > 0, "Host %s must have at least one core, not 0.", host->get_cname());
 
   speed_.peak     = speed_per_pstate_.front();
index 80fe78b..3d114cc 100644 (file)
@@ -31,11 +31,9 @@ DiskS19Model::DiskS19Model()
   all_existing_models.push_back(this);
 }
 
-DiskImpl* DiskS19Model::createDisk(const std::string& id, double read_bw, double write_bw)
+DiskImpl* DiskS19Model::create_disk()
 {
-  XBT_DEBUG("SURF disk create resource\n\t\tid '%s'\n\t\tread_bw '%f'\n", id.c_str(), read_bw);
-
-  return new DiskS19(this, id, get_maxmin_system(), read_bw, write_bw);
+  return new DiskS19();
 }
 
 double DiskS19Model::next_occurring_event(double now)
@@ -62,12 +60,6 @@ void DiskS19Model::update_actions_state(double /*now*/, double delta)
  * Resource *
  ************/
 
-DiskS19::DiskS19(DiskModel* model, const std::string& name, lmm::System* maxminSystem, double read_bw, double write_bw)
-    : DiskImpl(model, name, maxminSystem, read_bw, write_bw)
-{
-  XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw, write_bw);
-}
-
 DiskAction* DiskS19::io_start(sg_size_t size, s4u::Io::OpType type)
 {
   return new DiskS19Action(get_model(), static_cast<double>(size), not is_on(), this, type);
index a46ffce..50b2e35 100644 (file)
@@ -29,7 +29,7 @@ class XBT_PRIVATE DiskS19Action;
 class DiskS19Model : public DiskModel {
 public:
   DiskS19Model();
-  DiskImpl* createDisk(const std::string& id, double read_bw, double write_bw) override;
+  DiskImpl* create_disk() override;
   double next_occurring_event(double now) override;
   void update_actions_state(double now, double delta) override;
 };
@@ -40,8 +40,7 @@ public:
 
 class DiskS19 : public DiskImpl {
 public:
-  DiskS19(DiskModel* model, const std::string& name, kernel::lmm::System* maxminSystem, double read_bw,
-          double write_bw);
+  DiskS19() = default;
   DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) override;
   DiskAction* read(sg_size_t size) override;
   DiskAction* write(sg_size_t size) override;
index c2f2caa..15e75ad 100644 (file)
@@ -74,8 +74,9 @@ double NetworkModel::next_occurring_event_full(double now)
  ************/
 
 LinkImpl::LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint)
-    : Resource(model, name, constraint), piface_(this)
+    : piface_(this)
 {
+  this->set_name(name)->set_model(model)->set_constraint(constraint);
   if (name != "__loopback__")
     xbt_assert(not s4u::Link::by_name_or_null(name), "Link '%s' declared several times in the platform.", name.c_str());
 
index 809225f..0d046fb 100644 (file)
@@ -66,16 +66,13 @@ void sg_platf_exit() {
 /** @brief Add a host to the current AS */
 void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
 {
-  std::unordered_map<std::string, std::string> props;
+  simgrid::s4u::Host* host = routing_get_current()->create_host(args->id, args->speed_per_pstate, args->core_amount);
+
   if (args->properties) {
-    for (auto const& elm : *args->properties)
-      props.insert({elm.first, elm.second});
+    host->set_properties(*args->properties);
     delete args->properties;
   }
 
-  simgrid::s4u::Host* host =
-      routing_get_current()->create_host(args->id, args->speed_per_pstate, args->core_amount, &props);
-
   host->pimpl_->set_disks(args->disks, host);
 
   /* Change from the defaults */
@@ -87,6 +84,8 @@ void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
     host->set_pstate(args->pstate);
   if (not args->coord.empty())
     new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
+
+  simgrid::s4u::Host::on_creation(*host); // notify the signal
 }
 
 /** @brief Add a "router" to the network element list */
@@ -110,13 +109,10 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name,
 
 static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* args, const std::string& link_name)
 {
-  std::unordered_map<std::string, std::string> props;
-  if (args->properties)
-    for (auto const& elm : *args->properties)
-      props.insert({elm.first, elm.second});
+  simgrid::s4u::Link* link = routing_get_current()->create_link(link_name, args->bandwidths, args->latency, args->policy);
 
-  const simgrid::s4u::Link* link =
-      routing_get_current()->create_link(link_name, args->bandwidths, args->latency, args->policy, &props);
+  if (args->properties)
+    link->set_properties(*args->properties);
 
   simgrid::kernel::resource::LinkImpl* l = link->get_impl();
   if (args->latency_trace)
@@ -328,13 +324,31 @@ void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* c
 
 simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
 {
-  simgrid::kernel::resource::DiskImpl* d = surf_disk_model->createDisk(disk->id, disk->read_bw, disk->write_bw);
+  simgrid::kernel::lmm::System* maxmin_system = surf_disk_model->get_maxmin_system();
+  simgrid::kernel::resource::DiskImpl* pimpl = surf_disk_model->create_disk();
+
+  // This should be done using s4u::Disk methods and passed to the pimpl
+  pimpl->set_read_bandwidth(disk->read_bw)
+      ->set_write_bandwidth(disk->write_bw)
+      ->set_name(disk->id);
   if (disk->properties) {
-    d->set_properties(*disk->properties);
+    pimpl->set_properties(*disk->properties);
     delete disk->properties;
   }
-  simgrid::s4u::Disk::on_creation(*d->get_iface());
-  return d;
+
+  // This should be done in the seal() of a Disk creation
+  pimpl->set_read_constraint(maxmin_system->constraint_new(pimpl,disk->read_bw))
+      ->set_write_constraint(maxmin_system->constraint_new(pimpl, disk->write_bw))
+      ->set_model(surf_disk_model)
+      ->set_constraint(maxmin_system->constraint_new(pimpl, std::max(disk->read_bw, disk->write_bw)));
+
+  XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", disk->read_bw, disk->write_bw);
+  pimpl->turn_on();
+
+  // Temporary hack
+  pimpl->get_iface()->set_name(disk->id);
+  simgrid::s4u::Disk::on_creation(*pimpl->get_iface());
+  return pimpl;
 }
 
 void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route)
@@ -425,7 +439,7 @@ void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
 
   std::vector<double> speed_per_pstate;
   speed_per_pstate.push_back(peer->speed);
-  simgrid::s4u::Host* host = as->create_host(peer->id, speed_per_pstate, 1, nullptr);
+  simgrid::s4u::Host* host = as->create_host(peer->id, speed_per_pstate, 1);
 
   as->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out, peer->coord);
 
@@ -434,6 +448,7 @@ void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
     host->set_state_profile(peer->state_trace);
   if (peer->speed_trace)
     host->set_speed_profile(peer->speed_trace);
+  simgrid::s4u::Host::on_creation(*host); // notify the signal
 }
 
 /* Pick the right models for CPU, net and host, and call their model_init_preparse */
@@ -560,26 +575,26 @@ void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std:
 }
 
 /**
- * @brief Specify that the description of the current AS is finished
+ * @brief Specify that the description of the current Zone is finished
  *
- * Once you've declared all the content of your AS, you have to seal
- * it with this call. Your AS is not usable until you call this function.
+ * Once you've declared all the content of your Zone, you have to seal
+ * it with this call. Your Zone is not usable until you call this function.
  */
 void sg_platf_new_Zone_seal()
 {
-  xbt_assert(current_routing, "Cannot seal the current AS: none under construction");
+  xbt_assert(current_routing, "Cannot seal the current Zone: zone under construction");
   current_routing->seal();
   simgrid::s4u::NetZone::on_seal(*current_routing->get_iface());
   current_routing = current_routing->get_father();
 }
 
-/** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
+/** @brief Add a link connecting a host to the rest of its Zone (which must be cluster or vivaldi) */
 void sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
 {
   const simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
   xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
   xbt_assert(dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing),
-             "Only hosts from Cluster and Vivaldi ASes can get a host_link.");
+             "Only hosts from Cluster and Vivaldi Zones can get a host_link.");
 
   const simgrid::s4u::Link* linkUp   = simgrid::s4u::Link::by_name_or_null(hostlink->link_up);
   const simgrid::s4u::Link* linkDown = simgrid::s4u::Link::by_name_or_null(hostlink->link_down);
index b01737f..e746052 100644 (file)
@@ -22,7 +22,6 @@ void xbt_dict_postexit(void);
 void *mmalloc_preinit(void);
 void mmalloc_postexit(void);
 
-extern int smx_cleaned;
 extern int xbt_initialized;
 
 SG_END_DECL