Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 15 Nov 2016 22:35:26 +0000 (23:35 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 15 Nov 2016 22:35:26 +0000 (23:35 +0100)
34 files changed:
ChangeLog
src/kernel/routing/AsDijkstra.cpp
src/kernel/routing/AsFloyd.cpp
src/kernel/routing/AsFull.cpp
src/kernel/routing/AsImpl.cpp
src/kernel/routing/AsImpl.hpp
src/s4u/s4u_VirtualMachine.cpp
src/simix/smx_vm.cpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/PropertyHolder.cpp
src/surf/PropertyHolder.hpp
src/surf/VirtualMachineImpl.cpp
src/surf/VirtualMachineImpl.hpp
src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_constant.cpp
src/surf/network_constant.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_ns3.cpp
src/surf/network_ns3.hpp
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp
src/surf/sg_platf.cpp
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
tools/cmake/Modules/FindNS3.cmake

index 0970f49..2d50884 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,9 @@ SimGrid (3.14) UNRELEASED; urgency=low
  * smpi/cpu-threshold:-1 should become smpi/simulate-computation:no
    smpi/running-power    is renamed to smpi/host-speed
 
+ New functions and features
+ * MSG_parallel_task_execute_with_timeout, to timeout computations.
+
  Dropped / renamed functions and features
  * msg_mailbox_t and associated functions. Use s4u::Mailbox instead.
    - MSG_mailbox_is_empty() -> Mailbox::empty()
index 02106e6..cf697f0 100644 (file)
@@ -51,7 +51,7 @@ void AsDijkstra::seal()
     graphNodeMap_ = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
 
   /* Add the loopback if needed */
-  if (routing_platf->loopback_ && hierarchy_ == RoutingMode::base) {
+  if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
     xbt_dynar_foreach(xbt_graph_get_nodes(routeGraph_), cursor, node) {
       xbt_edge_t edge = nullptr;
 
@@ -66,7 +66,7 @@ void AsDijkstra::seal()
       if (!found) {
         sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
         e_route->link_list = new std::vector<Link*>();
-        e_route->link_list->push_back(routing_platf->loopback_);
+        e_route->link_list->push_back(surf_network_model->loopback_);
         xbt_graph_new_edge(routeGraph_, node, node, e_route);
       }
     }
index 2b5d921..6aa1816 100644 (file)
@@ -170,7 +170,7 @@ void AsFloyd::seal(){
   }
 
   /* Add the loopback if needed */
-  if (routing_platf->loopback_ && hierarchy_ == RoutingMode::base) {
+  if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
     for (unsigned int i = 0; i < table_size; i++) {
       sg_platf_route_cbarg_t e_route = TO_FLOYD_LINK(i, i);
       if (!e_route) {
@@ -178,7 +178,7 @@ void AsFloyd::seal(){
         e_route->gw_src = nullptr;
         e_route->gw_dst = nullptr;
         e_route->link_list = new std::vector<Link*>();
-        e_route->link_list->push_back(routing_platf->loopback_);
+        e_route->link_list->push_back(surf_network_model->loopback_);
         TO_FLOYD_LINK(i, i) = e_route;
         TO_FLOYD_PRED(i, i) = i;
         TO_FLOYD_COST(i, i) = 1;
index 24960df..62df1a6 100644 (file)
@@ -29,7 +29,7 @@ void AsFull::seal() {
     routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
 
   /* Add the loopback if needed */
-  if (routing_platf->loopback_ && hierarchy_ == RoutingMode::base) {
+  if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
     for (i = 0; i < table_size; i++) {
       e_route = TO_ROUTE_FULL(i, i);
       if (!e_route) {
@@ -37,7 +37,7 @@ void AsFull::seal() {
         e_route->gw_src = nullptr;
         e_route->gw_dst = nullptr;
         e_route->link_list = new std::vector<Link*>();
-        e_route->link_list->push_back(routing_platf->loopback_);
+        e_route->link_list->push_back(surf_network_model->loopback_);
         TO_ROUTE_FULL(i, i) = e_route;
       }
     }
index 67e292f..3bd9c9e 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "simgrid/s4u/host.hpp"
 #include "src/kernel/routing/AsImpl.hpp"
+#include "src/surf/cpu_interface.hpp"
 #include "src/surf/network_interface.hpp" // Link FIXME: move to proper header
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(AsImpl,surf, "Implementation of S4U autonomous systems");
@@ -26,12 +27,18 @@ namespace simgrid {
   }
   AsImpl::~AsImpl() = default;
 
-  void AsImpl::attachHost(s4u::Host* host)
+  simgrid::s4u::Host* AsImpl::createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount)
   {
+    simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
+
     if (hierarchy_ == RoutingMode::unset)
       hierarchy_ = RoutingMode::base;
 
-    host->pimpl_netcard = new NetCardImpl(host->name().c_str(), NetCard::Type::Host, this);
+    res->pimpl_netcard = new NetCardImpl(name, NetCard::Type::Host, this);
+
+    surf_cpu_model_pm->createCpu(res, speedPerPstate, coreAmount);
+
+    return res;
   }
 
   xbt_dynar_t AsImpl::getOneLinkRoutes()
index 700f067..8530695 100644 (file)
@@ -30,8 +30,8 @@ protected:
   ~AsImpl() override;
   
 public:
-  /** @brief attach the given host to that AS */
-  void attachHost(s4u::Host * host);
+  /** @brief Make an host within that AS */
+  simgrid::s4u::Host* createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount);
 
   /**
    * @brief Probe the routing path between two points
index 1b3872c..8a8e190 100644 (file)
@@ -12,7 +12,6 @@
 #include "xbt/asserts.h"
 
 namespace simgrid {
-
 namespace s4u {
 
 VirtualMachine::VirtualMachine(const char* name, s4u::Host* Pm) : Host(name)
@@ -25,14 +24,16 @@ VirtualMachine::~VirtualMachine()
   onDestruction(*this);
 }
 
+/** @brief Retrieve a copy of the parameters of that VM/PM
+ *  @details The ramsize and overcommit fields are used on the PM too */
 void VirtualMachine::parameters(vm_params_t params)
 {
-  this->pimpl_->getParams(params);
+  static_cast<surf::VirtualMachineImpl*>(pimpl_)->getParams(params);
 }
-
+/** @brief Sets the params of that VM/PM */
 void VirtualMachine::setParameters(vm_params_t params)
 {
-  simgrid::simix::kernelImmediate([&]() { this->pimpl_->setParams(params); });
+  simgrid::simix::kernelImmediate([&]() { static_cast<surf::VirtualMachineImpl*>(pimpl_)->setParams(params); });
 }
 
 } // namespace simgrid
index 002be82..2866042 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "mc/mc.h"
+#include "simgrid/s4u/VirtualMachine.hpp"
 #include "smx_private.h"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/VirtualMachineImpl.hpp"
@@ -14,7 +15,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virt
 static long host_get_ramsize(sg_host_t vm, int *overcommit)
 {
   s_vm_params_t params;
-  vm->pimpl_->getParams(&params);
+  static_cast<simgrid::s4u::VirtualMachine*>(vm)->parameters(&params);
 
   if (overcommit)
     *overcommit = params.overcommit;
index 3fd06eb..2943b4d 100644 (file)
@@ -62,17 +62,13 @@ Action* HostModel::executeParallelTask(int host_nb, simgrid::s4u::Host** host_li
                                        double* bytes_amount, double rate)
 {
 #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
-  Action *action =nullptr;
-  if ((host_nb == 1)
-      && (cost_or_zero(bytes_amount, 0) == 0.0)){
+  Action* action = nullptr;
+  if ((host_nb == 1) && (cost_or_zero(bytes_amount, 0) == 0.0)) {
     action = host_list[0]->pimpl_cpu->execution_start(flops_amount[0]);
-  } else if ((host_nb == 1)
-           && (cost_or_zero(flops_amount, 0) == 0.0)) {
+  } else if ((host_nb == 1) && (cost_or_zero(flops_amount, 0) == 0.0)) {
     action = surf_network_model->communicate(host_list[0], host_list[0], bytes_amount[0], rate);
-  } else if ((host_nb == 2)
-             && (cost_or_zero(flops_amount, 0) == 0.0)
-             && (cost_or_zero(flops_amount, 1) == 0.0)) {
-    int i,nb = 0;
+  } else if ((host_nb == 2) && (cost_or_zero(flops_amount, 0) == 0.0) && (cost_or_zero(flops_amount, 1) == 0.0)) {
+    int i, nb = 0;
     double value = 0.0;
 
     for (i = 0; i < host_nb * host_nb; i++) {
@@ -84,12 +80,16 @@ Action* HostModel::executeParallelTask(int host_nb, simgrid::s4u::Host** host_li
     if (nb == 1) {
       action = surf_network_model->communicate(host_list[0], host_list[1], value, rate);
     } else if (nb == 0) {
-       xbt_die("Cannot have a communication with no flop to exchange in this model. You should consider using the ptask model");
-    } else {       
-       xbt_die("Cannot have a communication that is not a simple point-to-point in this model. You should consider using the ptask model");
+      xbt_die("Cannot have a communication with no flop to exchange in this model. You should consider using the "
+              "ptask model");
+    } else {
+      xbt_die("Cannot have a communication that is not a simple point-to-point in this model. You should consider "
+              "using the ptask model");
     }
-  } else 
-    xbt_die("This model only accepts one of the following. You should consider using the ptask model for the other cases.\n - execution with one host only and no communication\n - Self-comms with one host only\n - Communications with two hosts and no computation");
+  } else
+    xbt_die("This model only accepts one of the following. You should consider using the ptask model for the other "
+            "cases.\n - execution with one host only and no communication\n - Self-comms with one host only\n - "
+            "Communications with two hosts and no computation");
 #undef cost_or_zero
   xbt_free(host_list);
   return action;
@@ -98,30 +98,29 @@ Action* HostModel::executeParallelTask(int host_nb, simgrid::s4u::Host** host_li
 /************
  * Resource *
  ************/
-HostImpl::HostImpl(s4u::Host* host, xbt_dynar_t storage) : PropertyHolder(nullptr), storage_(storage), piface_(host)
+HostImpl::HostImpl(s4u::Host* host, xbt_dynar_t storage) : storage_(storage), piface_(host)
 {
   piface_->pimpl_ = this;
-  params_.ramsize = 0;
 }
 
 /** @brief use destroy() instead of this destructor */
 HostImpl::~HostImpl() = default;
 
-simgrid::surf::Storage *HostImpl::findStorageOnMountList(const char* mount)
+simgrid::surf::StorageHostImpl::findStorageOnMountList(const char* mount)
 {
-  simgrid::surf::Storage *st = nullptr;
+  simgrid::surf::Storagest = nullptr;
   s_mount_t mnt;
   unsigned int cursor;
 
   XBT_DEBUG("Search for storage name '%s' on '%s'", mount, piface_->name().c_str());
-  xbt_dynar_foreach(storage_,cursor,mnt){
-    XBT_DEBUG("See '%s'",mnt.name);
-    if(!strcmp(mount,mnt.name)){
+  xbt_dynar_foreach (storage_, cursor, mnt) {
+    XBT_DEBUG("See '%s'", mnt.name);
+    if (!strcmp(mount, mnt.name)) {
       st = static_cast<simgrid::surf::Storage*>(mnt.storage);
       break;
     }
   }
-  if(!st)
+  if (!st)
     xbt_die("Can't find mount '%s' for '%s'", mount, piface_->name().c_str());
   return st;
 }
@@ -131,11 +130,11 @@ xbt_dict_t HostImpl::getMountedStorageList()
   s_mount_t mnt;
   unsigned int i;
   xbt_dict_t storage_list = xbt_dict_new_homogeneous(nullptr);
-  char *storage_name = nullptr;
+  char* storage_name      = nullptr;
 
-  xbt_dynar_foreach(storage_,i,mnt){
-    storage_name = (char *)static_cast<simgrid::surf::Storage*>(mnt.storage)->getName();
-    xbt_dict_set(storage_list,mnt.name,storage_name,nullptr);
+  xbt_dynar_foreach (storage_, i, mnt) {
+    storage_name = (char*)static_cast<simgrid::surf::Storage*>(mnt.storage)->getName();
+    xbt_dict_set(storage_list, mnt.name, storage_name, nullptr);
   }
   return storage_list;
 }
@@ -143,201 +142,192 @@ xbt_dict_t HostImpl::getMountedStorageList()
 xbt_dynar_t HostImpl::getAttachedStorageList()
 {
   xbt_lib_cursor_t cursor;
-  char *key;
-  void **data;
+  charkey;
+  void** data;
   xbt_dynar_t result = xbt_dynar_new(sizeof(void*), nullptr);
-  xbt_lib_foreach(storage_lib, cursor, key, data) {
+  xbt_lib_foreach(storage_lib, cursor, key, data)
+  {
     if (xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) {
       simgrid::surf::Storage* storage = static_cast<simgrid::surf::Storage*>(
           xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
       if (!strcmp((const char*)storage->attach_, piface_->name().c_str())) {
         xbt_dynar_push_as(result, void*, (void*)storage->getName());
       }
-  }
+    }
   }
   return result;
-}
-
-Action *HostImpl::open(const char* fullpath) {
-
-  simgrid::surf::Storage *st = nullptr;
-  s_mount_t mnt;
-  unsigned int cursor;
-  size_t longest_prefix_length = 0;
-  char *path = nullptr;
-  char *file_mount_name = nullptr;
-  char *mount_name = nullptr;
-
-  XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath, piface_->name().c_str());
-  xbt_dynar_foreach(storage_,cursor,mnt)
-  {
-    XBT_DEBUG("See '%s'",mnt.name);
-    file_mount_name = (char *) xbt_malloc ((strlen(mnt.name)+1));
-    strncpy(file_mount_name,fullpath,strlen(mnt.name)+1);
-    file_mount_name[strlen(mnt.name)] = '\0';
-
-    if(!strcmp(file_mount_name,mnt.name) && strlen(mnt.name)>longest_prefix_length)
-    {/* The current mount name is found in the full path and is bigger than the previous*/
-      longest_prefix_length = strlen(mnt.name);
-      st = static_cast<simgrid::surf::Storage*>(mnt.storage);
     }
-    free(file_mount_name);
-  }
-  if(longest_prefix_length>0)
-  { /* Mount point found, split fullpath into mount_name and path+filename*/
-  path = (char *) xbt_malloc ((strlen(fullpath)-longest_prefix_length+1));
-  mount_name = (char *) xbt_malloc ((longest_prefix_length+1));
-  strncpy(mount_name, fullpath, longest_prefix_length+1);
-  strncpy(path, fullpath+longest_prefix_length, strlen(fullpath)-longest_prefix_length+1);
-  path[strlen(fullpath)-longest_prefix_length] = '\0';
-  mount_name[longest_prefix_length] = '\0';
-  }
-  else
-    xbt_die("Can't find mount point for '%s' on '%s'", fullpath, piface_->name().c_str());
-
-  XBT_DEBUG("OPEN %s on disk '%s'",path, st->getName());
-  Action *action = st->open((const char*)mount_name, (const char*)path);
-  free((char*)path);
-  free((char*)mount_name);
-  return action;
-}
-
-Action *HostImpl::close(surf_file_t fd) {
-  simgrid::surf::Storage *st = findStorageOnMountList(fd->mount);
-  XBT_DEBUG("CLOSE %s on disk '%s'",fd->name, st->getName());
-  return st->close(fd);
-}
-
-Action *HostImpl::read(surf_file_t fd, sg_size_t size) {
-  simgrid::surf::Storage *st = findStorageOnMountList(fd->mount);
-  XBT_DEBUG("READ %s on disk '%s'",fd->name, st->getName());
-  return st->read(fd, size);
-}
-
-Action *HostImpl::write(surf_file_t fd, sg_size_t size) {
-  simgrid::surf::Storage *st = findStorageOnMountList(fd->mount);
-  XBT_DEBUG("WRITE %s on disk '%s'",fd->name, st->getName());
-  return st->write(fd, size);
-}
 
-int HostImpl::unlink(surf_file_t fd) {
-  if (!fd){
-    XBT_WARN("No such file descriptor. Impossible to unlink");
-    return -1;
-  } else {
-
-    simgrid::surf::Storage *st = findStorageOnMountList(fd->mount);
-    /* Check if the file is on this storage */
-    if (!xbt_dict_get_or_null(st->content_, fd->name)){
-      XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
-          st->getName());
-      return -1;
-    } else {
-      XBT_DEBUG("UNLINK %s on disk '%s'",fd->name, st->getName());
-      st->usedSize_ -= fd->size;
-
-      // Remove the file from storage
-      xbt_dict_remove(st->content_, fd->name);
+    Action* HostImpl::open(const char* fullpath)
+    {
+
+      simgrid::surf::Storage* st = nullptr;
+      s_mount_t mnt;
+      unsigned int cursor;
+      size_t longest_prefix_length = 0;
+      char* path                   = nullptr;
+      char* file_mount_name        = nullptr;
+      char* mount_name             = nullptr;
+
+      XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath, piface_->name().c_str());
+      xbt_dynar_foreach (storage_, cursor, mnt) {
+        XBT_DEBUG("See '%s'", mnt.name);
+        file_mount_name = (char*)xbt_malloc((strlen(mnt.name) + 1));
+        strncpy(file_mount_name, fullpath, strlen(mnt.name) + 1);
+        file_mount_name[strlen(mnt.name)] = '\0';
+
+        if (!strcmp(file_mount_name, mnt.name) &&
+            strlen(mnt.name) > longest_prefix_length) { /* The current mount name is found in the full path and is
+                                                           bigger than the previous*/
+          longest_prefix_length = strlen(mnt.name);
+          st                    = static_cast<simgrid::surf::Storage*>(mnt.storage);
+        }
+        free(file_mount_name);
+      }
+      if (longest_prefix_length > 0) { /* Mount point found, split fullpath into mount_name and path+filename*/
+        path       = (char*)xbt_malloc((strlen(fullpath) - longest_prefix_length + 1));
+        mount_name = (char*)xbt_malloc((longest_prefix_length + 1));
+        strncpy(mount_name, fullpath, longest_prefix_length + 1);
+        strncpy(path, fullpath + longest_prefix_length, strlen(fullpath) - longest_prefix_length + 1);
+        path[strlen(fullpath) - longest_prefix_length] = '\0';
+        mount_name[longest_prefix_length]              = '\0';
+      } else
+        xbt_die("Can't find mount point for '%s' on '%s'", fullpath, piface_->name().c_str());
+
+      XBT_DEBUG("OPEN %s on disk '%s'", path, st->getName());
+      Action* action = st->open((const char*)mount_name, (const char*)path);
+      free((char*)path);
+      free((char*)mount_name);
+      return action;
+    }
 
-      xbt_free(fd->name);
-      xbt_free(fd->mount);
-      xbt_free(fd);
-      return 0;
+    Action* HostImpl::close(surf_file_t fd)
+    {
+      simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
+      XBT_DEBUG("CLOSE %s on disk '%s'", fd->name, st->getName());
+      return st->close(fd);
     }
-  }
-}
 
-sg_size_t HostImpl::getSize(surf_file_t fd){
-  return fd->size;
-}
+    Action* HostImpl::read(surf_file_t fd, sg_size_t size)
+    {
+      simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
+      XBT_DEBUG("READ %s on disk '%s'", fd->name, st->getName());
+      return st->read(fd, size);
+    }
 
-xbt_dynar_t HostImpl::getInfo( surf_file_t fd)
-{
-  simgrid::surf::Storage *st = findStorageOnMountList(fd->mount);
-  sg_size_t *psize = xbt_new(sg_size_t, 1);
-  *psize = fd->size;
-  xbt_dynar_t info = xbt_dynar_new(sizeof(void*), nullptr);
-  xbt_dynar_push_as(info, sg_size_t *, psize);
-  xbt_dynar_push_as(info, void *, fd->mount);
-  xbt_dynar_push_as(info, void *, (void *)st->getName());
-  xbt_dynar_push_as(info, void *, st->typeId_);
-  xbt_dynar_push_as(info, void *, st->contentType_);
-
-  return info;
-}
+    Action* HostImpl::write(surf_file_t fd, sg_size_t size)
+    {
+      simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
+      XBT_DEBUG("WRITE %s on disk '%s'", fd->name, st->getName());
+      return st->write(fd, size);
+    }
 
-sg_size_t HostImpl::fileTell(surf_file_t fd){
-  return fd->current_position;
-}
+    int HostImpl::unlink(surf_file_t fd)
+    {
+      if (!fd) {
+        XBT_WARN("No such file descriptor. Impossible to unlink");
+        return -1;
+      } else {
+
+        simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
+        /* Check if the file is on this storage */
+        if (!xbt_dict_get_or_null(st->content_, fd->name)) {
+          XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name, st->getName());
+          return -1;
+        } else {
+          XBT_DEBUG("UNLINK %s on disk '%s'", fd->name, st->getName());
+          st->usedSize_ -= fd->size;
+
+          // Remove the file from storage
+          xbt_dict_remove(st->content_, fd->name);
+
+          xbt_free(fd->name);
+          xbt_free(fd->mount);
+          xbt_free(fd);
+          return 0;
+        }
+      }
+    }
 
-int HostImpl::fileSeek(surf_file_t fd, sg_offset_t offset, int origin){
-
-  switch (origin) {
-  case SEEK_SET:
-    fd->current_position = offset;
-    return 0;
-  case SEEK_CUR:
-    fd->current_position += offset;
-    return 0;
-  case SEEK_END:
-    fd->current_position = fd->size + offset;
-    return 0;
-  default:
-    return -1;
-  }
-}
+    sg_size_t HostImpl::getSize(surf_file_t fd)
+    {
+      return fd->size;
+    }
 
-int HostImpl::fileMove(surf_file_t fd, const char* fullpath){
-  /* Check if the new full path is on the same mount point */
-  if(!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
-    sg_size_t *psize, *new_psize;
-    psize = (sg_size_t*)
-        xbt_dict_get_or_null(findStorageOnMountList(fd->mount)->content_,
-                             fd->name);
-    new_psize = xbt_new(sg_size_t, 1);
-    *new_psize = *psize;
-    if (psize){// src file exists
-      xbt_dict_remove(findStorageOnMountList(fd->mount)->content_, fd->name);
-      char *path = (char *) xbt_malloc ((strlen(fullpath)-strlen(fd->mount)+1));
-      strncpy(path, fullpath+strlen(fd->mount),
-              strlen(fullpath)-strlen(fd->mount)+1);
-      xbt_dict_set(findStorageOnMountList(fd->mount)->content_, path,
-                   new_psize,nullptr);
-      XBT_DEBUG("Move file from %s to %s, size '%llu'",fd->name, fullpath, *psize);
-      free(path);
-      return 0;
-    } else {
-      XBT_WARN("File %s doesn't exist", fd->name);
-      return -1;
+    xbt_dynar_t HostImpl::getInfo(surf_file_t fd)
+    {
+      simgrid::surf::Storage* st = findStorageOnMountList(fd->mount);
+      sg_size_t* psize           = xbt_new(sg_size_t, 1);
+      *psize                     = fd->size;
+      xbt_dynar_t info           = xbt_dynar_new(sizeof(void*), nullptr);
+      xbt_dynar_push_as(info, sg_size_t*, psize);
+      xbt_dynar_push_as(info, void*, fd->mount);
+      xbt_dynar_push_as(info, void*, (void*)st->getName());
+      xbt_dynar_push_as(info, void*, st->typeId_);
+      xbt_dynar_push_as(info, void*, st->contentType_);
+
+      return info;
     }
-  } else {
-    XBT_WARN("New full path %s is not on the same mount point: %s. Action has been canceled.",
-             fullpath, fd->mount);
-    return -1;
-  }
-}
 
-xbt_dynar_t HostImpl::getVms()
-{
-  xbt_dynar_t dyn = xbt_dynar_new(sizeof(simgrid::surf::VirtualMachineImpl*), nullptr);
+    sg_size_t HostImpl::fileTell(surf_file_t fd)
+    {
+      return fd->current_position;
+    }
 
-  for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
-    if (this == ws_vm->getPm()->pimpl_)
-      xbt_dynar_push(dyn, &ws_vm);
-  }
+    int HostImpl::fileSeek(surf_file_t fd, sg_offset_t offset, int origin)
+    {
+
+      switch (origin) {
+        case SEEK_SET:
+          fd->current_position = offset;
+          return 0;
+        case SEEK_CUR:
+          fd->current_position += offset;
+          return 0;
+        case SEEK_END:
+          fd->current_position = fd->size + offset;
+          return 0;
+        default:
+          return -1;
+      }
+    }
 
-  return dyn;
-}
+    int HostImpl::fileMove(surf_file_t fd, const char* fullpath)
+    {
+      /* Check if the new full path is on the same mount point */
+      if (!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
+        sg_size_t *psize, *new_psize;
+        psize      = (sg_size_t*)xbt_dict_get_or_null(findStorageOnMountList(fd->mount)->content_, fd->name);
+        new_psize  = xbt_new(sg_size_t, 1);
+        *new_psize = *psize;
+        if (psize) { // src file exists
+          xbt_dict_remove(findStorageOnMountList(fd->mount)->content_, fd->name);
+          char* path = (char*)xbt_malloc((strlen(fullpath) - strlen(fd->mount) + 1));
+          strncpy(path, fullpath + strlen(fd->mount), strlen(fullpath) - strlen(fd->mount) + 1);
+          xbt_dict_set(findStorageOnMountList(fd->mount)->content_, path, new_psize, nullptr);
+          XBT_DEBUG("Move file from %s to %s, size '%llu'", fd->name, fullpath, *psize);
+          free(path);
+          return 0;
+        } else {
+          XBT_WARN("File %s doesn't exist", fd->name);
+          return -1;
+        }
+      } else {
+        XBT_WARN("New full path %s is not on the same mount point: %s. Action has been canceled.", fullpath, fd->mount);
+        return -1;
+      }
+    }
 
-void HostImpl::getParams(vm_params_t params)
-{
-  *params = params_;
-}
+    xbt_dynar_t HostImpl::getVms()
+    {
+      xbt_dynar_t dyn = xbt_dynar_new(sizeof(simgrid::surf::VirtualMachineImpl*), nullptr);
 
-void HostImpl::setParams(vm_params_t params)
-{
-  /* may check something here. */
-  params_ = *params;
-}
+      for (VirtualMachineImpl* ws_vm : VirtualMachineImpl::allVms_) {
+        if (this == ws_vm->getPm()->pimpl_)
+          xbt_dynar_push(dyn, &ws_vm);
+      }
 
-}}
+      return dyn;
+    }
+    }
+    }
index 56909eb..7692601 100644 (file)
@@ -25,8 +25,6 @@ namespace surf {
 class XBT_PRIVATE HostModel;
 class XBT_PRIVATE HostImpl;
 class XBT_PRIVATE HostAction;
-
-
 }
 }
 
@@ -52,8 +50,8 @@ public:
   HostModel() : Model() {}
 
   virtual void adjustWeightOfDummyCpuActions();
-  virtual Action *executeParallelTask(int host_nb, sg_host_t *host_list,
-      double *flops_amount, double *bytes_amount, double rate);
+  virtual Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount,
+                                      double rate);
 };
 
 /************
@@ -66,20 +64,12 @@ public:
 class HostImpl : public simgrid::surf::PropertyHolder {
 
 public:
-  /**
-   * @brief Host constructor
-   *
-   * @param storage The Storage associated to this Host
-   */
   HostImpl(s4u::Host* host, xbt_dynar_t storage);
-
-  /* Host destruction logic */
-  /**************************/
   virtual ~HostImpl();
 
 public:
   /** @brief Return the storage of corresponding mount point */
-  virtual simgrid::surf::Storage *findStorageOnMountList(const char* storage);
+  virtual simgrid::surf::StoragefindStorageOnMountList(const char* storage);
 
   /** @brief Get the xbt_dict_t of mount_point: Storage */
   virtual xbt_dict_t getMountedStorageList();
@@ -93,7 +83,7 @@ public:
    * @param fullpath The full path to the file
    * @return The StorageAction corresponding to the opening
    */
-  virtual Action *open(const char* fullpath);
+  virtual Actionopen(const char* fullpath);
 
   /**
    * @brief Close a file
@@ -101,7 +91,7 @@ public:
    * @param fd The file descriptor to close
    * @return The StorageAction corresponding to the closing
    */
-  virtual Action *close(surf_file_t fd);
+  virtual Actionclose(surf_file_t fd);
 
   /**
    * @brief Unlink a file
@@ -127,7 +117,7 @@ public:
    * @param size The size in bytes to read
    * @return The StorageAction corresponding to the reading
    */
-  virtual Action *read(surf_file_t fd, sg_size_t size);
+  virtual Actionread(surf_file_t fd, sg_size_t size);
 
   /**
    * @brief Write a file
@@ -136,7 +126,7 @@ public:
    * @param size The size in bytes to write
    * @return The StorageAction corresponding to the writing
    */
-  virtual Action *write(surf_file_t fd, sg_size_t size);
+  virtual Actionwrite(surf_file_t fd, sg_size_t size);
 
   /**
    * @brief Get the information of a file descriptor
@@ -192,17 +182,8 @@ public:
   /** @brief Get the list of virtual machines on the current Host */
   xbt_dynar_t getVms();
 
-  /* common with vm */
-  /** @brief Retrieve a copy of the parameters of that VM/PM
-   *  @details The ramsize and overcommit fields are used on the PM too */
-  void getParams(vm_params_t params);
-  /** @brief Sets the params of that VM/PM */
-  void setParams(vm_params_t params);
   simgrid::s4u::Host* getHost() { return piface_; }
-private:
-  s_vm_params_t params_;
 };
-
 }
 }
 
index b57e536..53f09d5 100644 (file)
@@ -9,10 +9,7 @@
 namespace simgrid {
 namespace surf {
 
-PropertyHolder::PropertyHolder(xbt_dict_t props)
-: properties_(props)
-{
-}
+PropertyHolder::PropertyHolder() = default;
 
 PropertyHolder::~PropertyHolder() {
   xbt_dict_free(&properties_);
index e7da433..ba06640 100644 (file)
@@ -17,7 +17,7 @@ namespace surf {
 class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance mayhem will get you
 
 public:
-  explicit PropertyHolder(xbt_dict_t props);
+  explicit PropertyHolder();
   ~PropertyHolder();
 
   const char *getProperty(const char*id);
index 8ad7f58..fbf47e5 100644 (file)
@@ -124,6 +124,9 @@ VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::Host* piface, simgrid::s4u:
   /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
   action_ = sub_cpu->execution_start(0);
 
+  /* Initialize the VM parameters */
+  params_.ramsize = 0;
+
   XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", piface->name().c_str(), hostPM_->name().c_str(),
            xbt_dynar_length(storage_));
 }
@@ -225,5 +228,16 @@ void VirtualMachineImpl::setBound(double bound)
 {
   action_->setBound(bound);
 }
+
+void VirtualMachineImpl::getParams(vm_params_t params)
+{
+  *params = params_;
+}
+
+void VirtualMachineImpl::setParams(vm_params_t params)
+{
+  /* may check something here. */
+  params_ = *params;
+}
 }
 }
index 2e3b054..8a8cc68 100644 (file)
@@ -56,7 +56,7 @@ extern XBT_PRIVATE simgrid::xbt::signal<void(simgrid::surf::VirtualMachineImpl*)
  */
 class VirtualMachineImpl : public HostImpl {
 public:
-  VirtualMachineImpl(s4u::Host* piface, s4u::Host* host);
+  explicit VirtualMachineImpl(s4u::Host* piface, s4u::Host* host);
   ~VirtualMachineImpl();
 
   /** @brief Suspend the VM */
@@ -79,6 +79,9 @@ public:
 
   virtual void setBound(double bound);
 
+  void getParams(vm_params_t params);
+  void setParams(vm_params_t params);
+
   /* The vm object of the lower layer */
   CpuAction* action_ = nullptr;
 
@@ -90,6 +93,9 @@ public:
   void setState(e_surf_vm_state_t state);
   static std::deque<VirtualMachineImpl*> allVms_;
 
+private:
+  s_vm_params_t params_;
+
 protected:
   e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
 };
index 0824bdb..96c31e0 100644 (file)
@@ -152,8 +152,9 @@ NetworkCm02Model::NetworkCm02Model()
   }
 
   maxminSystem_ = lmm_system_new(selectiveUpdate_);
