X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/95a02a8febe84fd1c2ed98c78c594a5e8a0116f7..eecf563b3a3a0333dac9f754fe11f047c99cd27d:/include/simgrid/kernel/resource/Model.hpp diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index 5855dda94c..16e9a4fb60 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -18,40 +18,48 @@ namespace resource { */ class XBT_PUBLIC Model { public: - Model(); + /** @brief Possible update mechanisms */ + enum class UpdateAlgo { + Full, /**< Full update mechanism: the remaining time of every action is recomputed at each step */ + Lazy /**< Lazy update mechanism: only the modified actions get recomputed. + It may be slower than full if your system is tightly coupled to the point where every action + gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for + a simple full update. */ + }; + + explicit Model(Model::UpdateAlgo algo); + virtual ~Model(); - /** @brief Get the set of [actions](@ref Action) in *ready* state */ - virtual ActionList* getReadyActionSet() const { return readyActionSet_; } + /** @brief Get the set of [actions](@ref Action) in *inited* state */ + Action::StateSet* get_inited_action_set() const { return inited_action_set_; } - /** @brief Get the set of [actions](@ref Action) in *running* state */ - virtual ActionList* getRunningActionSet() const { return runningActionSet_; } + /** @brief Get the set of [actions](@ref Action) in *started* state */ + Action::StateSet* get_started_action_set() const { return started_action_set_; } /** @brief Get the set of [actions](@ref Action) in *failed* state */ - virtual ActionList* getFailedActionSet() const { return failedActionSet_; } + Action::StateSet* get_failed_action_set() const { return failed_action_set_; } - /** @brief Get the set of [actions](@ref Action) in *done* state */ - virtual ActionList* getDoneActionSet() const { return doneActionSet_; } + /** @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) */ - virtual ActionLmmListPtr getModifiedSet() const { return modifiedSet_; } + Action::ModifiedSet* get_modified_set() const; /** @brief Get the maxmin system of the current Model */ - lmm_system_t getMaxminSystem() const { return maxminSystem_; } + lmm::System* get_maxmin_system() const { return maxmin_system_; } - /** - * @brief Get the update mechanism of the current Model - * @see e_UM_t - */ - e_UM_t getUpdateMechanism() const { return updateMechanism_; } - void setUpdateMechanism(e_UM_t mechanism) { updateMechanism_ = mechanism; } + /** @brief Set the maxmin system of the current Model */ + void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; } - /** @brief Get Action heap */ - heap_type& getActionHeap() { return actionHeap_; } + /** @brief Get the update algorithm of the current Model */ + UpdateAlgo get_update_algorithm() const { return update_algorithm_; } - double actionHeapTopDate() const { return actionHeap_.top().first; } - Action* actionHeapPop(); - bool actionHeapIsEmpty() const { return actionHeap_.empty(); } + /** @brief Get Action heap */ + ActionHeap& get_action_heap() { return action_heap_; } /** * @brief Share the resources between the actions @@ -59,9 +67,9 @@ public: * @param now The current time of the simulation * @return The delta of time till the next action will finish */ - virtual double nextOccuringEvent(double now); - virtual double nextOccuringEventLazy(double now); - virtual double nextOccuringEventFull(double now); + virtual double next_occuring_event(double now); + virtual double next_occuring_event_lazy(double now); + virtual double next_occuring_event_full(double now); /** * @brief Update action to the current time @@ -69,29 +77,27 @@ public: * @param now The current time of the simulation * @param delta The delta of time since the last update */ - virtual void updateActionsState(double now, double delta); - virtual void updateActionsStateLazy(double now, double delta); - virtual void updateActionsStateFull(double now, double delta); + virtual void update_actions_state(double now, double delta); + virtual void update_actions_state_lazy(double now, double delta); + virtual void update_actions_state_full(double now, double delta); - /** @brief Returns whether this model have an idempotent shareResource() + /** @brief Returns whether this model have an idempotent share_resource() * * The only model that is not is NS3: computing the next timestamp moves the model up to that point, * so we need to call it only when the next timestamp of other sources is computed. */ - virtual bool nextOccuringEventIsIdempotent() { return true; } - -protected: - ActionLmmListPtr modifiedSet_; - lmm_system_t maxminSystem_ = nullptr; - bool selectiveUpdate_; + virtual bool next_occuring_event_is_idempotent() { return true; } private: - e_UM_t updateMechanism_ = UM_UNDEFINED; - ActionList* readyActionSet_; /**< Actions in state SURF_ACTION_READY */ - ActionList* runningActionSet_; /**< Actions in state SURF_ACTION_RUNNING */ - ActionList* failedActionSet_; /**< Actions in state SURF_ACTION_FAILED */ - ActionList* doneActionSet_; /**< Actions in state SURF_ACTION_DONE */ - heap_type actionHeap_; + lmm::System* maxmin_system_ = nullptr; + const UpdateAlgo update_algorithm_; + Action::StateSet* inited_action_set_ = new Action::StateSet(); /**< Created not started */ + 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_; }; } // namespace resource