Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Emit a warning when a link's latency is smaller than surf/precision.
[simgrid.git] / src / surf / sg_platf.cpp
index 5b3db61..8f89621 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -67,7 +67,7 @@ void sg_platf_exit() {
 }
 
 /** @brief Add a host to the current AS */
-void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
+void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
 {
   std::map<std::string, std::string> props;
   if (args->properties) {
@@ -79,12 +79,10 @@ void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
   simgrid::s4u::Host* host =
       routing_get_current()->create_host(args->id, args->speed_per_pstate, args->core_amount, &props);
 
-  host->pimpl_->storage_ = mount_list;
+  host->pimpl_->set_storages(mount_list);
   mount_list.clear();
 
-  host->pimpl_->disks_ = std::move(args->disks);
-  for (auto d : host->pimpl_->disks_)
-    d->set_host(host);
+  host->pimpl_->set_disks(args->disks, host);
 
   /* Change from the defaults */
   if (args->state_trace)
@@ -118,6 +116,13 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name,
 
 static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name)
 {
+  static double last_warned_latency = sg_surf_precision;
+  if (link->latency != 0.0 && link->latency < last_warned_latency) {
+    XBT_WARN("Latency for link %s is smaller than surf/precision (%g < %g)."
+             " For more accuracy, consider setting \"--cfg=surf/precision:%g\".",
+             link_name.c_str(), link->latency, sg_surf_precision, link->latency);
+    last_warned_latency = link->latency;
+  }
   simgrid::kernel::resource::LinkImpl* l =
       surf_network_model->create_link(link_name, link->bandwidths, link->latency, link->policy);