From: SUTER Frederic Date: Mon, 3 May 2021 14:36:57 +0000 (+0200) Subject: yet another revision of the disk internals X-Git-Tag: v3.28~379 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f88215c694b16ecbae4a3e230d437f47bff54917 yet another revision of the disk internals --- diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index 425ae104f7..3621e1c127 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -6,6 +6,7 @@ #include "mc/mc.h" #include "simgrid/Exception.hpp" #include "simgrid/kernel/resource/Action.hpp" +#include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/Io.hpp" #include "src/kernel/actor/SimcallObserver.hpp" @@ -54,7 +55,8 @@ IoImpl& IoImpl::set_disk(resource::DiskImpl* disk) IoImpl* IoImpl::start() { state_ = State::RUNNING; - surf_action_ = disk_->io_start(size_, type_); + surf_action_ = + disk_->get_host()->get_netpoint()->get_englobing_zone()->get_disk_model()->io_start(disk_, size_, type_); surf_action_->set_activity(this); XBT_DEBUG("Create IO synchro %p %s", this, get_cname()); diff --git a/src/kernel/resource/DiskImpl.hpp b/src/kernel/resource/DiskImpl.hpp index 9898cb747f..45dc21bc62 100644 --- a/src/kernel/resource/DiskImpl.hpp +++ b/src/kernel/resource/DiskImpl.hpp @@ -39,6 +39,8 @@ public: DiskModel& operator=(const DiskModel&) = delete; virtual DiskImpl* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth) = 0; + + virtual DiskAction* io_start(const DiskImpl* disk, sg_size_t size, s4u::Io::OpType type) = 0; }; /************ @@ -89,9 +91,6 @@ public: void seal() 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; }; /********** diff --git a/src/surf/disk_s19.cpp b/src/surf/disk_s19.cpp index 3c983213e1..80fcfcec32 100644 --- a/src/surf/disk_s19.cpp +++ b/src/surf/disk_s19.cpp @@ -50,24 +50,26 @@ void DiskS19Model::update_actions_state(double /*now*/, double delta) } } -/************ - * Resource * - ************/ -DiskAction* DiskS19::io_start(sg_size_t size, s4u::Io::OpType type) -{ - return new DiskS19Action(get_model(), static_cast(size), not is_on(), this, type); -} - -DiskAction* DiskS19::read(sg_size_t size) +DiskAction* DiskS19Model::io_start(const DiskImpl* disk, sg_size_t size, s4u::Io::OpType type) { - return new DiskS19Action(get_model(), static_cast(size), not is_on(), this, s4u::Io::OpType::READ); -} - -DiskAction* DiskS19::write(sg_size_t size) -{ - return new DiskS19Action(get_model(), static_cast(size), not is_on(), this, s4u::Io::OpType::WRITE); + auto* action = new DiskS19Action(this, static_cast(size), not disk->is_on(), disk, type); + get_maxmin_system()->expand(disk->get_constraint(), action->get_variable(), 1.0); + switch (type) { + case s4u::Io::OpType::READ: + get_maxmin_system()->expand(disk->get_read_constraint(), action->get_variable(), 1.0); + break; + case s4u::Io::OpType::WRITE: + get_maxmin_system()->expand(disk->get_write_constraint(), action->get_variable(), 1.0); + break; + default: + THROW_UNIMPLEMENTED; + } + return action; } +/************ + * Resource * + ************/ /********** * Action * **********/ @@ -75,21 +77,6 @@ DiskAction* DiskS19::write(sg_size_t size) DiskS19Action::DiskS19Action(Model* model, double cost, bool failed, const DiskImpl* disk, s4u::Io::OpType type) : DiskAction(model, cost, failed, model->get_maxmin_system()->variable_new(this, 1.0, -1.0, 3)) { - 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->get_read_constraint(), get_variable(), 1.0); - break; - case s4u::Io::OpType::WRITE: - model->get_maxmin_system()->expand(disk->get_write_constraint(), get_variable(), 1.0); - break; - default: - THROW_UNIMPLEMENTED; - } - XBT_OUT(); } void DiskS19Action::update_remains_lazy(double /*now*/) diff --git a/src/surf/disk_s19.hpp b/src/surf/disk_s19.hpp index f80c35b2d9..443145750d 100644 --- a/src/surf/disk_s19.hpp +++ b/src/surf/disk_s19.hpp @@ -30,6 +30,9 @@ class DiskS19Model : public DiskModel { public: using DiskModel::DiskModel; DiskImpl* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth) override; + + DiskAction* io_start(const DiskImpl* disk, sg_size_t size, s4u::Io::OpType type) override; + void update_actions_state(double now, double delta) override; }; @@ -40,9 +43,6 @@ public: class DiskS19 : public DiskImpl { public: using DiskImpl::DiskImpl; - 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; }; /**********