+  loopback_     = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 
-  routing_model_create(createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE, nullptr));
+  routing_model_create();
 
   if (updateMechanism_ == UM_LAZY) {
     actionHeap_ = xbt_heap_new(8, nullptr);
@@ -171,10 +172,10 @@ NetworkCm02Model::NetworkCm02Model(void (*specificSolveFun)(lmm_system_t self))
 
 NetworkCm02Model::~NetworkCm02Model() {}
 
-Link* NetworkCm02Model::createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy,
-    xbt_dict_t properties)
+Link* NetworkCm02Model::createLink(const char* name, double bandwidth, double latency,
+                                   e_surf_link_sharing_policy_t policy)
 {
-  return new NetworkCm02Link(this, name, properties, bandwidth, latency, policy, maxminSystem_);
+  return new NetworkCm02Link(this, name, bandwidth, latency, policy, maxminSystem_);
 }
 
 void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
@@ -395,9 +396,9 @@ void NetworkCm02Model::gapAppend(double size, const Link* link, NetworkAction* a
 /************
  * Resource *
  ************/
-NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const char* name, xbt_dict_t props, double bandwidth,
-                                 double latency, e_surf_link_sharing_policy_t policy, lmm_system_t system)
-    : Link(model, name, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth), props)
+NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency,
+                                 e_surf_link_sharing_policy_t policy, lmm_system_t system)
+    : Link(model, name, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth))
 {
   bandwidth_.scale = 1.0;
   bandwidth_.peak  = bandwidth;
index 27e419b..e231d3a 100644 (file)
@@ -41,8 +41,8 @@ namespace simgrid {
       NetworkCm02Model();
       explicit NetworkCm02Model(void (*solve_fun)(lmm_system_t self));
       virtual ~NetworkCm02Model();
-      Link* createLink(const char *name, double bandwidth,  double latency, e_surf_link_sharing_policy_t policy,
-          xbt_dict_t properties) override;
+      Link* createLink(const char* name, double bandwidth, double latency,
+                       e_surf_link_sharing_policy_t policy) override;
       void updateActionsStateLazy(double now, double delta) override;
       void updateActionsStateFull(double now, double delta) override;
       Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
@@ -57,9 +57,8 @@ namespace simgrid {
 
     class NetworkCm02Link : public Link {
     public:
-      NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props,
-          double bandwidth, double latency, e_surf_link_sharing_policy_t policy,
-          lmm_system_t system);
+      NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency,
+                      e_surf_link_sharing_policy_t policy, lmm_system_t system);
       ~NetworkCm02Link() override;
       void apply_event(tmgr_trace_iterator_t event, double value) override;
       void setBandwidth(double value) override;
index 4581f26..bbf16a8 100644 (file)
@@ -17,17 +17,18 @@ void surf_network_model_init_Constant()
   surf_network_model = new simgrid::surf::NetworkConstantModel();
   all_existing_models->push_back(surf_network_model);
 
-  routing_model_create(nullptr);
+  routing_model_create();
 }
 
 namespace simgrid {
   namespace surf {
-    Link* NetworkConstantModel::createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy,
-        xbt_dict_t properties) {
+  Link* NetworkConstantModel::createLink(const char* name, double bw, double lat, e_surf_link_sharing_policy_t policy)
+  {
 
-      xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
-          "Please remove any link from your platform (and switch to routing='None')", name);
-      return nullptr;
+    xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
+            "Please remove any link from your platform (and switch to routing='None')",
+            name);
+    return nullptr;
     }
 
     double NetworkConstantModel::nextOccuringEvent(double /*now*/)
index 58e8ce9..ffb1659 100644 (file)
@@ -30,7 +30,7 @@ namespace simgrid {
       double nextOccuringEvent(double now) override;
       void updateActionsState(double now, double delta) override;
 
-      Link* createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override;
+      Link* createLink(const char* name, double bw, double lat, e_surf_link_sharing_policy_t policy) override;
     };
 
     /**********
index 493b71b..5a2e56d 100644 (file)
@@ -147,8 +147,8 @@ namespace simgrid {
      * Resource *
      ************/
 
-    Link::Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint, xbt_dict_t props)
-        : Resource(model, name, constraint), PropertyHolder(props)
+    Link::Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint)
+        : Resource(model, name, constraint)
     {
       if (strcmp(name,"__loopback__"))
         xbt_assert(!Link::byName(name), "Link '%s' declared several times in the platform.", name);
index 1354e73..c5522a8 100644 (file)
@@ -60,10 +60,9 @@ namespace simgrid {
        * @param bandwidth The initial bandwidth of the Link in bytes per second
        * @param latency The initial latency of the Link in seconds
        * @param policy The sharing policy of the Link
-       * @param props Dictionary of properties associated to this Link
        */
-      virtual Link* createLink(const char *name, double bandwidth, double latency,
-          e_surf_link_sharing_policy_t policy, xbt_dict_t properties)=0;
+      virtual Link* createLink(const charname, double bandwidth, double latency,
+                               e_surf_link_sharing_policy_t policy) = 0;
 
       /**
        * @brief Create a communication between two hosts.
@@ -120,6 +119,8 @@ namespace simgrid {
        */
       virtual double bandwidthConstraint(double rate, double bound, double size);
       double nextOccuringEventFull(double now) override;
+
+      Link* loopback_ = nullptr;
     };
 
     /************
@@ -135,7 +136,7 @@ namespace simgrid {
         public:
 
       /** @brief Constructor of LMM links */
-          Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint, xbt_dict_t props);
+          Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint);
 
           /* Link destruction logic */
           /**************************/
