Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use consistent namespaces
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 12 Mar 2019 13:12:52 +0000 (14:12 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 12 Mar 2019 13:12:52 +0000 (14:12 +0100)
Storage is a resource, it goes in simgrid::kernel::resource

13 files changed:
include/simgrid/forward.h
include/simgrid/s4u/Storage.hpp
src/include/surf/surf.hpp
src/kernel/activity/IoImpl.cpp
src/kernel/activity/IoImpl.hpp
src/s4u/s4u_Storage.cpp
src/surf/HostImpl.hpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
src/surf/sg_platf.cpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp
src/surf/surf_interface.cpp

index b486383..fa40a14 100644 (file)
@@ -140,6 +140,9 @@ class Resource;
 class NetworkModel;
 class LinkImpl;
 class NetworkAction;
+class StorageImpl;
+class StorageType;
+class StorageModel;
 }
 namespace routing {
 class ClusterCreationArgs;
@@ -163,9 +166,6 @@ namespace surf {
   class CpuModel;
   class HostImpl;
   class HostModel;
-  class StorageImpl;
-  class StorageType;
-  class StorageModel;
 }
 namespace mc {
 class CommunicationDeterminismChecker;
index 767a8ac..4ac1666 100644 (file)
@@ -26,22 +26,22 @@ namespace s4u {
  */
 
 class XBT_PUBLIC Storage : public simgrid::xbt::Extendable<Storage> {
-  friend simgrid::s4u::Engine;
-  friend simgrid::s4u::Io;
-  friend simgrid::surf::StorageImpl;
+  friend Engine;
+  friend Io;
+  friend kernel::resource::StorageImpl;
 
 public:
-  explicit Storage(const std::string& name, surf::StorageImpl* pimpl);
+  explicit Storage(const std::string& name, kernel::resource::StorageImpl* pimpl);
 
 protected:
   virtual ~Storage() = default;
 public:
   /** @brief Callback signal fired when a new Storage is created */
-  static simgrid::xbt::signal<void(s4u::Storage&)> on_creation;
+  static xbt::signal<void(s4u::Storage&)> on_creation;
   /** @brief Callback signal fired when a Storage is destroyed */
-  static simgrid::xbt::signal<void(s4u::Storage&)> on_destruction;
+  static xbt::signal<void(s4u::Storage&)> on_destruction;
   /** @brief Callback signal fired when a Storage's state changes */
-  static simgrid::xbt::signal<void(s4u::Storage&)> on_state_change;
+  static xbt::signal<void(s4u::Storage&)> on_state_change;
 
   /** Retrieve a Storage by its name. It must exist in the platform file */
   static Storage* by_name(const std::string& name);
@@ -70,7 +70,7 @@ public:
 
   IoPtr write_async(sg_size_t size);
   sg_size_t write(sg_size_t size);
-  surf::StorageImpl* get_impl() { return pimpl_; }
+  kernel::resource::StorageImpl* get_impl() { return pimpl_; }
 
   // Deprecated functions
 #ifndef DOXYGEN
@@ -115,7 +115,7 @@ public:
 
 private:
   Host* attached_to_ = nullptr;
-  surf::StorageImpl* const pimpl_;
+  kernel::resource::StorageImpl* const pimpl_;
   std::string name_;
   void* userdata_ = nullptr;
 };
index e6699b1..b5b027e 100644 (file)
@@ -18,8 +18,6 @@ XBT_PUBLIC_DATA simgrid::surf::CpuModel* surf_cpu_model_pm;
  */
 XBT_PUBLIC_DATA simgrid::surf::CpuModel* surf_cpu_model_vm;
 
-XBT_PUBLIC_DATA simgrid::surf::StorageModel* surf_storage_model;
-
 /** @ingroup SURF_models
  *  @brief The host model
  *
index c76752f..7647a18 100644 (file)
@@ -37,7 +37,7 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-IoImpl::IoImpl(const std::string& name, surf::StorageImpl* storage) : ActivityImpl(name), storage_(storage)
+IoImpl::IoImpl(const std::string& name, resource::StorageImpl* storage) : ActivityImpl(name), storage_(storage)
 {
   this->state_ = SIMIX_RUNNING;
 
@@ -51,13 +51,13 @@ IoImpl::~IoImpl()
   XBT_DEBUG("Destroy io %p", this);
 }
 
-IoImpl* IoImpl::start(sg_size_t size, simgrid::s4u::Io::OpType type)
+IoImpl* IoImpl::start(sg_size_t size, s4u::Io::OpType type)
 {
   surf_action_ = storage_->io_start(size, type);
   surf_action_->set_data(this);
 
   XBT_DEBUG("Create IO synchro %p %s", this, get_cname());
-  simgrid::kernel::activity::IoImpl::on_start(this);
+  IoImpl::on_start(this);
 
   return this;
 }
@@ -79,10 +79,10 @@ void IoImpl::post()
 {
   performed_ioops_ = surf_action_->get_cost();
   switch (surf_action_->get_state()) {
-    case simgrid::kernel::resource::Action::State::FAILED:
+    case resource::Action::State::FAILED:
       state_ = SIMIX_FAILED;
       break;
-    case simgrid::kernel::resource::Action::State::FINISHED:
+    case resource::Action::State::FINISHED:
       state_ = SIMIX_DONE;
       break;
     default:
index 0577069..653d191 100644 (file)
@@ -17,19 +17,19 @@ namespace activity {
 class XBT_PUBLIC IoImpl : public ActivityImpl {
 public:
   ~IoImpl() override;
-  explicit IoImpl(const std::string& name, surf::StorageImpl* storage);
+  explicit IoImpl(const std::string& name, resource::StorageImpl* storage);
 
-  IoImpl* start(sg_size_t size, simgrid::s4u::Io::OpType type);
+  IoImpl* start(sg_size_t size, s4u::Io::OpType type);
   void post() override;
   void finish() override;
   void cancel();
   double get_remaining();
   sg_size_t get_performed_ioops() { return performed_ioops_; }
 
-  surf::StorageImpl* storage_                     = nullptr;
+  resource::StorageImpl* storage_                 = nullptr;
   sg_size_t performed_ioops_                      = 0;
-  static simgrid::xbt::signal<void(kernel::activity::IoImplPtr)> on_start;
-  static simgrid::xbt::signal<void(kernel::activity::IoImplPtr)> on_completion;
+  static xbt::signal<void(IoImplPtr)> on_start;
+  static xbt::signal<void(IoImplPtr)> on_completion;
 };
 }
 }
index 5aaf6eb..09fb106 100644 (file)
 namespace simgrid {
 namespace xbt {
 template class Extendable<simgrid::s4u::Storage>;
-}
+} // namespace xbt
 
 namespace s4u {
 
-simgrid::xbt::signal<void(s4u::Storage&)> Storage::on_creation;
-simgrid::xbt::signal<void(s4u::Storage&)> Storage::on_destruction;
-simgrid::xbt::signal<void(s4u::Storage&)> Storage::on_state_change;
+xbt::signal<void(Storage&)> Storage::on_creation;
+xbt::signal<void(Storage&)> Storage::on_destruction;
+xbt::signal<void(Storage&)> Storage::on_state_change;
 
-Storage::Storage(const std::string& name, surf::StorageImpl* pimpl) : pimpl_(pimpl), name_(name)
+Storage::Storage(const std::string& name, kernel::resource::StorageImpl* pimpl) : pimpl_(pimpl), name_(name)
 {
-  simgrid::s4u::Engine::get_instance()->storage_register(name_, this);
+  Engine::get_instance()->storage_register(name_, this);
 }
 
 Storage* Storage::by_name(const std::string& name)
@@ -82,8 +82,8 @@ sg_size_t Storage::write(sg_size_t size)
   return IoPtr(io_init(size, Io::OpType::WRITE))->start()->wait()->get_performed_ioops();
 }
 
-} /* namespace s4u */
-} /* namespace simgrid */
+} // namespace s4u
+} // namespace simgrid
 
 /* **************************** Public C interface *************************** */
 
