From: Arnaud Giersch Date: Wed, 13 Feb 2019 11:08:49 +0000 (+0100) Subject: Change some calls to get_cname to calls to get_name. X-Git-Tag: v3_22~329 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/026c5a576fbea1da8f6290f4435d5424ce0efe8b?hp=d07491b881cc0dd542507d598e1099f178b79c59 Change some calls to get_cname to calls to get_name. --- diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 244c9d5474..e648aeb3dc 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -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"); diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index 196d1a62be..74e444bd03 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -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::mapget_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); } } diff --git a/src/instr/jedule/jedule_platform.cpp b/src/instr/jedule/jedule_platform.cpp index ad4e515f8c..a228b90dbd 100644 --- a/src/instr/jedule/jedule_platform.cpp +++ b/src/instr/jedule/jedule_platform.cpp @@ -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); } diff --git a/src/instr/jedule/jedule_sd_binding.cpp b/src/instr/jedule/jedule_sd_binding.cpp index 6da15be53b..1541655160 100644 --- a/src/instr/jedule/jedule_sd_binding.cpp +++ b/src/instr/jedule/jedule_sd_binding.cpp @@ -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; } diff --git a/src/kernel/context/Context.cpp b/src/kernel/context/Context.cpp index 5831381222..0cca7b8656 100644 --- a/src/kernel/context/Context.cpp +++ b/src/kernel/context/Context.cpp @@ -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 diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index 5c52d31e6c..fa1c3b8353 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -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 ************************************/ diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 7a0411540f..968e885979 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -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 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 m_host_list = {Host::current(), host}; diff --git a/src/plugins/link_energy.cpp b/src/plugins/link_energy.cpp index 98c5300874..5e27abd95c 100644 --- a/src/plugins/link_energy.cpp +++ b/src/plugins/link_energy.cpp @@ -197,7 +197,7 @@ void sg_link_energy_plugin_init() simgrid::s4u::Link::on_state_change.connect([](simgrid::s4u::Link& link) { link.extension()->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()->get_consumed_energy()); }); diff --git a/src/plugins/vm/VmLiveMigration.cpp b/src/plugins/vm/VmLiveMigration.cpp index 209ec15631..c6b78817ab 100644 --- a/src/plugins/vm/VmLiveMigration.cpp +++ b/src/plugins/vm/VmLiveMigration.cpp @@ -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()); diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 95002eda7b..572ee4ada9 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -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(pa))->get_cname(), - (*static_cast(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(pa))->get_name(); + const std::string& nb = (*static_cast(pb))->get_name(); + return na.compare(nb); + }); return res; } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 6d0d347495..57dc7a134e 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -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); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 2056a852bc..cb24df2b63 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -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()); }); }