From: Martin Quinson Date: Thu, 17 May 2018 20:43:44 +0000 (+0200) Subject: cleanup the resource::Action::State::IGNORED thing X-Git-Tag: v3.20~215^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/eecf563b3a3a0333dac9f754fe11f047c99cd27d?hp=c0f3756528127131a1947179f56871657a084259 cleanup the resource::Action::State::IGNORED thing Factorize stuff of CpuCas01Model and CpuTiModel into Model directly. This way, Action::get_state() always knows in which set the action is. No shit, no magic here. --- diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index 72a9435506..5c33f5ba20 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -70,8 +70,8 @@ public: STARTED, /**< Currently running */ FAILED, /**< either the resource failed, or the action was canceled */ FINISHED, /**< Successfully completed */ - IGNORED /**< e.g. failure detectors, these infinite sleep actions that are put on resources which failure should be - notified */ + IGNORED /**< e.g. failure detectors: infinite sleep actions that are put on resources which failure should get + noticed */ }; enum class SuspendStates { diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index 9a614ca37f..16e9a4fb60 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -43,6 +43,9 @@ public: /** @brief Get the set of [actions](@ref Action) in *finished* state */ Action::StateSet* get_finished_action_set() const { return finished_action_set_; } + /** @brief Get the set of [actions](@ref Action) in *ignored* state */ + Action::StateSet* get_ignored_action_set() const { return ignored_action_set_; } + /** @brief Get the set of modified [actions](@ref Action) */ Action::ModifiedSet* get_modified_set() const; @@ -92,6 +95,8 @@ private: Action::StateSet* started_action_set_ = new Action::StateSet(); /**< Started not done */ Action::StateSet* failed_action_set_ = new Action::StateSet(); /**< Done with failure */ Action::StateSet* finished_action_set_ = new Action::StateSet(); /**< Done successful */ + Action::StateSet* ignored_action_set_ = new Action::StateSet(); /**< not considered (failure detectors?) */ + ActionHeap action_heap_; }; diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index 4fb398fbd8..02aee24eba 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -63,7 +63,9 @@ Action::State Action::get_state() const return Action::State::FAILED; if (state_set_ == model_->get_finished_action_set()) return Action::State::FINISHED; - return Action::State::IGNORED; + if (state_set_ == model_->get_ignored_action_set()) + return Action::State::IGNORED; + THROW_IMPOSSIBLE; } void Action::set_state(Action::State state) @@ -82,6 +84,9 @@ void Action::set_state(Action::State state) case Action::State::FINISHED: state_set_ = model_->get_finished_action_set(); break; + case Action::State::IGNORED: + state_set_ = model_->get_ignored_action_set(); + break; default: state_set_ = nullptr; break; diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 926ff85060..b069dc9930 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -188,12 +188,8 @@ CpuAction *CpuCas01::sleep(double duration) // FIXME: sleep variables should not consume 1.0 in System::expand() action->set_max_duration(duration); action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; - if (duration < 0) { // NO_MAX_DURATION - /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ - simgrid::xbt::intrusive_erase(*action->get_state_set(), *action); - action->state_set_ = &static_cast(get_model())->cpuRunningActionSetThatDoesNotNeedBeingChecked_; - action->get_state_set()->push_back(*action); - } + if (duration < 0) // NO_MAX_DURATION + action->set_state(simgrid::kernel::resource::Action::State::IGNORED); get_model()->get_maxmin_system()->update_variable_weight(action->get_variable(), 0.0); if (get_model()->get_update_algorithm() == kernel::resource::Model::UpdateAlgo::Lazy) { // remove action from the heap diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 99cbea69e6..0009db9af2 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -27,7 +27,6 @@ public: ~CpuCas01Model() override; Cpu *createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) override; - kernel::resource::Action::StateSet cpuRunningActionSetThatDoesNotNeedBeingChecked_; }; /************ diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 6ce941766b..d15f1d2d58 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -561,12 +561,8 @@ CpuAction *CpuTi::sleep(double duration) action->set_max_duration(duration); action->suspended_ = kernel::resource::Action::SuspendStates::sleeping; - if (duration == NO_MAX_DURATION) { - /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ - simgrid::xbt::intrusive_erase(*action->get_state_set(), *action); - action->state_set_ = &static_cast(get_model())->runningActionSetThatDoesNotNeedBeingChecked_; - action->get_state_set()->push_back(*action); - } + if (duration < 0) // NO_MAX_DURATION + action->set_state(simgrid::kernel::resource::Action::State::IGNORED); action_set_.push_back(*action); diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index b58b80eccb..a4f918404a 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -145,7 +145,6 @@ public: double next_occuring_event(double now) override; void update_actions_state(double now, double delta) override; - kernel::resource::Action::StateSet runningActionSetThatDoesNotNeedBeingChecked_; CpuTiList modified_cpus_; };