index 1b480a5..d1fff38 100644 (file)
@@ -50,8 +50,8 @@ public:
   /** @brief Get the vector of storages (by names) attached to the Host */
   virtual std::vector<const char*> get_attached_storages();
 
-  std::map<std::string, simgrid::surf::StorageImpl*> storage_;
-  simgrid::s4u::Host* piface_ = nullptr;
+  std::map<std::string, kernel::resource::StorageImpl*> storage_;
+  s4u::Host* piface_ = nullptr;
 
   void turn_on();
   void turn_off();
index 7870a89..18c9ac6 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
 
-simgrid::surf::StorageModel* surf_storage_model = nullptr;
+simgrid::kernel::resource::StorageModel* surf_storage_model = nullptr;
 
 namespace simgrid {
-namespace surf {
+namespace kernel {
+namespace resource {
 
 /*********
  * Model *
@@ -104,5 +105,6 @@ void StorageAction::set_state(Action::State state)
   Action::set_state(state);
   on_state_change(this, old, state);
 }
-}
-}
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
index 083c020..70d8e4b 100644 (file)
 #ifndef STORAGE_INTERFACE_HPP_
 #define STORAGE_INTERFACE_HPP_
 
-namespace simgrid {
-namespace surf {
+/*********
+ * Model *
+ *********/
+
+XBT_PUBLIC_DATA simgrid::kernel::resource::StorageModel* surf_storage_model;
 
+namespace simgrid {
+namespace kernel {
+namespace resource {
 /***********
  * Classes *
  ***********/
@@ -66,12 +72,11 @@ public:
  * @brief SURF storage interface class
  * @details A Storage represent a storage unit (e.g.: hard drive, usb key)
  */
-class StorageImpl : public kernel::resource::Resource, public PropertyHolder {
+class StorageImpl : public Resource, public surf::PropertyHolder {
 public:
   /** @brief Storage constructor */
-  StorageImpl(kernel::resource::Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double bread,
-              double bwrite, const std::string& type_id, const std::string& content_name, sg_size_t size,
-              const std::string& attach);
+  StorageImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double bread, double bwrite,
+              const std::string& type_id, const std::string& content_name, sg_size_t size, const std::string& attach);
   StorageImpl(const StorageImpl&) = delete;
   StorageImpl& operator=(const StorageImpl&) = delete;
 
@@ -83,13 +88,13 @@ public:
   /** @brief Check if the Storage is used (if an action currently uses its resources) */
   bool is_used() override;
 
-  void apply_event(simgrid::kernel::profile::Event* event, double value) override;
+  void apply_event(profile::Event* event, double value) override;
 
   void turn_on() override;
   void turn_off() override;
 
   void destroy(); // Must be called instead of the destructor
-  virtual simgrid::kernel::resource::Action* io_start(sg_size_t size, s4u::Io::OpType type) = 0;
+  virtual Action* io_start(sg_size_t size, s4u::Io::OpType type) = 0;
   /**
    * @brief Read a file
    *
@@ -107,8 +112,8 @@ public:
   virtual StorageAction* write(sg_size_t size) = 0;
   virtual std::string getHost() { return attach_; }
 
-  kernel::lmm::Constraint* constraintWrite_; /* Constraint for maximum write bandwidth*/
-  kernel::lmm::Constraint* constraintRead_;  /* Constraint for maximum write bandwidth*/
+  lmm::Constraint* constraintWrite_; /* Constraint for maximum write bandwidth*/
+  lmm::Constraint* constraintRead_;  /* Constraint for maximum write bandwidth*/
 
   std::string typeId_;
   std::string content_name; // Only used at parsing time then goes to the FileSystemExtension
@@ -128,10 +133,9 @@ private:
 /** @ingroup SURF_storage_interface
  * @brief SURF storage action interface class
  */
-class StorageAction : public kernel::resource::Action {
+class StorageAction : public Action {
 public:
-  static xbt::signal<void(StorageAction*, kernel::resource::Action::State, kernel::resource::Action::State)>
-      on_state_change;
+  static xbt::signal<void(StorageAction*, Action::State, Action::State)> on_state_change;
 
   /**
    * @brief StorageAction constructor
@@ -142,7 +146,7 @@ public:
    * @param storage The Storage associated to this StorageAction
    * @param type [description]
    */
-  StorageAction(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage, s4u::Io::OpType type)
+  StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, s4u::Io::OpType type)
       : Action(model, cost, failed), type_(type), storage_(storage){};
 
   /**
@@ -180,7 +184,8 @@ public:
   {
   }
 };
-}
-}
 
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
 #endif /* STORAGE_INTERFACE_HPP_ */
index 4070803..dc1d5c3 100644 (file)
@@ -27,7 +27,7 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
 
-XBT_PRIVATE std::map<std::string, simgrid::surf::StorageImpl*> mount_list;
+XBT_PRIVATE std::map<std::string, simgrid::kernel::resource::StorageImpl*> mount_list;
 XBT_PRIVATE std::vector<std::string> known_storages;
 
 namespace simgrid {
@@ -38,7 +38,7 @@ simgrid::xbt::signal<void(kernel::routing::ClusterCreationArgs*)> on_cluster;
 }
 
 static int surf_parse_models_setup_already_called = 0;
-std::map<std::string, simgrid::surf::StorageType*> storage_types;
+std::map<std::string, simgrid::kernel::resource::StorageType*> storage_types;
 
 /** The current AS in the parsing */
 static simgrid::kernel::routing::NetZoneImpl* current_routing = nullptr;
@@ -333,7 +333,7 @@ void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage
   xbt_assert(std::find(known_storages.begin(), known_storages.end(), storage->id) == known_storages.end(),
              "Refusing to add a second storage named \"%s\"", storage->id.c_str());
 
-  simgrid::surf::StorageType* stype;
+  simgrid::kernel::resource::StorageType* stype;
   auto st = storage_types.find(storage->type_id);
   if (st != storage_types.end()) {
     stype = st->second;
@@ -373,9 +373,9 @@ void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs
   xbt_assert(storage_types.find(storage_type->id) == storage_types.end(),
              "Reading a storage type, processing unit \"%s\" already exists", storage_type->id.c_str());
 
-  simgrid::surf::StorageType* stype =
-      new simgrid::surf::StorageType(storage_type->id, storage_type->model, storage_type->content,
-                                     storage_type->properties, storage_type->model_properties, storage_type->size);
+  simgrid::kernel::resource::StorageType* stype = new simgrid::kernel::resource::StorageType(
+      storage_type->id, storage_type->model, storage_type->content, storage_type->properties,
+      storage_type->model_properties, storage_type->size);
 
   XBT_DEBUG("Create a storage type id '%s' with model '%s', content '%s'", storage_type->id.c_str(),
             storage_type->model.c_str(), storage_type->content.c_str());
index c13aa46..82aa54a 100644 (file)
@@ -15,7 +15,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_storage);
 /*************
  * CallBacks *
  *************/
-extern std::map<std::string, simgrid::surf::StorageType*> storage_types;
+extern std::map<std::string, simgrid::kernel::resource::StorageType*> storage_types;
 
 void check_disk_attachment()
 {
@@ -35,11 +35,12 @@ void check_disk_attachment()
 
 void surf_storage_model_init_default()
 {
-  surf_storage_model = new simgrid::surf::StorageN11Model();
+  surf_storage_model = new simgrid::kernel::resource::StorageN11Model();
 }
 
 namespace simgrid {
-namespace surf {
+namespace kernel {
+namespace resource {
 
 StorageN11Model::StorageN11Model()
 {
@@ -78,7 +79,7 @@ void StorageN11Model::update_actions_state(double /*now*/, double delta)
 
     if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_weight() > 0)) ||
         ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
-      action.finish(kernel::resource::Action::State::FINISHED);
+      action.finish(Action::State::FINISHED);
     }
   }
 }
@@ -87,13 +88,13 @@ void StorageN11Model::update_actions_state(double /*now*/, double delta)
  * Resource *
  ************/
 
-StorageN11::StorageN11(StorageModel* model, const std::string& name, kernel::lmm::System* maxminSystem, double bread,
+StorageN11::StorageN11(StorageModel* model, const std::string& name, lmm::System* maxminSystem, double bread,
                        double bwrite, const std::string& type_id, const std::string& content_name, sg_size_t size,
                        const std::string& attach)
     : StorageImpl(model, name, maxminSystem, bread, bwrite, type_id, content_name, size, attach)
 {
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
-  simgrid::s4u::Storage::on_creation(this->piface_);
+  s4u::Storage::on_creation(this->piface_);
 }
 
 StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type)
@@ -115,8 +116,7 @@ StorageAction* StorageN11::write(sg_size_t size)
  * Action *
  **********/
 
-StorageN11Action::StorageN11Action(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage,
-                                   s4u::Io::OpType type)
+StorageN11Action::StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage, s4u::Io::OpType type)
     : StorageAction(model, cost, failed, model->get_maxmin_system()->variable_new(this, 1.0, -1.0, 3), storage, type)
 {
   XBT_IN("(%s,%g", storage->get_cname(), cost);
@@ -169,5 +169,6 @@ void StorageN11Action::update_remains_lazy(double /*now*/)
 {
   THROW_IMPOSSIBLE;
 }
-}
-}
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
index 6682708..4d4f67c 100644 (file)
@@ -11,7 +11,8 @@
 #define STORAGE_N11_HPP_
 
 namespace simgrid {
-namespace surf {
+namespace kernel {
+namespace resource {
 
 /***********
  * Classes *
@@ -55,8 +56,7 @@ public:
 
 class StorageN11Action : public StorageAction {
 public:
-  StorageN11Action(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage,
-                   s4u::Io::OpType type);
+  StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage, s4u::Io::OpType type);
   void suspend() override;
   void cancel() override;
   void resume() override;
@@ -65,7 +65,7 @@ public:
   void update_remains_lazy(double now) override;
 };
 
-}
-}
-
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
 #endif /* STORAGE_N11_HPP_ */
index 71a9f87..8beb759 100644 (file)
@@ -34,7 +34,7 @@ simgrid::kernel::profile::FutureEvtSet future_evt_set;
 std::vector<std::string> surf_path;
 /**  set of hosts for which one want to be notified if they ever restart. */
 std::set<std::string> watched_hosts;
-extern std::map<std::string, simgrid::surf::StorageType*> storage_types;
+extern std::map<std::string, simgrid::kernel::resource::StorageType*> storage_types;
 
 s_surf_model_description_t* surf_plugin_description = nullptr;
 XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
@@ -305,7 +305,7 @@ void surf_exit()
 {
   simgrid::s4u::Engine::shutdown();
   for (auto const& e : storage_types) {
-    simgrid::surf::StorageType* stype = e.second;
+    simgrid::kernel::resource::StorageType* stype = e.second;
     delete stype->properties;
     delete stype->model_properties;
     delete stype;