Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make host's pimpl_netpoint private
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 22 Oct 2019 07:26:54 +0000 (09:26 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 22 Oct 2019 07:26:54 +0000 (09:26 +0200)
* getter is public
* setter is protected

include/simgrid/s4u/Host.hpp
src/instr/instr_paje_containers.cpp
src/kernel/routing/NetZoneImpl.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Host.cpp
src/surf/network_ns3.cpp
src/surf/sg_platf.cpp
teshsuite/simdag/flatifier/flatifier.cpp
teshsuite/simdag/is-router/is-router.cpp

index f9f856a..c36c54a 100644 (file)
@@ -38,6 +38,7 @@ namespace s4u {
 class XBT_PUBLIC Host : public xbt::Extendable<Host> {
   friend vm::VMModel;            // Use the pimpl_cpu to compute the VM sharing
   friend vm::VirtualMachineImpl; // creates the the pimpl_cpu
 class XBT_PUBLIC Host : public xbt::Extendable<Host> {
   friend vm::VMModel;            // Use the pimpl_cpu to compute the VM sharing
   friend vm::VirtualMachineImpl; // creates the the pimpl_cpu
+  friend kernel::routing::NetZoneImpl;
 
 public:
   explicit Host(const std::string& name);
 
 public:
   explicit Host(const std::string& name);
@@ -45,6 +46,7 @@ public:
   /** Host destruction logic */
 protected:
   virtual ~Host();
   /** Host destruction logic */
 protected:
   virtual ~Host();
+  void set_netpoint(kernel::routing::NetPoint* netpoint) { pimpl_netpoint_ = netpoint; }
 
 private:
   bool currently_destroying_ = false;
 
 private:
   bool currently_destroying_ = false;
@@ -77,6 +79,8 @@ public:
   /** Retrieves the name of that host as a C string */
   const char* get_cname() const { return name_.c_str(); }
 
   /** Retrieves the name of that host as a C string */
   const char* get_cname() const { return name_.c_str(); }
 
+  kernel::routing::NetPoint* get_netpoint() const { return pimpl_netpoint_; }
+
   int get_actor_count();
   std::vector<ActorPtr> get_all_actors();
 
   int get_actor_count();
   std::vector<ActorPtr> get_all_actors();
 
@@ -145,6 +149,7 @@ public:
 private:
   xbt::string name_{"noname"};
   std::unordered_map<std::string, Storage*>* mounts_ = nullptr; // caching
 private:
   xbt::string name_{"noname"};
   std::unordered_map<std::string, Storage*>* mounts_ = nullptr; // caching
+  kernel::routing::NetPoint* pimpl_netpoint_         = nullptr;
 
 public:
 #ifndef DOXYGEN
 
 public:
 #ifndef DOXYGEN
@@ -152,8 +157,6 @@ public:
   kernel::resource::Cpu* pimpl_cpu = nullptr;
   // TODO, this could be a unique_ptr
   surf::HostImpl* pimpl_ = nullptr;
   kernel::resource::Cpu* pimpl_cpu = nullptr;
   // TODO, this could be a unique_ptr
   surf::HostImpl* pimpl_ = nullptr;
-  /** DO NOT USE DIRECTLY (@todo: these should be protected, once our code is clean) */
-  kernel::routing::NetPoint* pimpl_netpoint = nullptr;
 #endif
 };
 } // namespace s4u
 #endif
 };
 } // namespace s4u
