Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
snake_case s4u::Link
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 16 May 2018 06:43:14 +0000 (08:43 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 16 May 2018 06:43:14 +0000 (08:43 +0200)
include/simgrid/s4u/Link.hpp
src/instr/instr_platform.cpp
src/s4u/s4u_Host.cpp
src/s4u/s4u_Link.cpp
src/surf/plugins/link_energy.cpp
src/surf/xml/surfxml_parseplatf.cpp
teshsuite/simdag/flatifier/flatifier.cpp

index 7a9bea2..b9ae777 100644 (file)
@@ -40,41 +40,36 @@ public:
   /** @brief Retrieves the name of that link as a C string */
   const char* get_cname() const;
 
-  XBT_ATTRIB_DEPRECATED_v323("Please use Link::by_name()") static Link* byName(const char* name) { return by_name(name); }
-  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_name()") const std::string& getName() const { return get_name(); }
-  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_cname()") const char* getCname() const { return get_cname(); }
-
   /** @brief Get the bandwidth in bytes per second of current Link */
-  double bandwidth();
+  double get_bandwidth();
 
   /** @brief Get the latency in seconds of current Link */
-  double latency();
+  double get_latency();
 
-  /** @brief The sharing policy is a @{link e_surf_link_sharing_policy_t::EType} (0: FATPIPE, 1: SHARED, 2: SPLITDUPLEX)
-   */
-  SharingPolicy sharingPolicy();
+  /** @brief Describes how the link is shared between flows */
+  SharingPolicy get_sharing_policy();
 
   /** @brief Returns the current load (in flops per second) */
-  double getUsage();
+  double get_usage();
 
-  /** @brief Check if the Link is used */
-  bool isUsed();
+  /** @brief Check if the Link is used (at least one flow uses the link) */
+  bool is_used();
 
-  void turnOn();
-  void turnOff();
+  void turn_on();
+  void turn_off();
 
-  void* getData();
-  void setData(void* d);
+  void* get_data(); /** Should be used only from the C interface. Prefer extensions in C++ */
+  void set_data(void* d);
 
-  void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain
-                                             boolean values. */
-  void setBandwidthTrace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to
+  void set_state_trace(tmgr_trace_t trace);     /*< setup the trace file with states events (ON or OFF). Trace must contain
+                                                  boolean values. */
+  void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to
                                                   external load). Trace must contain percentages (value between 0 and 1). */
-  void setLatencyTrace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to
-                                               external load). Trace must contain absolute values */
+  void set_latency_trace(tmgr_trace_t trace);   /*< setup the trace file with latency events (peak latency changes due to
+                                                  external load). Trace must contain absolute values */
 
-  const char* getProperty(const char* key);
-  void setProperty(std::string key, std::string value);
+  const char* get_property(const char* key);
+  void set_property(std::string key, std::string value);
 
   /* The signals */
   /** @brief Callback signal fired when a new Link is created */
@@ -95,7 +90,29 @@ public:
   /** @brief Callback signal fired when a communication changes it state (ready/done/cancel) */
   static simgrid::xbt::signal<void(kernel::resource::NetworkAction*)> on_communication_state_change;
 
+  // Deprecated methods
   XBT_ATTRIB_DEPRECATED_v321("Use get_cname(): v3.21 will turn this warning into an error.") const char* name();
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::by_name()") static Link* byName(const char* name) { return by_name(name); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_name()") const std::string& getName() const { return get_name(); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_cname()") const char* getCname() const { return get_cname(); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_sharing_policy()") SharingPolicy sharingPolicy() {return get_sharing_policy();}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_usage()") double getUsage() {return get_usage();}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::is_used()") bool isUsed() {return is_used();}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_bandwidth()") double bandwidth() {return get_bandwidth();}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_latency()") double latency() {return get_latency();}
+
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::turn_on()") void turnOn() {turn_on();}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::turn_off()") void turnOff() {turn_off();}
+
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_property()") const char* getProperty(const char* key) {return get_property(key);}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::set_property()") void setProperty(std::string key, std::string value) {set_property(key, value);}
+
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_data()") void* getData() {return get_data();}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::set_data()") void setData(void* d) {set_data(d);}
+
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_state_trace()") void setStateTrace(tmgr_trace_t trace) {set_state_trace(trace);}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_bandwidth_trace()") void setBandwidthTrace(tmgr_trace_t trace) {set_bandwidth_trace(trace);}
+  XBT_ATTRIB_DEPRECATED_v323("Please use Link::get_latency_trace()") void setLatencyTrace(tmgr_trace_t trace) {set_latency_trace(trace);}
 };
 }
 }
