Storage is a resource, it goes in simgrid::kernel::resource
13 files changed:
class NetworkModel;
class LinkImpl;
class NetworkAction;
class NetworkModel;
class LinkImpl;
class NetworkAction;
+class StorageImpl;
+class StorageType;
+class StorageModel;
}
namespace routing {
class ClusterCreationArgs;
}
namespace routing {
class ClusterCreationArgs;
class CpuModel;
class HostImpl;
class HostModel;
class CpuModel;
class HostImpl;
class HostModel;
- class StorageImpl;
- class StorageType;
- class StorageModel;
}
namespace mc {
class CommunicationDeterminismChecker;
}
namespace mc {
class CommunicationDeterminismChecker;
*/
class XBT_PUBLIC Storage : public simgrid::xbt::Extendable<Storage> {
*/
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;
- 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 */
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 */
/** @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 */
/** @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);
/** Retrieve a Storage by its name. It must exist in the platform file */
static Storage* by_name(const std::string& name);
IoPtr write_async(sg_size_t size);
sg_size_t write(sg_size_t size);
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
// Deprecated functions
#ifndef DOXYGEN
private:
Host* attached_to_ = nullptr;
private:
Host* attached_to_ = nullptr;
- surf::StorageImpl* const pimpl_;
+ kernel::resource::StorageImpl* const pimpl_;
std::string name_;
void* userdata_ = nullptr;
};
std::string name_;
void* userdata_ = nullptr;
};
*/
XBT_PUBLIC_DATA simgrid::surf::CpuModel* surf_cpu_model_vm;
*/
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
*
/** @ingroup SURF_models
* @brief The host model
*
namespace kernel {
namespace activity {
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;
{
this->state_ = SIMIX_RUNNING;
XBT_DEBUG("Destroy io %p", this);
}
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());
{
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);
{
performed_ioops_ = surf_action_->get_cost();
switch (surf_action_->get_state()) {
{
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;
state_ = SIMIX_FAILED;
break;
- case simgrid::kernel::resource::Action::State::FINISHED:
+ case resource::Action::State::FINISHED:
state_ = SIMIX_DONE;
break;
default:
state_ = SIMIX_DONE;
break;
default:
class XBT_PUBLIC IoImpl : public ActivityImpl {
public:
~IoImpl() override;
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_; }
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;
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;
namespace simgrid {
namespace xbt {
template class Extendable<simgrid::s4u::Storage>;
namespace simgrid {
namespace xbt {
template class Extendable<simgrid::s4u::Storage>;
-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)
}
Storage* Storage::by_name(const std::string& name)
return IoPtr(io_init(size, Io::OpType::WRITE))->start()->wait()->get_performed_ioops();
}
return IoPtr(io_init(size, Io::OpType::WRITE))->start()->wait()->get_performed_ioops();
}
-} /* namespace s4u */
-} /* namespace simgrid */
+} // namespace s4u
+} // namespace simgrid
/* **************************** Public C interface *************************** */
/* **************************** Public C interface *************************** */
/** @brief Get the vector of storages (by names) attached to the Host */
virtual std::vector<const char*> get_attached_storages();
/** @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();
void turn_on();
void turn_off();
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
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 kernel {
+namespace resource {
Action::set_state(state);
on_state_change(this, old, state);
}
Action::set_state(state);
on_state_change(this, old, state);
}
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
#ifndef STORAGE_INTERFACE_HPP_
#define STORAGE_INTERFACE_HPP_
#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 *
***********/
/***********
* Classes *
***********/
* @brief SURF storage interface class
* @details A Storage represent a storage unit (e.g.: hard drive, usb key)
*/
* @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 */
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;
StorageImpl(const StorageImpl&) = delete;
StorageImpl& operator=(const StorageImpl&) = delete;
/** @brief Check if the Storage is used (if an action currently uses its resources) */
bool is_used() override;
/** @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
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
*
/**
* @brief Read a file
*
virtual StorageAction* write(sg_size_t size) = 0;
virtual std::string getHost() { return attach_; }
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
std::string typeId_;
std::string content_name; // Only used at parsing time then goes to the FileSystemExtension
/** @ingroup SURF_storage_interface
* @brief SURF storage action interface class
*/
/** @ingroup SURF_storage_interface
* @brief SURF storage action interface class
*/
-class StorageAction : public kernel::resource::Action {
+class StorageAction : public Action {
- 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
/**
* @brief StorageAction constructor
* @param storage The Storage associated to this StorageAction
* @param type [description]
*/
* @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){};
/**
: Action(model, cost, failed), type_(type), storage_(storage){};
/**
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
#endif /* STORAGE_INTERFACE_HPP_ */
#endif /* STORAGE_INTERFACE_HPP_ */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
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 {
XBT_PRIVATE std::vector<std::string> known_storages;
namespace simgrid {
}
static int surf_parse_models_setup_already_called = 0;
}
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;
/** The current AS in the parsing */
static simgrid::kernel::routing::NetZoneImpl* current_routing = nullptr;
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());
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;
auto st = storage_types.find(storage->type_id);
if (st != storage_types.end()) {
stype = st->second;
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());
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());
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());
/*************
* CallBacks *
*************/
/*************
* 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()
{
void check_disk_attachment()
{
void surf_storage_model_init_default()
{
void surf_storage_model_init_default()
{
- surf_storage_model = new simgrid::surf::StorageN11Model();
+ surf_storage_model = new simgrid::kernel::resource::StorageN11Model();
+namespace kernel {
+namespace resource {
StorageN11Model::StorageN11Model()
{
StorageN11Model::StorageN11Model()
{
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))) {
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);
* Resource *
************/
* 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);
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)
}
StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type)
-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);
: 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);
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
#define STORAGE_N11_HPP_
namespace simgrid {
#define STORAGE_N11_HPP_
namespace simgrid {
+namespace kernel {
+namespace resource {
class StorageN11Action : public StorageAction {
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;
void suspend() override;
void cancel() override;
void resume() override;
void update_remains_lazy(double now) override;
};
void update_remains_lazy(double now) override;
};
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
#endif /* STORAGE_N11_HPP_ */
#endif /* STORAGE_N11_HPP_ */
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;
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)
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)
{
simgrid::s4u::Engine::shutdown();
for (auto const& e : storage_types) {
{
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;
delete stype->properties;
delete stype->model_properties;
delete stype;