index 95bf51d..69bd672 100644 (file)
@@ -69,7 +69,7 @@ HostContainer::HostContainer(simgrid::s4u::Host const& host, NetZoneContainer* f
 {
   xbt_assert(father, "Only the Root container has no father");
 
 {
   xbt_assert(father, "Only the Root container has no father");
 
-  netpoint_ = host.pimpl_netpoint;
+  netpoint_ = host.get_netpoint();
   xbt_assert(netpoint_, "Element '%s' not found", host.get_cname());
 
   trivaNodeTypes.insert(type_->get_name());
   xbt_assert(netpoint_, "Element '%s' not found", host.get_cname());
 
   trivaNodeTypes.insert(type_->get_name());
index 670720c..ff8fe36 100644 (file)
@@ -100,7 +100,7 @@ simgrid::s4u::Host* NetZoneImpl::create_host(const char* name, const std::vector
   if (hierarchy_ == RoutingMode::unset)
     hierarchy_ = RoutingMode::base;
 
   if (hierarchy_ == RoutingMode::unset)
     hierarchy_ = RoutingMode::base;
 
-  res->pimpl_netpoint = new NetPoint(name, NetPoint::Type::Host, this);
+  res->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
 
   surf_cpu_model_pm->create_cpu(res, speed_per_pstate, coreAmount);
 
 
   surf_cpu_model_pm->create_cpu(res, speed_per_pstate, coreAmount);
 
index 9a4c1d0..128b757 100644 (file)
@@ -283,7 +283,7 @@ void VirtualMachineImpl::set_physical_host(s4u::Host* destination)
   std::string pm_name_dst = destination->get_name();
 
   /* update net_elm with that of the destination physical host */
   std::string pm_name_dst = destination->get_name();
 
   /* update net_elm with that of the destination physical host */
-  piface_->pimpl_netpoint = destination->pimpl_netpoint;
+  piface_->pimpl_netpoint_ = destination->get_netpoint();
 
   physical_host_ = destination;
 
 
   physical_host_ = destination;
 
index 4f63455..e812231 100644 (file)
@@ -35,7 +35,7 @@ VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host
   XBT_DEBUG("Create VM %s", get_cname());
 
   /* Currently, a VM uses the network resource of its physical host */
   XBT_DEBUG("Create VM %s", get_cname());
 
   /* Currently, a VM uses the network resource of its physical host */
-  pimpl_netpoint = physical_host->pimpl_netpoint;
+  set_netpoint(physical_host->get_netpoint());
 
   // Create a VCPU for this VM
   std::vector<double> speeds;
 
   // Create a VCPU for this VM
   std::vector<double> speeds;
@@ -54,7 +54,7 @@ VirtualMachine::~VirtualMachine()
   XBT_DEBUG("destroy %s", get_cname());
 
   /* Don't free these things twice: they are the ones of my physical host */
   XBT_DEBUG("destroy %s", get_cname());
 
   /* Don't free these things twice: they are the ones of my physical host */
-  pimpl_netpoint = nullptr;
+  set_netpoint(nullptr);
 }
 
 void VirtualMachine::start()
 }
 
 void VirtualMachine::start()
index a891bc6..459c290 100644 (file)
@@ -42,8 +42,8 @@ Host::~Host()
   xbt_assert(currently_destroying_, "Please call h->destroy() instead of manually deleting it.");
 
   delete pimpl_;
   xbt_assert(currently_destroying_, "Please call h->destroy() instead of manually deleting it.");
 
   delete pimpl_;
-  if (pimpl_netpoint != nullptr) // not removed yet by a children class
-    Engine::get_instance()->netpoint_unregister(pimpl_netpoint);
+  if (pimpl_netpoint_ != nullptr) // not removed yet by a children class
+    Engine::get_instance()->netpoint_unregister(pimpl_netpoint_);
   delete pimpl_cpu;
   delete mounts_;
 }
   delete pimpl_cpu;
   delete mounts_;
 }
@@ -160,7 +160,7 @@ void Host::route_to(Host* dest, std::vector<Link*>& links, double* latency)
 /** @brief Just like Host::routeTo, but filling an array of link implementations */
 void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
 {
 /** @brief Just like Host::routeTo, but filling an array of link implementations */
 void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
 {
-  kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint, dest->pimpl_netpoint, links, latency);
+  kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint_, dest->get_netpoint(), links, latency);
   if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
     XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(),
                (latency == nullptr ? -1 : *latency));
   if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
     XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(),
                (latency == nullptr ? -1 : *latency));