index d4b933b..bf5d0f7 100644 (file)
@@ -174,7 +174,7 @@ namespace surf {
 NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
   ns3_initialize(ns3_tcp_model.get().c_str());
 
-  routing_model_create(nullptr);
+  routing_model_create();
   simgrid::s4u::Host::onCreation.connect(ns3_add_host);
   simgrid::kernel::routing::netcardCreatedCallbacks.connect(ns3_add_netcard);
   simgrid::surf::on_cluster.connect (&parse_ns3_add_cluster);
@@ -193,10 +193,10 @@ NetworkNS3Model::~NetworkNS3Model() {
   xbt_dict_free(&flowFromSock);
 }
 
-Link* NetworkNS3Model::createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy,
-    xbt_dict_t properties){
-
-  return new LinkNS3(this, name, properties, bandwidth, latency);
+Link* NetworkNS3Model::createLink(const char* name, double bandwidth, double latency,
+                                  e_surf_link_sharing_policy_t policy)
+{
+  return new LinkNS3(this, name, bandwidth, latency);
 }
 
 Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
@@ -283,8 +283,8 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
  * Resource *
  ************/
 
-LinkNS3::LinkNS3(NetworkNS3Model* model, const char* name, xbt_dict_t props, double bandwidth, double latency)
-    : Link(model, name, nullptr, props)
+LinkNS3::LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency)
+    : Link(model, name, nullptr)
 {
   bandwidth_.peak = bandwidth;
   latency_.peak   = latency;
index 75e414e..b1162b3 100644 (file)
@@ -19,8 +19,7 @@ class NetworkNS3Model : public NetworkModel {
 public:
   NetworkNS3Model();
   ~NetworkNS3Model();
-  Link* createLink(const char *name, double bandwidth, double latency,
-      e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override;
+  Link* createLink(const char* name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) override;
   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
   double nextOccuringEvent(double now) override;
   bool nextOccuringEventIsIdempotent() {return false;}
@@ -32,7 +31,7 @@ public:
  ************/
 class LinkNS3 : public Link {
 public:
-  LinkNS3(NetworkNS3Model *model, const char *name, xbt_dict_t props, double bandwidth, double latency);
+  explicit LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency);
   ~LinkNS3();
 
   void apply_event(tmgr_trace_iterator_t event, double value) override;
index 33f500d..a986926 100644 (file)
@@ -41,7 +41,7 @@ HostL07Model::HostL07Model() : HostModel() {
   surf_network_model = new NetworkL07Model(this,maxminSystem_);
   surf_cpu_model_pm = new CpuL07Model(this,maxminSystem_);
 
-  routing_model_create(surf_network_model->createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE, nullptr));
+  routing_model_create();
 }
 
 HostL07Model::~HostL07Model() = default;
@@ -61,6 +61,7 @@ NetworkL07Model::NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys)
   , hostModel_(hmodel)
   {
     maxminSystem_ = sys;
+    loopback_     = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
   }
 NetworkL07Model::~NetworkL07Model()
 {
@@ -249,10 +250,10 @@ Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host,  std::vector<double> *spee
   return new CpuL07(this, host, speedPerPstate, core);
 }
 
-Link* NetworkL07Model::createLink(const char *name, double bandwidth, double latency,
-    e_surf_link_sharing_policy_t policy, xbt_dict_t properties)
+Link* NetworkL07Model::createLink(const charname, double bandwidth, double latency,
+                                  e_surf_link_sharing_policy_t policy)
 {
-  return new LinkL07(this, name, properties, bandwidth, latency, policy);
+  return new LinkL07(this, name, bandwidth, latency, policy);
 }
 
 /************
@@ -267,9 +268,9 @@ CpuL07::CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector<double>
 
 CpuL07::~CpuL07()=default;
 
-LinkL07::LinkL07(NetworkL07Model* model, const char* name, xbt_dict_t props, double bandwidth, double latency,
+LinkL07::LinkL07(NetworkL07Model* model, const char* name, double bandwidth, double latency,
                  e_surf_link_sharing_policy_t policy)
-    : Link(model, name, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth), props)
+    : Link(model, name, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth))
 {
   bandwidth_.peak = bandwidth;
   latency_.peak   = latency;
index 78127ce..1b04286 100644 (file)
@@ -58,9 +58,7 @@ class NetworkL07Model : public NetworkModel {
 public:
   NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys);
   ~NetworkL07Model();
-  Link* createLink(const char *name, double bandwidth, double latency,
-      e_surf_link_sharing_policy_t policy,
-      xbt_dict_t properties) override;
+  Link* createLink(const char* name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) override;
 
   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
 
@@ -85,8 +83,8 @@ protected:
 
 class LinkL07 : public Link {
 public:
-  LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
-      double bandwidth, double latency, e_surf_link_sharing_policy_t policy);
+  LinkL07(NetworkL07Model* model, const char* name, double bandwidth, double latency,
+          e_surf_link_sharing_policy_t policy);
   ~LinkL07(){ };
   bool isUsed() override;
   void apply_event(tmgr_trace_iterator_t event, double value) override;
index 65b2133..cb5a0d4 100644 (file)
@@ -74,43 +74,36 @@ void sg_platf_exit() {
 }
 
 /** @brief Add an host to the current AS */
-void sg_platf_new_host(sg_platf_host_cbarg_t host)
+void sg_platf_new_host(sg_platf_host_cbarg_t args)
 {
-  simgrid::kernel::routing::AsImpl* current_routing = routing_get_current();
-
-  simgrid::s4u::Host* h = new simgrid::s4u::Host(host->id);
-  current_routing->attachHost(h);
-
-  if (host->coord && strcmp(host->coord, "")) {
-    new simgrid::kernel::routing::vivaldi::Coords(h, host->coord);
-  }
-
-  simgrid::surf::Cpu *cpu = surf_cpu_model_pm->createCpu( h, &host->speed_per_pstate, host->core_amount);
-  if (host->state_trace)
-    cpu->setStateTrace(host->state_trace);
-  if (host->speed_trace)
-    cpu->setSpeedTrace(host->speed_trace);
-
-  new simgrid::surf::HostImpl(h, mount_list);
-  xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, static_cast<void*>(mount_list));
+  simgrid::s4u::Host* host = routing_get_current()->createHost(args->id, &args->speed_per_pstate, args->core_amount);
 
+  new simgrid::surf::HostImpl(host, mount_list);
+  xbt_lib_set(storage_lib, args->id, ROUTING_STORAGE_HOST_LEVEL, static_cast<void*>(mount_list));
   mount_list = nullptr;
 
-  if (host->properties) {
+  if (args->properties) {
     xbt_dict_cursor_t cursor=nullptr;
     char *key,*data;
-    xbt_dict_foreach(host->properties,cursor,key,data)
-      h->setProperty(key,data);
-    xbt_dict_free(&host->properties);
+    xbt_dict_foreach (args->properties, cursor, key, data)
+      host->setProperty(key, data);
+    xbt_dict_free(&args->properties);
   }
 
-  if (host->pstate != 0)
-    cpu->setPState(host->pstate);
+  /* Change from the defaults */
+  if (args->state_trace)
+    host->pimpl_cpu->setStateTrace(args->state_trace);
+  if (args->speed_trace)
+    host->pimpl_cpu->setSpeedTrace(args->speed_trace);
+  if (args->pstate != 0)
+    host->pimpl_cpu->setPState(args->pstate);
+  if (args->coord && strcmp(args->coord, ""))
+    new simgrid::kernel::routing::vivaldi::Coords(host, args->coord);
 
-  simgrid::s4u::Host::onCreation(*h);
+  simgrid::s4u::Host::onCreation(*host);
 
   if (TRACE_is_enabled() && TRACE_needs_platform())
-    sg_instr_new_host(*h);
+    sg_instr_new_host(*host);
 }
 
 /** @brief Add a "router" to the network element list */
@@ -165,7 +158,15 @@ void sg_platf_new_link(sg_platf_link_cbarg_t link){
     names.push_back(xbt_strdup(link->id));
   }
   for (auto link_name : names) {
-    Link *l = surf_network_model->createLink(link_name, link->bandwidth, link->latency, link->policy, link->properties);
+    Link* l = surf_network_model->createLink(link_name, link->bandwidth, link->latency, link->policy);
+
+    if (link->properties) {
+      xbt_dict_cursor_t cursor = nullptr;
+      char *key, *data;
+      xbt_dict_foreach (link->properties, cursor, key, data)
+        l->setProperty(key, data);
+      xbt_dict_free(&link->properties);
+    }
 
     if (link->latency_trace)
       l->setLatencyTrace(link->latency_trace);
@@ -422,12 +423,16 @@ void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
       storage->content_type,
     storage->properties);
 
-  surf_storage_model->createStorage(storage->id,
-                                     ((storage_type_t) stype)->type_id,
-                                     storage->content,
-                                     storage->content_type,
-                   storage->properties,
-                                     storage->attach);
+  auto s = surf_storage_model->createStorage(storage->id, ((storage_type_t)stype)->type_id, storage->content,
+                                             storage->content_type, storage->attach);
+
+  if (storage->properties) {
+    xbt_dict_cursor_t cursor = nullptr;
+    char *key, *data;
+    xbt_dict_foreach (storage->properties, cursor, key, data)
+      s->setProperty(key, data);
+    xbt_dict_free(&storage->properties);
+  }
 }
 void sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type){
 
index c2ae47c..ff31c4c 100644 (file)
@@ -49,16 +49,15 @@ StorageModel::~StorageModel(){
  * Resource *
  ************/
 
-Storage::Storage(Model *model, const char *name, xbt_dict_t props,
-                 lmm_system_t maxminSystem, double bread, double bwrite,
-                 double bconnection, const char* type_id, const char *content_name,
-                 const char *content_type, sg_size_t size, const char *attach)
- : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
- , PropertyHolder(props)
- , contentType_(xbt_strdup(content_type))
- , size_(size), usedSize_(0)
- , typeId_(xbt_strdup(type_id))
- , writeActions_(std::vector<StorageAction*>())
+Storage::Storage(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
+                 double bconnection, const char* type_id, const char* content_name, const char* content_type,
+                 sg_size_t size, const char* attach)
+    : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
+    , contentType_(xbt_strdup(content_type))
+    , size_(size)
+    , usedSize_(0)
+    , typeId_(xbt_strdup(type_id))
+    , writeActions_(std::vector<StorageAction*>())
 {
   content_ = parseContent(content_name);
   attach_ = xbt_strdup(attach);
index e271c9b..e2b39ef 100644 (file)
@@ -64,9 +64,8 @@ public:
   StorageModel();
   ~StorageModel();
 
-  virtual Storage *createStorage(const char* id, const char* type_id,
-                                 const char* content_name, const char* content_type,
-                                 xbt_dict_t properties, const char *attach) = 0;
+  virtual Storage* createStorage(const char* id, const char* type_id, const char* content_name,
+                                 const char* content_type, const char* attach) = 0;
 
   std::vector<Storage*> p_storageList;
 };
@@ -89,11 +88,8 @@ public:
    * @param name The name of the Storage
    * @param props Dictionary of properties associated to this Storage
    */
-  Storage(Model *model, const char *name, xbt_dict_t props,
-          lmm_system_t maxminSystem, double bread, double bwrite,
-          double bconnection,
-          const char* type_id, const char *content_name, const char *content_type,
-          sg_size_t size, const char *attach);
+  Storage(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
+          const char* type_id, const char* content_name, const char* content_type, sg_size_t size, const char* attach);
 
   ~Storage();
 
index 9ed638d..a986fe4 100644 (file)
@@ -61,8 +61,8 @@ namespace simgrid {
 namespace surf {
 
 #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area
-Storage *StorageN11Model::createStorage(const char* id, const char* type_id,
-    const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach)
+Storage* StorageN11Model::createStorage(const char* id, const char* type_id, const char* content_name,
+                                        const char* content_type, const char* attach)
 {
 
   xbt_assert(!surf_storage_resource_priv(surf_storage_resource_by_name(id)),
@@ -77,14 +77,12 @@ Storage *StorageN11Model::createStorage(const char* id, const char* type_id,
   double Bconnection   = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bconnection"),
       "property Bconnection, storage",type_id);
 
-  Storage *storage = new StorageN11(this, id, properties, maxminSystem_,
-      Bread, Bwrite, Bconnection, type_id, (char *)content_name,
-      content_type, storage_type->size, (char *) attach);
+  Storage* storage = new StorageN11(this, id, maxminSystem_, Bread, Bwrite, Bconnection, type_id, (char*)content_name,
+                                    content_type, storage_type->size, (char*)attach);
   storageCreatedCallbacks(storage);
   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
 
-  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tproperties '%p'\n\t\tBread '%f'\n",
-      id, type_id, properties, Bread);
+  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tBread '%f'\n", id, type_id, Bread);
 
   p_storageList.push_back(storage);
 
@@ -167,12 +165,11 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
  * Resource *
  ************/
 
-StorageN11::StorageN11(StorageModel *model, const char* name,
-    xbt_dict_t properties, lmm_system_t maxminSystem, double bread,
-    double bwrite, double bconnection, const char* type_id, char *content_name,
-    const char *content_type, sg_size_t size, char *attach)
-: Storage(model, name, properties,
-    maxminSystem, bread, bwrite, bconnection, type_id, content_name, content_type, size, attach) {
+StorageN11::StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
+                       double bconnection, const char* type_id, char* content_name, const char* content_type,
+                       sg_size_t size, char* attach)
+    : Storage(model, name, maxminSystem, bread, bwrite, bconnection, type_id, content_name, content_type, size, attach)
+{
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
 }
 
index 04f6f0c..3a12eee 100644 (file)
@@ -28,8 +28,8 @@ class XBT_PRIVATE StorageN11Action;
 
 class StorageN11Model : public StorageModel {
 public:
-  Storage *createStorage(const char* id, const char* type_id,
-       const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach) override;
+  Storage* createStorage(const char* id, const char* type_id, const char* content_name, const char* content_type,
+                         const char* attach) override;
   double nextOccuringEvent(double now) override;
   void updateActionsState(double now, double delta) override;
 };
@@ -40,15 +40,15 @@ public:
 
 class StorageN11 : public Storage {
 public:
-  StorageN11(StorageModel *model, const char* name, xbt_dict_t properties,
-         lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
-         const char* type_id, char *content_name, const char *content_type, sg_size_t size, char *attach);
+  StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
+             double bconnection, const char* type_id, char* content_name, const char* content_type, sg_size_t size,
+             char* attach);
 
   StorageAction *open(const char* mount, const char* path);
   StorageAction *close(surf_file_t fd);
   StorageAction *ls(const char *path);
-  StorageAction *read(surf_file_t fd, sg_size_t size); //FIXME:why we have a useless param  *??
-  StorageAction *write(surf_file_t fd, sg_size_t size);//FIXME:why we have a useless param  *??
+  StorageAction* read(surf_file_t fd, sg_size_t size);
+  StorageAction* write(surf_file_t fd, sg_size_t size);
   void rename(const char *src, const char *dest);
 };
 
index 50107a3..b2cedc1 100644 (file)
@@ -528,15 +528,11 @@ void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
 namespace simgrid {
 namespace surf {
 
-Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
-  : name_(xbt_strdup(name))
-  , model_(model)
-  , constraint_(constraint)
+Resource::Resource(Model* model, const char* name, lmm_constraint_t constraint)
+    : name_(name), model_(model), constraint_(constraint)
 {}
 
-Resource::~Resource() {
-  free(name_);
-}
+Resource::~Resource() = default;
 
 bool Resource::isOn() const {
   return isOn_;
@@ -560,11 +556,11 @@ Model *Resource::getModel() const {
 }
 
 const char *Resource::getName() const {
-  return name_;
+  return name_.c_str();
 }
 
 bool Resource::operator==(const Resource &other) const {
-  return strcmp(name_, other.name_);
+  return name_ == other.name_;
 }
 
 lmm_constraint_t Resource::getConstraint() const {
index 42f4c85..998d260 100644 (file)
@@ -423,7 +423,7 @@ public:
   virtual void turnOff();
 
 private:
-  char* name_;
+  std::string name_;
   Model *model_;
   bool isOn_ = true;
 
index 3dee138..7f18490 100644 (file)
@@ -129,9 +129,9 @@ xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){
 }}}
 
 /** @brief create the root AS */
-void routing_model_create(Link *loopback)
+void routing_model_create()
 {
-  routing_platf = new simgrid::kernel::routing::RoutingPlatf(loopback);
+  routing_platf = new simgrid::kernel::routing::RoutingPlatf();
 }
 
 /* ************************************************************************** */
@@ -165,10 +165,7 @@ void routing_exit() {
   delete routing_platf;
 }
 
-simgrid::kernel::routing::RoutingPlatf::RoutingPlatf(simgrid::surf::Link *loopback)
-: loopback_(loopback)
-{
-}
+simgrid::kernel::routing::RoutingPlatf::RoutingPlatf() = default;
 simgrid::kernel::routing::RoutingPlatf::~RoutingPlatf()
 {
   delete root_;
index d11b9ca..71d0d14 100644 (file)
@@ -18,7 +18,7 @@
 #include <vector>
 
 SG_BEGIN_DECL()
-XBT_PUBLIC(void) routing_model_create(Link *loopback);
+XBT_PUBLIC(void) routing_model_create();
 XBT_PRIVATE xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
 XBT_PRIVATE xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
 SG_END_DECL()
@@ -107,10 +107,9 @@ public:
  */
 XBT_PUBLIC_CLASS RoutingPlatf {
 public:
-  explicit RoutingPlatf(Link *loopback);
+  explicit RoutingPlatf();
   ~RoutingPlatf();
   AsImpl *root_ = nullptr;
-  Link *loopback_;
   xbt_dynar_t getOneLinkRoutes();
   void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
 };
index 3679e89..6dd95aa 100644 (file)
@@ -20,7 +20,7 @@ set(HAVE_NS3 0)
 set(NS3_HINT ${ns3_path} CACHE PATH "Path to search for NS3 lib and include")
 
 find_library(NS3_LIBRARIES
-  NAME ns3-core ns3.14-core ns3.15-core ns3.16-core ns3.17-core ns3.18-core ns3.19-core ns3.20-core ns3.21-core ns3.22-core ns3.25-core
+  NAME ns3-core ns3.14-core ns3.15-core ns3.16-core ns3.17-core ns3.18-core ns3.19-core ns3.20-core ns3.21-core ns3.22-core ns3.25-core ns3.26-core ns3.27-core ns3.28-core
   PATH_SUFFIXES lib64 lib ns3/lib
   PATHS
   ${NS3_HINT}
@@ -28,7 +28,7 @@ find_library(NS3_LIBRARIES
 
 find_path(NS3_INCLUDE_DIR
   NAME ns3/core-module.h
-  PATH_SUFFIXES include ns3/include include/ns3.14 include/ns3.15 include/ns3.16 include/ns3.17 include/ns3.18 include/ns3.19 include/ns3.20 include/ns3.21 include/ns3.22 include/ns3.25
+  PATH_SUFFIXES include ns3/include include/ns3.14 include/ns3.15 include/ns3.16 include/ns3.17 include/ns3.18 include/ns3.19 include/ns3.20 include/ns3.21 include/ns3.22 include/ns3.25 include/ns3.26 include/ns3.27 include/ns3.28
   PATHS
   ${NS3_HINT}
   )