Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change some calls to get_cname to calls to get_name.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 13 Feb 2019 11:08:49 +0000 (12:08 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 13 Feb 2019 16:51:16 +0000 (17:51 +0100)
12 files changed:
src/instr/instr_paje_containers.cpp
src/instr/instr_platform.cpp
src/instr/jedule/jedule_platform.cpp
src/instr/jedule/jedule_sd_binding.cpp
src/kernel/context/Context.cpp
src/msg/msg_process.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/link_energy.cpp
src/plugins/vm/VmLiveMigration.cpp
src/s4u/s4u_Host.cpp
src/simix/ActorImpl.cpp
src/simix/smx_global.cpp

index 244c9d5..e648aeb 100644 (file)
@@ -60,7 +60,7 @@ RouterContainer::RouterContainer(std::string name, Container* father)
 }
 
 HostContainer::HostContainer(simgrid::s4u::Host& host, NetZoneContainer* father)
-    : Container::Container(host.get_cname(), "HOST", father)
+    : Container::Container(host.get_name(), "HOST", father)
 {
   xbt_assert(father, "Only the Root container has no father");
 
index 196d1a6..74e444b 100644 (file)
@@ -132,7 +132,7 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t
   if (not netzone->get_children().empty()) {
     // bottom-up recursion
     for (auto const& nz_son : netzone->get_children()) {
-      container_t child_container = container->children_.at(nz_son->get_cname());
+      container_t child_container = container->children_.at(nz_son->get_name());
       recursiveGraphExtraction(nz_son, child_container, filter);
     }
   }
@@ -234,7 +234,7 @@ static void instr_host_on_creation(simgrid::s4u::Host& host)
 
 static void instr_host_on_speed_change(simgrid::s4u::Host& host)
 {
-  simgrid::instr::Container::by_name(host.get_cname())
+  simgrid::instr::Container::by_name(host.get_name())
       ->get_variable("speed")
       ->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed());
 }
