include include/simgrid/jedule/jedule_sd_binding.h
include include/simgrid/kernel/future.hpp
include include/simgrid/kernel/resource/Action.hpp
+include include/simgrid/kernel/resource/DiskImpl.hpp
include include/simgrid/kernel/resource/Model.hpp
include include/simgrid/kernel/resource/Resource.hpp
include include/simgrid/kernel/routing/ClusterZone.hpp
include src/kernel/lmm/maxmin.hpp
include src/kernel/lmm/maxmin_test.cpp
include src/kernel/resource/Action.cpp
+include src/kernel/resource/DiskImpl.cpp
include src/kernel/resource/Model.cpp
include src/kernel/resource/Resource.cpp
include src/kernel/resource/profile/DatedValue.cpp
include src/surf/cpu_interface.hpp
include src/surf/cpu_ti.cpp
include src/surf/cpu_ti.hpp
+include src/surf/disk_s19.cpp
+include src/surf/disk_s19.hpp
include src/surf/host_clm03.cpp
include src/surf/host_clm03.hpp
include src/surf/network_cm02.cpp
class NetworkModel;
class LinkImpl;
class NetworkAction;
+class DiskImpl;
+class DiskModel;
class StorageImpl;
class StorageType;
class StorageModel;
--- /dev/null
+/* Copyright (c) 2019. 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 "DiskImpl.hpp"
+
+#include "simgrid/s4u/Engine.hpp"
+#include "src/kernel/EngineImpl.hpp"
+#include "src/kernel/lmm/maxmin.hpp"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(disk_kernel, surf, "Logging specific to the disk kernel resource");
+
+simgrid::kernel::resource::DiskModel* surf_disk_model = nullptr;
+
+namespace simgrid {
+namespace kernel {
+namespace resource {
+
+/*********
+ * Model *
+ *********/
+
+DiskModel::DiskModel() : Model(Model::UpdateAlgo::FULL)
+{
+ set_maxmin_system(new simgrid::kernel::lmm::System(true /* selective update */));
+}
+
+DiskModel::~DiskModel()
+{
+ surf_disk_model = nullptr;
+}
+
+/************
+ * Resource *
+ ************/
+
+DiskImpl::DiskImpl(kernel::resource::Model* model, const std::string& name, kernel::lmm::System* maxminSystem,
+ double read_bw, double write_bw)
+ : Resource(model, name, maxminSystem->constraint_new(this, std::max(read_bw, write_bw)))
+// FIXME , piface_(name, this)
+{
+ DiskImpl::turn_on();
+ XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw, write_bw);
+ constraint_read_ = maxminSystem->constraint_new(this, read_bw);
+ constraint_write_ = maxminSystem->constraint_new(this, write_bw);
+}
+
+DiskImpl::~DiskImpl()
+{
+ xbt_assert(currently_destroying_, "Don't delete Disks directly. Call destroy() instead.");
+}
+
+/** @brief Fire the required callbacks and destroy the object
+ *
+ * Don't delete directly a Disk, call d->destroy() instead.
+ */
+void DiskImpl::destroy()
+{
+ if (not currently_destroying_) {
+ currently_destroying_ = true;
+ // FIXME s4u::Storage::on_destruction(this->piface_);
+ delete this;
+ }
+}
+
+bool DiskImpl::is_used()
+{
+ THROW_UNIMPLEMENTED;
+}
+
+void DiskImpl::apply_event(kernel::profile::Event* /*event*/, double /*value*/)
+{
+ THROW_UNIMPLEMENTED;
+}
+
+void DiskImpl::turn_on()
+{
+ if (not is_on()) {
+ Resource::turn_on();
+ // FIXME s4u::Storage::on_state_change(this->piface_);
+ }
+}
+void DiskImpl::turn_off()
+{
+ if (is_on()) {
+ Resource::turn_off();
+ // FIXME s4u::Storage::on_state_change(this->piface_);
+ }
+}
+
+xbt::signal<void(DiskAction const&, kernel::resource::Action::State, kernel::resource::Action::State)>
+ DiskAction::on_state_change;
+
+/**********
+ * Action *
+ **********/
+void DiskAction::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
--- /dev/null
+/* Copyright (c) 2019. 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 "src/surf/PropertyHolder.hpp"
+#include "src/surf/surf_interface.hpp"
+
+#include <map>
+
+#ifndef DISK_INTERFACE_HPP_
+#define DISK_INTERFACE_HPP_
+
+/*********
+ * Model *
+ *********/
+
+XBT_PUBLIC_DATA simgrid::kernel::resource::DiskModel* surf_disk_model;
+
+namespace simgrid {
+namespace kernel {
+namespace resource {
+/***********
+ * Classes *
+ ***********/
+
+class DiskAction;
+
+/*********
+ * Model *
+ *********/
+class DiskModel : public kernel::resource::Model {
+public:
+ DiskModel();
+ DiskModel(const DiskModel&) = delete;
+ DiskModel& operator=(const DiskModel&) = delete;
+ ~DiskModel();
+
+ virtual DiskImpl* createDisk(const std::string& id, double read_bw, double write_bw) = 0;
+};
+
+/************
+ * Resource *
+ ************/
+class DiskImpl : public Resource, public surf::PropertyHolder {
+ bool currently_destroying_ = false;
+
+public:
+ DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
+ DiskImpl(const DiskImpl&) = delete;
+ DiskImpl& operator=(const DiskImpl&) = delete;
+
+ ~DiskImpl() override;
+
+ /** @brief Public interface */
+ // FIXME s4u::Storage piface_;
+
+ /** @brief Check if the Storage is used (if an action currently uses its resources) */
+ bool is_used() 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 DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) = 0;
+ virtual DiskAction* read(sg_size_t size) = 0;
+ virtual DiskAction* write(sg_size_t size) = 0;
+
+ lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/
+ lmm::Constraint* constraint_read_; /* Constraint for maximum write bandwidth*/
+};
+
+/**********
+ * Action *
+ **********/
+
+class DiskAction : public Action {
+public:
+ static xbt::signal<void(DiskAction const&, Action::State, Action::State)> on_state_change;
+
+ DiskAction(Model* model, double cost, bool failed, DiskImpl* disk, s4u::Io::OpType type)
+ : Action(model, cost, failed), type_(type), disk_(disk){};
+
+ /**
+ * @brief diskAction constructor
+ *
+ * @param model The StorageModel associated to this DiskAction
+ * @param cost The cost of this DiskAction in bytes
+ * @param failed [description]
+ * @param var The lmm variable associated to this DiskAction if it is part of a LMM component
+ * @param storage The Storage associated to this DiskAction
+ * @param type [description]
+ */
+ DiskAction(kernel::resource::Model* model, double cost, bool failed, kernel::lmm::Variable* var, DiskImpl* disk,
+ s4u::Io::OpType type)
+ : Action(model, cost, failed, var), type_(type), disk_(disk){};
+
+ void set_state(simgrid::kernel::resource::Action::State state) override;
+
+ s4u::Io::OpType type_;
+ DiskImpl* disk_;
+};
+
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
+#endif /* DISK_INTERFACE_HPP_ */
--- /dev/null
+/* Copyright (c) 2013-2019. 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 "disk_s19.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"
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(disk_kernel);
+
+/*********
+ * Model *
+ *********/
+
+void surf_disk_model_init_default()
+{
+ surf_disk_model = new simgrid::kernel::resource::DiskS19Model();
+}
+
+namespace simgrid {
+namespace kernel {
+namespace resource {
+
+DiskS19Model::DiskS19Model()
+{
+ all_existing_models.push_back(this);
+}
+
+DiskImpl* DiskS19Model::createDisk(const std::string& id, double read_bw, double write_bw)
+{
+ XBT_DEBUG("SURF disk create resource\n\t\tid '%s'\n\t\tread_bw '%f'\n", id.c_str(), read_bw);
+
+ return new DiskS19(this, id, get_maxmin_system(), read_bw, write_bw);
+}
+
+double DiskS19Model::next_occuring_event(double now)
+{
+ return DiskModel::next_occuring_event_full(now);
+}
+
+void DiskS19Model::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(lrint(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 *
+ ************/
+
+DiskS19::DiskS19(DiskModel* model, const std::string& name, lmm::System* maxminSystem, double read_bw, double write_bw)
+ : DiskImpl(model, name, maxminSystem, read_bw, write_bw)
+{
+ XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw, write_bw);
+ // FIXME s4u::Storage::on_creation(this->piface_);
+}
+
+DiskAction* DiskS19::io_start(sg_size_t size, s4u::Io::OpType type)
+{
+ return new DiskS19Action(get_model(), size, not is_on(), this, type);
+}
+
+DiskAction* DiskS19::read(sg_size_t size)
+{
+ return new DiskS19Action(get_model(), size, not is_on(), this, s4u::Io::OpType::READ);
+}
+
+DiskAction* DiskS19::write(sg_size_t size)
+{
+ return new DiskS19Action(get_model(), size, not is_on(), this, s4u::Io::OpType::WRITE);
+}
+
+/**********
+ * Action *
+ **********/
+
+DiskS19Action::DiskS19Action(Model* model, double cost, bool failed, DiskImpl* disk, s4u::Io::OpType type)
+ : DiskAction(model, cost, failed, model->get_maxmin_system()->variable_new(this, 1.0, -1.0, 3), disk, type)
+{
+ XBT_IN("(%s,%g", disk->get_cname(), cost);
+
+ // Must be less than the max bandwidth for all actions
+ model->get_maxmin_system()->expand(disk->get_constraint(), get_variable(), 1.0);
+ switch (type) {
+ case s4u::Io::OpType::READ:
+ model->get_maxmin_system()->expand(disk->constraint_read_, get_variable(), 1.0);
+ break;
+ case s4u::Io::OpType::WRITE:
+ model->get_maxmin_system()->expand(disk->constraint_write_, get_variable(), 1.0);
+ break;
+ default:
+ THROW_UNIMPLEMENTED;
+ }
+ XBT_OUT();
+}
+
+void DiskS19Action::cancel()
+{
+ set_state(Action::State::FAILED);
+}
+
+void DiskS19Action::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 DiskS19Action::resume()
+{
+ THROW_UNIMPLEMENTED;
+}
+
+void DiskS19Action::set_max_duration(double /*duration*/)
+{
+ THROW_UNIMPLEMENTED;
+}
+
+void DiskS19Action::set_sharing_penalty(double)
+{
+ THROW_UNIMPLEMENTED;
+}
+void DiskS19Action::update_remains_lazy(double /*now*/)
+{
+ THROW_IMPOSSIBLE;
+}
+} // namespace resource
+} // namespace kernel
+} // namespace simgrid
--- /dev/null
+/* Copyright (c) 2013-2019. 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 <xbt/base.h>
+
+#include "src/kernel/resource/DiskImpl.hpp"
+
+#ifndef DISK_S19_HPP_
+#define DISK_S19_HPP_
+
+namespace simgrid {
+namespace kernel {
+namespace resource {
+
+/***********
+ * Classes *
+ ***********/
+
+class XBT_PRIVATE DiskS19Model;
+class XBT_PRIVATE DiskS19;
+class XBT_PRIVATE DiskS19Action;
+
+/*********
+ * Model *
+ *********/
+
+class DiskS19Model : public DiskModel {
+public:
+ DiskS19Model();
+ DiskImpl* createDisk(const std::string& id, double read_bw, double write_bw) override;
+ double next_occuring_event(double now) override;
+ void update_actions_state(double now, double delta) override;
+};
+
+/************
+ * Resource *
+ ************/
+
+class DiskS19 : public DiskImpl {
+public:
+ DiskS19(DiskModel* model, const std::string& name, kernel::lmm::System* maxminSystem, double read_bw,
+ double write_bw);
+ virtual ~DiskS19() = default;
+ DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) override;
+ DiskAction* read(sg_size_t size) override;
+ DiskAction* write(sg_size_t size) override;
+};
+
+/**********
+ * Action *
+ **********/
+
+class DiskS19Action : public DiskAction {
+public:
+ DiskS19Action(Model* model, double cost, bool failed, DiskImpl* disk, 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 /* DISK_S19_HPP_ */
delete cabinet->radicals;
}
+void sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk)
+{
+ THROW_UNIMPLEMENTED;
+}
+
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(),
*/
XBT_PUBLIC void surf_storage_model_init_default();
+XBT_PUBLIC void surf_disk_model_init_default();
+
/* --------------------
* Model Descriptions
* -------------------- */
sg_size_t size;
};
+class DiskCreationArgs {
+public:
+ std::string id;
+ std::unordered_map<std::string, std::string>* properties;
+ double read_bw;
+ double write_bw;
+};
+
class MountCreationArgs {
public:
std::string storageId;
XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
+XBT_PUBLIC void sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
+
XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone
XBT_PUBLIC void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount);
}
void STag_surfxml_disk() {
- THROW_UNIMPLEMENTED;
+ XBT_DEBUG("STag_surfxml_disk");
+ xbt_assert(current_property_set == nullptr,
+ "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
}
+
void ETag_surfxml_disk() {
+ simgrid::kernel::routing::DiskCreationArgs disk;
+ disk.properties = current_property_set;
+ current_property_set = nullptr;
+
+ disk.id = A_surfxml_disk_id;
+ disk.read_bw = surf_parse_get_bandwidth(A_surfxml_disk_read___bw, "read_bw of disk ", disk.id);
+ disk.write_bw = surf_parse_get_bandwidth(A_surfxml_disk_write___bw, "write_bw of disk ", disk.id);
+ sg_platf_new_disk(&disk);
}
void STag_surfxml_host___link(){
src/surf/xml/simgrid_dtd.c
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/kernel/resource/Action.cpp
src/kernel/resource/Model.cpp
src/kernel/resource/Resource.cpp
+ src/kernel/resource/DiskImpl.cpp
src/kernel/resource/profile/DatedValue.cpp
src/kernel/resource/profile/DatedValue.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp
+ src/surf/disk_s19.cpp
src/surf/network_cm02.cpp
src/surf/network_constant.cpp
src/surf/network_interface.cpp
include/simgrid/kernel/resource/Action.hpp
include/simgrid/kernel/resource/Model.hpp
include/simgrid/kernel/resource/Resource.hpp
+ include/simgrid/kernel/resource/DiskImpl.hpp
include/simgrid/kernel/routing/ClusterZone.hpp
include/simgrid/kernel/routing/DijkstraZone.hpp