From: Martin Quinson Date: Tue, 20 Mar 2018 12:34:31 +0000 (+0100) Subject: do not load a private header from s/k/resource/ headers X-Git-Tag: v3.19~11^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/deaf4c6f1cb3026b053ca861fe77313c78385be7 do not load a private header from s/k/resource/ headers --- diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index 6154a6767c..d3b7a0497d 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -6,7 +6,14 @@ #ifndef SIMGRID_KERNEL_RESOURCE_ACTION_HPP #define SIMGRID_KERNEL_RESOURCE_ACTION_HPP -#include "src/surf/surf_interface.hpp" +#include +#include +#include + +#include +#include + +const int NO_MAX_DURATION = -1.0; namespace simgrid { namespace kernel { @@ -107,11 +114,11 @@ public: /** @brief Update the maximum duration of the current action * @param delta Amount to remove from the MaxDuration */ - void updateMaxDuration(double delta) { double_update(&maxDuration_, delta, sg_surf_precision); } + void updateMaxDuration(double delta); /** @brief Update the remaining time of the current action * @param delta Amount to remove from the remaining time */ - void updateRemains(double delta) { double_update(&remains_, delta, sg_maxmin_precision * sg_surf_precision); } + void updateRemains(double delta); /** @brief Set the remaining time of the current action */ void setRemains(double value) { remains_ = value; } @@ -188,7 +195,7 @@ private: boost::optional heapHandle_ = boost::none; public: - virtual void updateRemainingLazy(double now) { THROW_IMPOSSIBLE; }; + virtual void updateRemainingLazy(double now) = 0; void heapInsert(heap_type& heap, double key, Action::Type hat); void heapRemove(heap_type& heap); void heapUpdate(heap_type& heap, double key, Action::Type hat); @@ -196,7 +203,7 @@ public: kernel::lmm::Variable* getVariable() const { return variable_; } void setVariable(kernel::lmm::Variable* var) { variable_ = var; } double getLastUpdate() const { return lastUpdate_; } - void refreshLastUpdate() { lastUpdate_ = surf_get_clock(); } + void refreshLastUpdate(); double getLastValue() const { return lastValue_; } void setLastValue(double val) { lastValue_ = val; } Action::Type getType() const { return type_; } diff --git a/include/simgrid/kernel/resource/Model.hpp b/include/simgrid/kernel/resource/Model.hpp index 5855dda94c..98bc1587c5 100644 --- a/include/simgrid/kernel/resource/Model.hpp +++ b/include/simgrid/kernel/resource/Model.hpp @@ -8,6 +8,19 @@ #include +extern "C" { + +/** @brief Possible update mechanisms */ +enum e_UM_t { + UM_FULL, /**< Full update mechanism: the remaining time of every action is recomputed at each step */ + UM_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. */ + UM_UNDEFINED /**< Mechanism not defined */ +}; +} + namespace simgrid { namespace kernel { namespace resource { diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index 04840601ae..8559cca8db 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -6,6 +6,7 @@ #include "simgrid/kernel/resource/Action.hpp" #include "simgrid/kernel/resource/Model.hpp" #include "src/kernel/lmm/maxmin.hpp" +#include "src/surf/surf_interface.hpp" XBT_LOG_NEW_CATEGORY(kernel, "Logging specific to the internals of SimGrid"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(resource, kernel, "Logging specific to the resources"); @@ -227,6 +228,20 @@ double Action::getRemains() return remains_; } +void Action::updateMaxDuration(double delta) +{ + double_update(&maxDuration_, delta, sg_surf_precision); +} +void Action::updateRemains(double delta) +{ + double_update(&remains_, delta, sg_maxmin_precision * sg_surf_precision); +} + +void Action::refreshLastUpdate() +{ + lastUpdate_ = surf_get_clock(); +} + } // namespace surf } // namespace simgrid } // namespace simgrid diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index a2d9074599..71c87a1c4c 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -85,5 +85,10 @@ NetworkConstantAction::NetworkConstantAction(NetworkConstantModel* model_, doubl }; NetworkConstantAction::~NetworkConstantAction() = default; + +void NetworkConstantAction::updateRemainingLazy(double /*now*/) +{ + THROW_IMPOSSIBLE; +} } } diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index f12715bc4a..198dd8ac4e 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -42,6 +42,7 @@ namespace simgrid { NetworkConstantAction(NetworkConstantModel *model_, double size, double latency); ~NetworkConstantAction(); double initialLatency_; + void updateRemainingLazy(double now) override; }; } diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index ab86421b0c..0402324415 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -339,6 +339,10 @@ std::list NetworkNS3Action::links() { THROW_UNIMPLEMENTED; } +void NetworkNS3Action::updateRemainingLazy(double /*now*/) +{ + THROW_IMPOSSIBLE; +} /* Test whether a flow is suspended */ bool NetworkNS3Action::isSuspended() diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index 7ed353a5a3..f8e3e3c84d 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -52,6 +52,7 @@ public: void suspend() override; void resume() override; std::list links() override; + void updateRemainingLazy(double now) override; // private: double lastSent_ = 0; diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index cc8b5e1305..73e9415d54 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -188,6 +188,9 @@ void StorageN11Action::setSharingWeight(double /*priority*/) { THROW_UNIMPLEMENTED; } - +void StorageN11Action::updateRemainingLazy(double /*now*/) +{ + THROW_IMPOSSIBLE; +} } } diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index 9414ac6261..c38ec744e2 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -54,13 +54,14 @@ class StorageN11Action : public StorageAction { public: StorageN11Action(kernel::resource::Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type); - void suspend(); - int unref(); - void cancel(); - void resume(); - bool isSuspended(); - void setMaxDuration(double duration); - void setSharingWeight(double priority); + void suspend() override; + int unref() override; + void cancel() override; + void resume() override; + bool isSuspended() override; + void setMaxDuration(double duration) override; + void setSharingWeight(double priority) override; + void updateRemainingLazy(double now) override; }; } diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 24aa95f43f..09547f7a45 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -21,8 +21,6 @@ #include #include -#define NO_MAX_DURATION -1.0 - /********* * Utils * *********/ diff --git a/src/surf/surf_private.hpp b/src/surf/surf_private.hpp index b1f9e7c111..aa48911231 100644 --- a/src/surf/surf_private.hpp +++ b/src/surf/surf_private.hpp @@ -9,22 +9,8 @@ #include "src/surf/trace_mgr.hpp" #include "surf/surf.hpp" -#define NO_MAX_DURATION -1.0 - extern "C" { -/** @ingroup SURF_interface - * @brief Possible update mechanisms - */ -enum e_UM_t { - UM_FULL, /**< Full update mechanism: the remaining time of every action is recomputed at each step */ - UM_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. */ - UM_UNDEFINED /**< Mechanism not defined */ -}; - /* Generic functions common to all models */ XBT_PRIVATE FILE* surf_fopen(const char* name, const char* mode);