@@ -265,7 +265,7 @@ static void instr_action_on_state_change(simgrid::kernel::resource::Action* acti
 
 static void instr_link_on_bandwidth_change(simgrid::s4u::Link& link)
 {
-  simgrid::instr::Container::by_name(link.get_cname())
+  simgrid::instr::Container::by_name(link.get_name())
       ->get_variable("bandwidth")
       ->set_event(surf_get_clock(), sg_bandwidth_factor * link.get_bandwidth());
 }
@@ -273,7 +273,7 @@ static void instr_link_on_bandwidth_change(simgrid::s4u::Link& link)
 static void instr_netpoint_on_creation(simgrid::kernel::routing::NetPoint* netpoint)
 {
   if (netpoint->is_router())
-    new simgrid::instr::RouterContainer(netpoint->get_cname(), currentContainer.back());
+    new simgrid::instr::RouterContainer(netpoint->get_name(), currentContainer.back());
 }
 
 static void instr_on_platform_created()
@@ -504,7 +504,7 @@ static void recursiveXBTGraphExtraction(xbt_graph_t graph, std::map<std::string,
   if (not netzone->get_children().empty()) {
     // bottom-up recursion
     for (auto const& netzone_child : netzone->get_children()) {
-      container_t child_container = container->children_.at(netzone_child->get_cname());
+      container_t child_container = container->children_.at(netzone_child->get_name());
       recursiveXBTGraphExtraction(graph, nodes, edges, netzone_child, child_container);
     }
   }
index ad4e515..a228b90 100644 (file)
@@ -68,7 +68,7 @@ void Container::create_hierarchy(sg_netzone_t from_as)
     this->add_resources(table);
   } else {
     for (auto const& nz : from_as->get_children()) {
-      jed_container_t child_container = new simgrid::jedule::Container(std::string(nz->get_cname()));
+      jed_container_t child_container = new simgrid::jedule::Container(nz->get_name());
       this->add_child(child_container);
       child_container->create_hierarchy(nz);
     }
index 6da15be..1541655 100644 (file)
@@ -33,7 +33,7 @@ void jedule_sd_init()
 
   my_jedule = new simgrid::jedule::Jedule();
 
-  jed_container_t root_container = new simgrid::jedule::Container(std::string(root_comp->get_cname()));
+  jed_container_t root_container = new simgrid::jedule::Container(root_comp->get_name());
   root_container->create_hierarchy(root_comp);
   my_jedule->root_container_ = root_container;
 }
index 5831381..0cca7b8 100644 (file)
@@ -89,7 +89,7 @@ void Context::stop()
   if (actor_->auto_restart_ && not actor_->host_->is_on()) {
     XBT_DEBUG("Insert host %s to watched_hosts because it's off and %s needs to restart", actor_->host_->get_cname(),
               actor_->get_cname());
-    watched_hosts.insert(actor_->host_->get_cname());
+    watched_hosts.insert(actor_->host_->get_name());
   }
 
   // Execute the termination callbacks
index 5c52d31..fa1c3b8 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, "Logging specific to MSG (proc
 
 std::string instr_pid(msg_process_t proc)
 {
-  return std::string(proc->get_cname()) + "-" + std::to_string(proc->get_pid());
+  return std::string(proc->get_name()) + "-" + std::to_string(proc->get_pid());
 }
 
 /******************************** Process ************************************/
index 7a04115..968e885 100644 (file)
@@ -102,7 +102,7 @@ sg_size_t File::read(sg_size_t size)
   sg_size_t read_size = local_storage_->read(std::min(size, size_ - current_position_));
   current_position_ += read_size;
 
-  if (strcmp(host->get_cname(), Host::current()->get_cname())) {
+  if (host->get_name() != Host::current()->get_name()) {
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
     XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), read_size);
     std::vector<Host*> m_host_list   = {Host::current(), host};
@@ -128,7 +128,7 @@ sg_size_t File::write(sg_size_t size)
   /* Find the host where the file is physically located (remote or local)*/
   Host* host = local_storage_->get_host();
 
-  if (strcmp(host->get_cname(), Host::current()->get_cname())) {
+  if (host->get_name() != Host::current()->get_name()) {
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
     XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
     std::vector<Host*> m_host_list   = {Host::current(), host};
index 98c5300..5e27abd 100644 (file)
@@ -197,7 +197,7 @@ void sg_link_energy_plugin_init()
   simgrid::s4u::Link::on_state_change.connect([](simgrid::s4u::Link& link) { link.extension<LinkEnergy>()->update(); });
 
   simgrid::s4u::Link::on_destruction.connect([](simgrid::s4u::Link& link) {
-    if (strcmp(link.get_cname(), "__loopback__"))
+    if (link.get_name() != "__loopback__")
       XBT_INFO("Energy consumption of link '%s': %f Joules", link.get_cname(),
                link.extension<LinkEnergy>()->get_consumed_energy());
   });
index 209ec15..c6b7881 100644 (file)
@@ -66,7 +66,7 @@ void MigrationRx::operator()()
     simgrid::instr::Container::by_name(vm_->get_name())->remove_from_parent();
 
     // create new container on the new_host location
-    new simgrid::instr::Container(vm_->get_cname(), "VM", simgrid::instr::Container::by_name(dst_pm_->get_name()));
+    new simgrid::instr::Container(vm_->get_name(), "VM", simgrid::instr::Container::by_name(dst_pm_->get_name()));
 
     // end link
     msg = simgrid::instr::Container::by_name(vm_->get_name());
index 95002ed..572ee4a 100644 (file)
@@ -366,12 +366,6 @@ sg_host_t sg_host_by_name(const char* name)
   return simgrid::s4u::Host::by_name_or_null(name);
 }
 
-static int hostcmp_voidp(const void* pa, const void* pb)
-{
-  return strcmp((*static_cast<simgrid::s4u::Host* const*>(pa))->get_cname(),
-                (*static_cast<simgrid::s4u::Host* const*>(pb))->get_cname());
-}
-
 xbt_dynar_t sg_hosts_as_dynar()
 {
   xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr);
@@ -382,7 +376,11 @@ xbt_dynar_t sg_hosts_as_dynar()
     if (host && host->pimpl_netpoint && host->pimpl_netpoint->is_host())
       xbt_dynar_push(res, &host);
   }
-  xbt_dynar_sort(res, hostcmp_voidp);
+  xbt_dynar_sort(res, [](const void* pa, const void* pb) {
+    const std::string& na = (*static_cast<simgrid::s4u::Host* const*>(pa))->get_name();
+    const std::string& nb = (*static_cast<simgrid::s4u::Host* const*>(pb))->get_name();
+    return na.compare(nb);
+  });
   return res;
 }
 
index 6d0d347..57dc7a1 100644 (file)
@@ -295,7 +295,7 @@ smx_activity_t ActorImpl::sleep(double duration)
 {
   if (not host_->is_on())
     throw_exception(std::make_exception_ptr(simgrid::HostFailureException(
-        XBT_THROW_POINT, std::string("Host ") + std::string(host_->get_cname()) + " failed, you cannot sleep there.")));
+        XBT_THROW_POINT, std::string("Host ") + host_->get_cname() + " failed, you cannot sleep there.")));
 
   return simgrid::kernel::activity::SleepImplPtr(new simgrid::kernel::activity::SleepImpl("sleep", host_))
       ->start(duration);
index 2056a85..cb24df2 100644 (file)
@@ -195,7 +195,7 @@ void SIMIX_global_init(int *argc, char **argv)
     simgrid::s4u::on_platform_created.connect(surf_presolve);
 
     simgrid::s4u::Storage::on_creation.connect([](simgrid::s4u::Storage& storage) {
-      sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_cname());
+      sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_name());
       xbt_assert(s != nullptr, "Storage not found for name %s", storage.get_cname());
     });
   }