index 6eff605..5911db5 100644 (file)
@@ -199,10 +199,10 @@ static void instr_link_on_creation(simgrid::s4u::Link& link)
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
     simgrid::instr::VariableType* bandwidth = container->type_->by_name_or_create("bandwidth", "");
     bandwidth->set_calling_container(container);
-    bandwidth->set_event(0, link.bandwidth());
+    bandwidth->set_event(0, link.get_bandwidth());
     simgrid::instr::VariableType* latency = container->type_->by_name_or_create("latency", "");
     latency->set_calling_container(container);
-    latency->set_event(0, link.latency());
+    latency->set_event(0, link.get_latency());
   }
   if (TRACE_uncategorized()) {
     container->type_->by_name_or_create("bandwidth_used", "0.5 0.5 0.5");
@@ -264,7 +264,7 @@ static void instr_link_on_bandwidth_change(simgrid::s4u::Link& link)
 {
   simgrid::instr::Container::by_name(link.get_cname())
       ->get_variable("bandwidth")
-      ->set_event(surf_get_clock(), sg_bandwidth_factor * link.bandwidth());
+      ->set_event(surf_get_clock(), sg_bandwidth_factor * link.get_bandwidth());
 }
 
 static void instr_netpoint_on_creation(simgrid::kernel::routing::NetPoint* netpoint)
index a9a58c0..17f9d90 100644 (file)
@@ -561,7 +561,7 @@ double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
   std::vector<simgrid::s4u::Link*> vlinks;
   from->routeTo(to, vlinks, nullptr);
   for (auto const& link : vlinks) {
-    double bandwidth = link->bandwidth();
+    double bandwidth = link->get_bandwidth();
     if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
       min_bandwidth = bandwidth;
   }
index 954969d..a3b44a6 100644 (file)
@@ -43,67 +43,67 @@ const char* Link::name()
 {
   return get_cname();
 }
-bool Link::isUsed()
+bool Link::is_used()
 {
   return this->pimpl_->is_used();
 }
 
-double Link::latency()
+double Link::get_latency()
 {
   return this->pimpl_->latency();
 }
 
-double Link::bandwidth()
+double Link::get_bandwidth()
 {
   return this->pimpl_->bandwidth();
 }
 
-Link::SharingPolicy Link::sharingPolicy()
+Link::SharingPolicy Link::get_sharing_policy()
 {
   return this->pimpl_->sharingPolicy();
 }
 
-double Link::getUsage()
+double Link::get_usage()
 {
   return this->pimpl_->get_constraint()->get_usage();
 }
 
-void Link::turnOn()
+void Link::turn_on()
 {
   simgrid::simix::simcall([this]() { this->pimpl_->turn_on(); });
 }
-void Link::turnOff()
+void Link::turn_off()
 {
   simgrid::simix::simcall([this]() { this->pimpl_->turn_off(); });
 }
 
-void* Link::getData()
+void* Link::get_data()
 {
   return this->pimpl_->getData();
 }
-void Link::setData(void* d)
+void Link::set_data(void* d)
 {
   simgrid::simix::simcall([this, d]() { this->pimpl_->setData(d); });
 }
 
-void Link::setStateTrace(tmgr_trace_t trace)
+void Link::set_state_trace(tmgr_trace_t trace)
 {
   simgrid::simix::simcall([this, trace]() { this->pimpl_->setStateTrace(trace); });
 }
-void Link::setBandwidthTrace(tmgr_trace_t trace)
+void Link::set_bandwidth_trace(tmgr_trace_t trace)
 {
   simgrid::simix::simcall([this, trace]() { this->pimpl_->setBandwidthTrace(trace); });
 }
-void Link::setLatencyTrace(tmgr_trace_t trace)
+void Link::set_latency_trace(tmgr_trace_t trace)
 {
   simgrid::simix::simcall([this, trace]() { this->pimpl_->setLatencyTrace(trace); });
 }
 
-const char* Link::getProperty(const char* key)
+const char* Link::get_property(const char* key)
 {
   return this->pimpl_->getProperty(key);
 }
-void Link::setProperty(std::string key, std::string value)
+void Link::set_property(std::string key, std::string value)
 {
   simgrid::simix::simcall([this, key, value] { this->pimpl_->setProperty(key, value); });
 }
@@ -123,23 +123,23 @@ sg_link_t sg_link_by_name(const char* name)
 
 int sg_link_is_shared(sg_link_t link)
 {
-  return (int)link->sharingPolicy();
+  return (int)link->get_sharing_policy();
 }
 double sg_link_bandwidth(sg_link_t link)
 {
-  return link->bandwidth();
+  return link->get_bandwidth();
 }
 double sg_link_latency(sg_link_t link)
 {
-  return link->latency();
+  return link->get_latency();
 }
 void* sg_link_data(sg_link_t link)
 {
-  return link->getData();
+  return link->get_data();
 }
 void sg_link_data_set(sg_link_t link, void* data)
 {
-  link->setData(data);
+  link->set_data(data);
 }
 int sg_link_count()
 {
index bce16c3..3f28eb8 100644 (file)
@@ -88,7 +88,7 @@ void LinkEnergy::initWattsRangeList()
     return;
   inited_ = true;
 
-  const char* all_power_values_str = this->link_->getProperty("watt_range");
+  const char* all_power_values_str = this->link_->get_property("watt_range");
 
   if (all_power_values_str == nullptr)
     return;
@@ -126,7 +126,7 @@ double LinkEnergy::getPower()
 
   double power_slope = busy_ - idle_;
 
-  double normalized_link_usage = link_->getUsage() / link_->bandwidth();
+  double normalized_link_usage = link_->get_usage() / link_->get_bandwidth();
   double dynamic_power         = power_slope * normalized_link_usage;
 
   return idle_ + dynamic_power;
index 0524b4d..460bba8 100644 (file)
@@ -129,7 +129,7 @@ void parse_platform_file(const char *file)
 
     sg_link_t link = simgrid::s4u::Link::by_name(elm.second.c_str());
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
-    link->setStateTrace(trace);
+    link->set_state_trace(trace);
   }
 
   for (auto const& elm : trace_connect_list_link_bw) {
@@ -137,7 +137,7 @@ void parse_platform_file(const char *file)
     tmgr_trace_t trace = traces_set_list.at(elm.first);
     sg_link_t link     = simgrid::s4u::Link::by_name(elm.second.c_str());
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
-    link->setBandwidthTrace(trace);
+    link->set_bandwidth_trace(trace);
   }
 
   for (auto const& elm : trace_connect_list_link_lat) {
@@ -145,7 +145,7 @@ void parse_platform_file(const char *file)
     tmgr_trace_t trace = traces_set_list.at(elm.first);
     sg_link_t link     = simgrid::s4u::Link::by_name(elm.second.c_str());
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
-    link->setLatencyTrace(trace);
+    link->set_latency_trace(trace);
   }
 
   surf_parse_close();
index 11e6ce7..b7bf33b 100644 (file)
@@ -84,7 +84,7 @@ static void dump_links()
     simgrid::s4u::Link* link = links[i];
     std::printf("  <link id=\"");
 
-    std::printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", link->get_cname(), link->bandwidth(), link->latency());
+    std::printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", link->get_cname(), link->get_bandwidth(), link->get_latency());
     if (sg_link_is_shared(link)) {
       std::printf("/>\n");
     } else {