@@ -172,7 +172,7 @@ void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links,
 /** @brief Returns the networking zone englobing that host */
 NetZone* Host::get_englobing_zone()
 {
 /** @brief Returns the networking zone englobing that host */
 NetZone* Host::get_englobing_zone()
 {
-  return pimpl_netpoint->get_englobing_zone()->get_iface();
+  return pimpl_netpoint_->get_englobing_zone()->get_iface();
 }
 
 void Host::send_to(Host* dest, double byte_amount)
 }
 
 void Host::send_to(Host* dest, double byte_amount)
@@ -386,7 +386,7 @@ xbt_dynar_t sg_hosts_as_dynar()
   std::vector<simgrid::s4u::Host*> list = simgrid::s4u::Engine::get_instance()->get_all_hosts();
 
   auto last = std::remove_if(begin(list), end(list), [](const simgrid::s4u::Host* host) {
   std::vector<simgrid::s4u::Host*> list = simgrid::s4u::Engine::get_instance()->get_all_hosts();
 
   auto last = std::remove_if(begin(list), end(list), [](const simgrid::s4u::Host* host) {
-    return not host || not host->pimpl_netpoint || not host->pimpl_netpoint->is_host();
+    return not host || not host->get_netpoint() || not host->get_netpoint()->is_host();
   });
   std::sort(begin(list), last,
             [](const simgrid::s4u::Host* a, const simgrid::s4u::Host* b) { return a->get_name() < b->get_name(); });
   });
   std::sort(begin(list), last,
             [](const simgrid::s4u::Host* a, const simgrid::s4u::Host* b) { return a->get_name() < b->get_name(); });
index 1e14879..df15a7a 100644 (file)
@@ -75,7 +75,7 @@ static void clusterCreation_cb(simgrid::kernel::routing::ClusterCreationArgs con
 
     // Create private link
     std::string host_id = cluster.prefix + std::to_string(i) + cluster.suffix;
 
     // Create private link
     std::string host_id = cluster.prefix + std::to_string(i) + cluster.suffix;
-    auto* host_src      = simgrid::s4u::Host::by_name(host_id)->pimpl_netpoint->extension<NetPointNs3>();
+    auto* host_src      = simgrid::s4u::Host::by_name(host_id)->get_netpoint()->extension<NetPointNs3>();
     xbt_assert(host_src, "Cannot find a ns-3 host of name %s", host_id.c_str());
 
     // Any ns-3 route is symmetrical
     xbt_assert(host_src, "Cannot find a ns-3 host of name %s", host_id.c_str());
 
     // Any ns-3 route is symmetrical
@@ -323,8 +323,8 @@ NetworkNS3Action::NetworkNS3Action(Model* model, double totalBytes, s4u::Host* s
 
   static int port_number = 1025; // Port number is limited from 1025 to 65 000
 
 
   static int port_number = 1025; // Port number is limited from 1025 to 65 000
 
-  unsigned int node1 = src->pimpl_netpoint->extension<NetPointNs3>()->node_num;
-  unsigned int node2 = dst->pimpl_netpoint->extension<NetPointNs3>()->node_num;
+  unsigned int node1 = src->get_netpoint()->extension<NetPointNs3>()->node_num;
+  unsigned int node2 = dst->get_netpoint()->extension<NetPointNs3>()->node_num;
 
   ns3::Ptr<ns3::Node> src_node = src->pimpl_netpoint->extension<NetPointNs3>()->ns3_node_;
   ns3::Ptr<ns3::Node> dst_node = dst->pimpl_netpoint->extension<NetPointNs3>()->ns3_node_;
 
   ns3::Ptr<ns3::Node> src_node = src->pimpl_netpoint->extension<NetPointNs3>()->ns3_node_;
   ns3::Ptr<ns3::Node> dst_node = dst->pimpl_netpoint->extension<NetPointNs3>()->ns3_node_;
index 2359340..9f7b635 100644 (file)
@@ -93,7 +93,7 @@ void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
   if (args->pstate != 0)
     host->set_pstate(args->pstate);
   if (not args->coord.empty())
   if (args->pstate != 0)
     host->set_pstate(args->pstate);
   if (not args->coord.empty())
-    new simgrid::kernel::routing::vivaldi::Coords(host->pimpl_netpoint, args->coord);
+    new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
 }
 
 /** @brief Add a "router" to the network element list */
 }
 
 /** @brief Add a "router" to the network element list */
