From 44f73def709658990c1570729f21eb1e14c583fa Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 2 Feb 2021 21:22:44 +0100 Subject: [PATCH] Storage-kill: start with entire files --- MANIFEST.in | 7 -- include/simgrid/s4u/Storage.hpp | 85 -------------- include/simgrid/storage.h | 33 ------ src/s4u/s4u_Storage.cpp | 194 ------------------------------- src/surf/StorageImpl.cpp | 109 ----------------- src/surf/StorageImpl.hpp | 185 ----------------------------- src/surf/storage_n11.cpp | 178 ---------------------------- src/surf/storage_n11.hpp | 71 ----------- tools/cmake/DefinePackages.cmake | 7 -- 9 files changed, 869 deletions(-) delete mode 100644 include/simgrid/s4u/Storage.hpp delete mode 100644 include/simgrid/storage.h delete mode 100644 src/s4u/s4u_Storage.cpp delete mode 100644 src/surf/StorageImpl.cpp delete mode 100644 src/surf/StorageImpl.hpp delete mode 100644 src/surf/storage_n11.cpp delete mode 100644 src/surf/storage_n11.hpp diff --git a/MANIFEST.in b/MANIFEST.in index b4a715e1d5..083854c788 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2043,7 +2043,6 @@ include include/simgrid/s4u/Mailbox.hpp include include/simgrid/s4u/Mutex.hpp include include/simgrid/s4u/NetZone.hpp include include/simgrid/s4u/Semaphore.hpp -include include/simgrid/s4u/Storage.hpp include include/simgrid/s4u/VirtualMachine.hpp include include/simgrid/semaphore.h include include/simgrid/simdag.h @@ -2051,7 +2050,6 @@ include include/simgrid/simix.h include include/simgrid/simix.hpp include include/simgrid/simix/blocking_simcall.hpp include include/simgrid/smpi/replay.hpp -include include/simgrid/storage.h include include/simgrid/version.h.in include include/simgrid/vm.h include include/simgrid/zone.h @@ -2383,7 +2381,6 @@ include src/s4u/s4u_Mailbox.cpp include src/s4u/s4u_Mutex.cpp include src/s4u/s4u_Netzone.cpp include src/s4u/s4u_Semaphore.cpp -include src/s4u/s4u_Storage.cpp include src/simdag/dax.dtd include src/simdag/dax_dtd.c include src/simdag/dax_dtd.h @@ -2596,8 +2593,6 @@ include src/smpi/smpirun.in include src/smpi/smpitools.sh include src/surf/HostImpl.cpp include src/surf/HostImpl.hpp -include src/surf/StorageImpl.cpp -include src/surf/StorageImpl.hpp include src/surf/cpu_cas01.cpp include src/surf/cpu_cas01.hpp include src/surf/cpu_interface.cpp @@ -2627,8 +2622,6 @@ include src/surf/ns3/ns3_simulator.hpp include src/surf/ptask_L07.cpp include src/surf/ptask_L07.hpp include src/surf/sg_platf.cpp -include src/surf/storage_n11.cpp -include src/surf/storage_n11.hpp include src/surf/surf_c_bindings.cpp include src/surf/surf_interface.cpp include src/surf/surf_interface.hpp diff --git a/include/simgrid/s4u/Storage.hpp b/include/simgrid/s4u/Storage.hpp deleted file mode 100644 index e97b4bede8..0000000000 --- a/include/simgrid/s4u/Storage.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) 2006-2021. 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. */ - -#ifndef INCLUDE_SIMGRID_S4U_STORAGE_HPP_ -#define INCLUDE_SIMGRID_S4U_STORAGE_HPP_ - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace simgrid { - -extern template class XBT_PUBLIC xbt::Extendable; - -namespace s4u { - -/** Storage represent the disk resources, usually associated to a given host - * - * By default, SimGrid does not keep track of the actual data being written but - * only computes the time taken by the corresponding data movement. - */ - -class XBT_PUBLIC Storage : public xbt::Extendable { - friend Engine; - friend Io; - friend kernel::resource::StorageImpl; - -public: - 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 xbt::signal on_creation; - /** @brief Callback signal fired when a Storage is destroyed */ - static xbt::signal on_destruction; - /** @brief Callback signal fired when a Storage's state changes */ - static xbt::signal on_state_change; - - /** Retrieve a Storage by its name. It must exist in the platform file */ - static Storage* by_name(const std::string& name); - static Storage* by_name_or_null(const std::string& name); - - /** @brief Retrieves the name of that storage as a C++ string */ - std::string const& get_name() const { return name_; } - /** @brief Retrieves the name of that storage as a C string */ - const char* get_cname() const { return name_.c_str(); } - - const char* get_type() const; - Host* get_host() const { return attached_to_; }; - void set_host(Host* host) { attached_to_ = host; } - - const std::unordered_map* get_properties() const; - const char* get_property(const std::string& key) const; - void set_property(const std::string&, const std::string& value); - - IoPtr io_init(sg_size_t size, s4u::Io::OpType type); - - IoPtr read_async(sg_size_t size); - sg_size_t read(sg_size_t size); - - IoPtr write_async(sg_size_t size); - sg_size_t write(sg_size_t size); - kernel::resource::StorageImpl* get_impl() const { return pimpl_; } - -private: - Host* attached_to_ = nullptr; - kernel::resource::StorageImpl* const pimpl_; - std::string name_; -}; - -} // namespace s4u -} // namespace simgrid - -#endif /* INCLUDE_SIMGRID_S4U_STORAGE_HPP_ */ diff --git a/include/simgrid/storage.h b/include/simgrid/storage.h deleted file mode 100644 index bccf237fbe..0000000000 --- a/include/simgrid/storage.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Public interface to the Link datatype */ - -/* Copyright (c) 2018-2021. 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. */ - -#ifndef INCLUDE_SIMGRID_STORAGE_H_ -#define INCLUDE_SIMGRID_STORAGE_H_ - -#include -#include -#include -#include - -/* C interface */ -SG_BEGIN_DECL - -XBT_PUBLIC const char* sg_storage_get_name(const_sg_storage_t storage); -XBT_PUBLIC sg_storage_t sg_storage_get_by_name(const char* name); -XBT_PUBLIC xbt_dict_t sg_storage_get_properties(const_sg_storage_t storage); -XBT_PUBLIC void sg_storage_set_property_value(sg_storage_t storage, const char* name, const char* value); -XBT_PUBLIC const char* sg_storage_get_property_value(const_sg_storage_t storage, const char* name); -XBT_PUBLIC xbt_dynar_t sg_storages_as_dynar(); -XBT_PUBLIC void sg_storage_set_data(sg_storage_t host, void* data); -XBT_PUBLIC void* sg_storage_get_data(const_sg_storage_t storage); -XBT_PUBLIC const char* sg_storage_get_host(const_sg_storage_t storage); -XBT_PUBLIC sg_size_t sg_storage_read(sg_storage_t storage, sg_size_t size); -XBT_PUBLIC sg_size_t sg_storage_write(sg_storage_t storage, sg_size_t size); - -SG_END_DECL - -#endif /* INCLUDE_SIMGRID_STORAGE_H_ */ diff --git a/src/s4u/s4u_Storage.cpp b/src/s4u/s4u_Storage.cpp deleted file mode 100644 index bf602dcc50..0000000000 --- a/src/s4u/s4u_Storage.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* Copyright (c) 2006-2021. 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. */ - -#include "simgrid/s4u/Engine.hpp" -#include "simgrid/s4u/Host.hpp" -#include "simgrid/s4u/Io.hpp" -#include "simgrid/s4u/Storage.hpp" -#include "simgrid/simix.hpp" -#include "simgrid/storage.h" -#include "src/surf/StorageImpl.hpp" - -namespace simgrid { - -template class xbt::Extendable; - -namespace s4u { - -xbt::signal Storage::on_creation; -xbt::signal Storage::on_destruction; -xbt::signal Storage::on_state_change; - -Storage::Storage(const std::string& name, kernel::resource::StorageImpl* pimpl) : pimpl_(pimpl), name_(name) -{ - Engine::get_instance()->storage_register(name_, this); -} - -Storage* Storage::by_name(const std::string& name) -{ - return Engine::get_instance()->storage_by_name(name); -} - -Storage* Storage::by_name_or_null(const std::string& name) -{ - return Engine::get_instance()->storage_by_name_or_null(name); -} - -const char* Storage::get_type() const -{ - return pimpl_->get_type(); -} - -const std::unordered_map* Storage::get_properties() const -{ - return pimpl_->get_properties(); -} - -const char* Storage::get_property(const std::string& key) const -{ - return this->pimpl_->get_property(key); -} - -void Storage::set_property(const std::string& key, const std::string& value) -{ - kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); }); -} - -IoPtr Storage::io_init(sg_size_t size, Io::OpType type) -{ - return Io::init()->set_storage(this)->set_size(size)->set_op_type(type); -} - -IoPtr Storage::read_async(sg_size_t size) -{ - return IoPtr(io_init(size, Io::OpType::READ))->start(); -} - -sg_size_t Storage::read(sg_size_t size) -{ - return IoPtr(io_init(size, Io::OpType::READ))->start()->wait()->get_performed_ioops(); -} - -IoPtr Storage::write_async(sg_size_t size) -{ - return IoPtr(io_init(size, Io::OpType::WRITE)->start()); -} - -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 - -/* **************************** Public C interface *************************** */ - -/** @addtogroup sg_storage_management - * (#sg_storage_t) and the functions for managing it. - */ - -/** @ingroup sg_storage_management - * - * @brief Returns the name of the #sg_storage_t. - * - * This functions checks whether a storage is a valid pointer or not and return its name. - */ -const char* sg_storage_get_name(const_sg_storage_t storage) -{ - xbt_assert((storage != nullptr), "Invalid parameters"); - return storage->get_cname(); -} - -const char* sg_storage_get_host(const_sg_storage_t storage) -{ - xbt_assert((storage != nullptr), "Invalid parameters"); - return storage->get_host()->get_cname(); -} - -/** @ingroup sg_storage_management - * @brief Returns a xbt_dict_t consisting of the list of properties assigned to this storage - * @param storage a storage - * @return a dict containing the properties - */ -xbt_dict_t sg_storage_get_properties(const_sg_storage_t storage) -{ - xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)"); - xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f); - const std::unordered_map* props = storage->get_properties(); - if (props == nullptr) - return nullptr; - for (auto const& elm : *props) { - xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str())); - } - return as_dict; -} - -/** @ingroup sg_storage_management - * @brief Change the value of a given storage property - * - * @param storage a storage - * @param name a property name - * @param value what to change the property to - */ -void sg_storage_set_property_value(sg_storage_t storage, const char* name, const char* value) -{ - storage->set_property(name, value); -} - -/** @ingroup sg_storage_management - * @brief Returns the value of a given storage property - * - * @param storage a storage - * @param name a property name - * @return value of a property (or nullptr if property not set) - */ -const char* sg_storage_get_property_value(const_sg_storage_t storage, const char* name) -{ - return storage->get_property(name); -} - -/** @ingroup sg_storage_management - * @brief Finds a sg_storage_t using its name. - * @param name the name of a storage - * @return the corresponding storage - */ -sg_storage_t sg_storage_get_by_name(const char* name) -{ - return simgrid::s4u::Storage::by_name(name); -} - -/** @ingroup sg_storage_management - * @brief Returns a dynar containing all the storage elements declared at a given point of time - */ -xbt_dynar_t sg_storages_as_dynar() -{ - std::vector storage_list = simgrid::s4u::Engine::get_instance()->get_all_storages(); - xbt_dynar_t res = xbt_dynar_new(sizeof(sg_storage_t), nullptr); - for (auto const& s : storage_list) - xbt_dynar_push(res, &s); - return res; -} - -void* sg_storage_get_data(const_sg_storage_t storage) -{ - xbt_assert((storage != nullptr), "Invalid parameters"); - return storage->get_data(); -} - -void sg_storage_set_data(sg_storage_t storage, void* data) -{ - storage->set_data(data); -} - -sg_size_t sg_storage_read(sg_storage_t storage, sg_size_t size) -{ - return storage->read(size); -} - -sg_size_t sg_storage_write(sg_storage_t storage, sg_size_t size) -{ - return storage->write(size); -} diff --git a/src/surf/StorageImpl.cpp b/src/surf/StorageImpl.cpp deleted file mode 100644 index dcbc1d2545..0000000000 --- a/src/surf/StorageImpl.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) 2013-2021. 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. */ - -#include "StorageImpl.hpp" -#include "simgrid/s4u/Engine.hpp" -#include "src/kernel/EngineImpl.hpp" -#include "src/kernel/lmm/maxmin.hpp" -#include "surf_private.hpp" - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_storage, ker_resource, "Deprecated way of expressing I/O related resources"); - -simgrid::kernel::resource::StorageModel* surf_storage_model = nullptr; - -namespace simgrid { -namespace kernel { -namespace resource { - -/********* - * Model * - *********/ - -StorageModel::StorageModel() : Model(Model::UpdateAlgo::FULL) -{ - set_maxmin_system(new simgrid::kernel::lmm::System(true /* selective update */)); -} - -StorageModel::~StorageModel() -{ - surf_storage_model = nullptr; -} - -/************ - * Resource * - ************/ - -StorageImpl::StorageImpl(kernel::resource::Model* model, const std::string& name, kernel::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) - : Resource(model, name, maxminSystem->constraint_new(this, std::max(bread, bwrite))) - , piface_(name, this) - , typeId_(type_id) - , attach_(attach) - , content_name_(content_name) - , size_(size) -{ - StorageImpl::turn_on(); - XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size); - constraint_read_ = maxminSystem->constraint_new(this, bread); - constraint_write_ = maxminSystem->constraint_new(this, bwrite); -} - -StorageImpl::~StorageImpl() -{ - xbt_assert(currently_destroying_, "Don't delete Storages directly. Call destroy() instead."); -} - -/** @brief Fire the required callbacks and destroy the object - * - * Don't delete directly a Storage, call s->destroy() instead. - */ -void StorageImpl::destroy() -{ - if (not currently_destroying_) { - currently_destroying_ = true; - s4u::Storage::on_destruction(this->piface_); - delete this; - } -} - -bool StorageImpl::is_used() const -{ - THROW_UNIMPLEMENTED; -} - -void StorageImpl::apply_event(kernel::profile::Event* /*event*/, double /*value*/) -{ - THROW_UNIMPLEMENTED; -} - -void StorageImpl::turn_on() -{ - if (not is_on()) { - Resource::turn_on(); - s4u::Storage::on_state_change(this->piface_); - } -} -void StorageImpl::turn_off() -{ - if (is_on()) { - Resource::turn_off(); - s4u::Storage::on_state_change(this->piface_); - } -} -xbt::signal StorageAction::on_state_change; - -/********** - * Action * - **********/ -void StorageAction::set_state(Action::State state) -{ - Action::State old = get_state(); - Action::set_state(state); - on_state_change(*this, old, state); -} -} // namespace resource -} // namespace kernel -} // namespace simgrid diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp deleted file mode 100644 index 3003afaf9d..0000000000 --- a/src/surf/StorageImpl.hpp +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright (c) 2004-2021. 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. */ - -#include "simgrid/kernel/resource/Action.hpp" -#include "simgrid/kernel/resource/Model.hpp" -#include "simgrid/kernel/resource/Resource.hpp" -#include "simgrid/s4u/Io.hpp" -#include "simgrid/s4u/Storage.hpp" -#include "surf_interface.hpp" -#include "xbt/PropertyHolder.hpp" - -#include - -#ifndef STORAGE_INTERFACE_HPP_ -#define STORAGE_INTERFACE_HPP_ - -/********* - * Model * - *********/ - -XBT_PUBLIC_DATA simgrid::kernel::resource::StorageModel* surf_storage_model; - -namespace simgrid { -namespace kernel { -namespace resource { -/*********** - * Classes * - ***********/ - -class StorageAction; -/** @ingroup SURF_storage_interface - * @brief The possible type of action for the storage component - */ - -/********* - * Model * - *********/ -/** @ingroup SURF_storage_interface - * @brief SURF storage model interface class - * @details A model is an object which handle the interactions between its Resources and its Actions - */ -class StorageModel : public kernel::resource::Model { -public: - StorageModel(); - StorageModel(const StorageModel&) = delete; - StorageModel& operator=(const StorageModel&) = delete; - ~StorageModel() override; - - virtual StorageImpl* createStorage(std::string& filename, int lineno, const std::string& id, - const std::string& type_id, const std::string& content_name, - const std::string& attach) = 0; -}; - -/************ - * Resource * - ************/ -/** @ingroup SURF_storage_interface - * @brief SURF storage interface class - * @details A Storage represent a storage unit (e.g.: hard drive, usb key) - */ -class StorageImpl : public Resource, public xbt::PropertyHolder { - s4u::Storage piface_; - lmm::Constraint* constraint_read_; /* Constraint for maximum read bandwidth*/ - lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/ - - std::string typeId_; - bool currently_destroying_ = false; - // Name of the host to which this storage is attached. Only used at platform parsing time, then the interface stores - // the Host directly. - std::string attach_; - -public: - const std::string content_name_; // Only used at parsing time then goes to the FileSystemExtension - const sg_size_t size_; // Only used at parsing time then goes to the FileSystemExtension - /** @brief Storage constructor */ - 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; - - ~StorageImpl() override; - - const s4u::Storage* get_iface() const { return &piface_; } - s4u::Storage* get_iface() { return &piface_; } - const char* get_type() const { return typeId_.c_str(); } - lmm::Constraint* get_read_constraint() const { return constraint_read_; } - lmm::Constraint* get_write_constraint() const { return constraint_write_; } - /** @brief Check if the Storage is used (if an action currently uses its resources) */ - bool is_used() const 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 StorageAction* io_start(sg_size_t size, s4u::Io::OpType type) = 0; - /** - * @brief Read a file - * - * @param size The size in bytes to read - * @return The StorageAction corresponding to the reading - */ - virtual StorageAction* read(sg_size_t size) = 0; - - /** - * @brief Write a file - * - * @param size The size in bytes to write - * @return The StorageAction corresponding to the writing - */ - virtual StorageAction* write(sg_size_t size) = 0; - const std::string& get_host() const { return attach_; } -}; - -/********** - * Action * - **********/ - -/** @ingroup SURF_storage_interface - * @brief SURF storage action interface class - */ -class StorageAction : public Action { -public: - /** - * @brief Callbacks handler which emit the callbacks after StorageAction State changed * - * @details Callback functions have the following signature: `void(StorageAction& action, - * simgrid::kernel::resource::Action::State old, simgrid::kernel::resource::Action::State current)` - */ - static xbt::signal on_state_change; - - /** - * @brief StorageAction constructor - * - * @param model The StorageModel associated to this StorageAction - * @param cost The cost of this StorageAction in bytes - * @param failed [description] - * @param storage The Storage associated to this StorageAction - * @param type [description] - */ - StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, s4u::Io::OpType type) - : Action(model, cost, failed), type_(type), storage_(storage){}; - - /** - * @brief StorageAction constructor - * - * @param model The StorageModel associated to this StorageAction - * @param cost The cost of this StorageAction in [TODO] - * @param failed [description] - * @param var The lmm variable associated to this StorageAction if it is part of a LMM component - * @param storage The Storage associated to this StorageAction - * @param type [description] - */ - StorageAction(kernel::resource::Model* model, double cost, bool failed, kernel::lmm::Variable* var, - StorageImpl* storage, s4u::Io::OpType type) - : Action(model, cost, failed, var), type_(type), storage_(storage){}; - - void set_state(simgrid::kernel::resource::Action::State state) override; - - s4u::Io::OpType type_; - StorageImpl* storage_; -}; - -class StorageType { -public: - std::string id; - std::string model; - std::string content; - std::unordered_map* properties; - std::unordered_map* model_properties; - sg_size_t size; - StorageType(const std::string& id, const std::string& model, const std::string& content, - std::unordered_map* properties, - std::unordered_map* model_properties, sg_size_t size) - : id(id), model(model), content(content), properties(properties), model_properties(model_properties), size(size) - { - } -}; - -} // namespace resource -} // namespace kernel -} // namespace simgrid -#endif /* STORAGE_INTERFACE_HPP_ */ diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp deleted file mode 100644 index eaa1496fcc..0000000000 --- a/src/surf/storage_n11.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* Copyright (c) 2013-2021. 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. */ - -#include "storage_n11.hpp" -#include "simgrid/kernel/routing/NetPoint.hpp" -#include "simgrid/s4u/Engine.hpp" -#include "simgrid/s4u/Host.hpp" -#include "src/kernel/lmm/maxmin.hpp" -#include "src/surf/xml/platf.hpp" -#include "surf/surf.hpp" -#include "xbt/parse_units.hpp" - -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_storage); - -/************* - * CallBacks * - *************/ -extern std::map> storage_types; - -void check_disk_attachment() -{ - for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) { - const simgrid::kernel::routing::NetPoint* host_elm = - simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(s->get_impl()->get_host()); - if (not host_elm) - surf_parse_error(std::string("Unable to attach storage ") + s->get_cname() + ": host " + - s->get_impl()->get_host() + " does not exist."); - else - s->set_host(simgrid::s4u::Host::by_name(s->get_impl()->get_host())); - } -} - -/********* - * Model * - *********/ - -void surf_storage_model_init_default() -{ - surf_storage_model = new simgrid::kernel::resource::StorageN11Model(); -} - -namespace simgrid { -namespace kernel { -namespace resource { - -StorageN11Model::StorageN11Model() -{ - all_existing_models.push_back(this); -} - -StorageImpl* StorageN11Model::createStorage(std::string& filename, int lineno, const std::string& id, - const std::string& type_id, const std::string& content_name, - const std::string& attach) -{ - const StorageType* storage_type = storage_types.at(type_id); - - double Bread = xbt_parse_get_bandwidth(filename, lineno, storage_type->model_properties->at("Bread").c_str(), - "property Bread, storage", type_id); - double Bwrite = xbt_parse_get_bandwidth(filename, lineno, storage_type->model_properties->at("Bwrite").c_str(), - "property Bwrite, storage", type_id); - - XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tBread '%f'\n", id.c_str(), type_id.c_str(), - Bread); - - return new StorageN11(this, id, get_maxmin_system(), Bread, Bwrite, type_id, content_name, storage_type->size, - attach); -} - -double StorageN11Model::next_occurring_event(double now) -{ - return StorageModel::next_occurring_event_full(now); -} - -void StorageN11Model::update_actions_state(double /*now*/, double delta) -{ - for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { - auto& action = *it; - ++it; // increment iterator here since the following calls to action.finish() may invalidate it - action.update_remains(rint(action.get_variable()->get_value() * delta)); - action.update_max_duration(delta); - - if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_penalty() > 0)) || - ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) { - action.finish(Action::State::FINISHED); - } - } -} - -/************ - * Resource * - ************/ - -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); - s4u::Storage::on_creation(*get_iface()); -} - -StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type) -{ - return new StorageN11Action(get_model(), static_cast(size), not is_on(), this, type); -} - -StorageAction* StorageN11::read(sg_size_t size) -{ - return new StorageN11Action(get_model(), static_cast(size), not is_on(), this, s4u::Io::OpType::READ); -} - -StorageAction* StorageN11::write(sg_size_t size) -{ - return new StorageN11Action(get_model(), static_cast(size), not is_on(), this, s4u::Io::OpType::WRITE); -} - -/********** - * Action * - **********/ - -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); - - // Must be less than the max bandwidth for all actions - model->get_maxmin_system()->expand(storage->get_constraint(), get_variable(), 1.0); - switch(type) { - case s4u::Io::OpType::READ: - model->get_maxmin_system()->expand(storage->get_read_constraint(), get_variable(), 1.0); - break; - case s4u::Io::OpType::WRITE: - model->get_maxmin_system()->expand(storage->get_write_constraint(), get_variable(), 1.0); - break; - default: - THROW_UNIMPLEMENTED; - } - XBT_OUT(); -} - -void StorageN11Action::cancel() -{ - set_state(Action::State::FAILED); -} - -void StorageN11Action::suspend() -{ - XBT_IN("(%p)", this); - if (is_running()) { - get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0); - set_suspend_state(Action::SuspendStates::SUSPENDED); - } - XBT_OUT(); -} - -void StorageN11Action::resume() -{ - THROW_UNIMPLEMENTED; -} - -void StorageN11Action::set_max_duration(double /*duration*/) -{ - THROW_UNIMPLEMENTED; -} - -void StorageN11Action::set_sharing_penalty(double) -{ - THROW_UNIMPLEMENTED; -} -void StorageN11Action::update_remains_lazy(double /*now*/) -{ - THROW_IMPOSSIBLE; -} -} // namespace resource -} // namespace kernel -} // namespace simgrid diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp deleted file mode 100644 index 2face7f595..0000000000 --- a/src/surf/storage_n11.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2013-2021. 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. */ - -#include - -#include "StorageImpl.hpp" - -#ifndef STORAGE_N11_HPP_ -#define STORAGE_N11_HPP_ - -namespace simgrid { -namespace kernel { -namespace resource { - -/*********** - * Classes * - ***********/ - -class XBT_PRIVATE StorageN11Model; -class XBT_PRIVATE StorageN11; -class XBT_PRIVATE StorageN11Action; - -/********* - * Model * - *********/ - -class StorageN11Model : public StorageModel { -public: - StorageN11Model(); - StorageImpl* createStorage(std::string& filename, int lineno, const std::string& id, const std::string& type_id, - const std::string& content_name, const std::string& attach) override; - double next_occurring_event(double now) override; - void update_actions_state(double now, double delta) override; -}; - -/************ - * Resource * - ************/ - -class StorageN11 : public StorageImpl { -public: - StorageN11(StorageModel* model, const std::string& name, kernel::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); - ~StorageN11() override = default; - StorageAction* io_start(sg_size_t size, s4u::Io::OpType type) override; - StorageAction* read(sg_size_t size) override; - StorageAction* write(sg_size_t size) override; -}; - -/********** - * Action * - **********/ - -class StorageN11Action : public StorageAction { -public: - StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage, s4u::Io::OpType type); - void suspend() override; - void cancel() override; - void resume() override; - void set_max_duration(double duration) override; - void set_sharing_penalty(double sharing_penalty) override; - void update_remains_lazy(double now) override; -}; - -} // namespace resource -} // namespace kernel -} // namespace simgrid -#endif /* STORAGE_N11_HPP_ */ diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 9143de750b..68242c8906 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -51,8 +51,6 @@ set(EXTRA_DIST src/surf/xml/surfxml_sax_cb.cpp src/surf/disk_s19.hpp - src/surf/StorageImpl.hpp - src/surf/storage_n11.hpp src/surf/surf_interface.hpp src/surf/surf_private.hpp src/surf/host_clm03.hpp @@ -351,8 +349,6 @@ set(SURF_SRC src/surf/network_interface.cpp src/surf/network_wifi.cpp src/surf/sg_platf.cpp - src/surf/StorageImpl.cpp - src/surf/storage_n11.cpp src/surf/surf_c_bindings.cpp src/surf/surf_interface.cpp src/surf/xml/platf.hpp @@ -454,7 +450,6 @@ set(S4U_SRC src/s4u/s4u_Mutex.cpp src/s4u/s4u_Netzone.cpp src/s4u/s4u_Semaphore.cpp - src/s4u/s4u_Storage.cpp ) set(SIMGRID_SRC @@ -709,7 +704,6 @@ set(headers_to_install include/simgrid/cond.h include/simgrid/mutex.h include/simgrid/semaphore.h - include/simgrid/storage.h include/simgrid/vm.h include/simgrid/zone.h include/simgrid/s4u/Activity.hpp @@ -727,7 +721,6 @@ set(headers_to_install include/simgrid/s4u/Mutex.hpp include/simgrid/s4u/NetZone.hpp include/simgrid/s4u/Semaphore.hpp - include/simgrid/s4u/Storage.hpp include/simgrid/s4u/VirtualMachine.hpp include/simgrid/s4u.hpp -- 2.20.1