@@ -503,7 +503,7 @@ void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer)
   speed_per_pstate.push_back(peer->speed);
   simgrid::s4u::Host* host = as->create_host(peer->id.c_str(), speed_per_pstate, 1, nullptr);
 
   speed_per_pstate.push_back(peer->speed);
   simgrid::s4u::Host* host = as->create_host(peer->id.c_str(), speed_per_pstate, 1, nullptr);
 
-  as->set_peer_link(host->pimpl_netpoint, peer->bw_in, peer->bw_out, peer->coord);
+  as->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out, peer->coord);
 
   /* Change from the defaults */
   if (peer->state_trace)
 
   /* Change from the defaults */
   if (peer->state_trace)
@@ -667,7 +667,7 @@ void sg_platf_new_Zone_seal()
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
 void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
 {
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
 void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
 {
-  simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->pimpl_netpoint;
+  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.");
   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.");
index ce9155b..da1a39a 100644 (file)
@@ -122,11 +122,11 @@ static void dump_routes()
 
   for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
     simgrid::s4u::Host* host1               = hosts[it_src];
 
   for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
     simgrid::s4u::Host* host1               = hosts[it_src];
-    simgrid::kernel::routing::NetPoint* src = host1->pimpl_netpoint;
+    simgrid::kernel::routing::NetPoint* src = host1->get_netpoint();
     for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
       simgrid::s4u::Host* host2 = hosts[it_dst];
       std::vector<simgrid::kernel::resource::LinkImpl*> route;
     for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
       simgrid::s4u::Host* host2 = hosts[it_dst];
       std::vector<simgrid::kernel::resource::LinkImpl*> route;
-      simgrid::kernel::routing::NetPoint* dst = host2->pimpl_netpoint;
+      simgrid::kernel::routing::NetPoint* dst = host2->get_netpoint();
       simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
       if (not route.empty()) {
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", host1->get_cname(), host2->get_cname());
       simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
       if (not route.empty()) {
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", host1->get_cname(), host2->get_cname());
@@ -164,7 +164,7 @@ static void dump_routes()
         simgrid::s4u::Host* host2 = hosts[it_dst];
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->get_cname(), host2->get_cname());
         std::vector<simgrid::kernel::resource::LinkImpl*> route;
         simgrid::s4u::Host* host2 = hosts[it_dst];
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->get_cname(), host2->get_cname());
         std::vector<simgrid::kernel::resource::LinkImpl*> route;
-        simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
+        simgrid::kernel::routing::NetPoint* netcardDst = host2->get_netpoint();
         simgrid::kernel::routing::NetZoneImpl::get_global_route(value1, netcardDst, route, nullptr);
         for (auto const& link : route)
           std::printf("<link_ctn id=\"%s\"/>", link->get_cname());
         simgrid::kernel::routing::NetZoneImpl::get_global_route(value1, netcardDst, route, nullptr);
         for (auto const& link : route)
           std::printf("<link_ctn id=\"%s\"/>", link->get_cname());
index 35441df..e48c032 100644 (file)
@@ -29,7 +29,7 @@ int main(int argc, char **argv)
   int it;
   sg_host_t host;
   xbt_dynar_foreach(hosts, it, host) {
   int it;
   sg_host_t host;
   xbt_dynar_foreach(hosts, it, host) {
-    simgrid::kernel::routing::NetPoint* nc = host->pimpl_netpoint;
+    simgrid::kernel::routing::NetPoint* nc = host->get_netpoint();
     const char *type = "buggy";
     if (nc->is_router())
       type = "router";
     const char *type = "buggy";
     if (nc->is_router())
       type = "router";