From: Frederic Suter Date: Tue, 20 Mar 2018 13:50:48 +0000 (+0100) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3.19~11 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/08ddd90ede6ae87880ab6aefe213001b224de841?hp=28d54bec9f86b7f4ead97559ab906c86a4f6d3ca Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 6e8fdd02ea..392a3f8d2a 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -52,6 +52,7 @@ namespace resource { class Action; class Model; class Resource; +class TraceEvent; } namespace routing { class ClusterCreationArgs; 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/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index f70ea2da46..1c281bc64a 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -6,7 +6,10 @@ #ifndef SIMGRID_KERNEL_RESOURCE_RESOURCE_HPP #define SIMGRID_KERNEL_RESOURCE_RESOURCE_HPP -#include "src/surf/surf_interface.hpp" +#include +#include +#include +#include namespace simgrid { namespace kernel { @@ -45,7 +48,7 @@ public: * @param event What happened * @param value [TODO] */ - virtual void apply_event(tmgr_trace_event_t event, double value) = 0; + virtual void apply_event(TraceEvent* event, double value) = 0; /** @brief Check if the current Resource is used (if it currently serves an action) */ virtual bool isUsed() = 0; @@ -76,9 +79,9 @@ private: protected: struct Metric { - double peak; /**< The peak of the metric, ie its max value */ - double scale; /**< Current availability of the metric according to the traces, in [0,1] */ - tmgr_trace_event_t event; /**< The associated trace event associated to the metric */ + double peak; /**< The peak of the metric, ie its max value */ + double scale; /**< Current availability of the metric according to the traces, in [0,1] */ + TraceEvent* event; /**< The associated trace event associated to the metric */ }; }; } // namespace resource diff --git a/include/simgrid/kernel/routing/EmptyZone.hpp b/include/simgrid/kernel/routing/EmptyZone.hpp index 8f13116462..cb64ff5ed5 100644 --- a/include/simgrid/kernel/routing/EmptyZone.hpp +++ b/include/simgrid/kernel/routing/EmptyZone.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. 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. */ @@ -6,7 +6,7 @@ #ifndef SURF_ROUTING_NONE_HPP_ #define SURF_ROUTING_NONE_HPP_ -#include "simgrid/kernel/routing/NetZoneImpl.hpp" +#include namespace simgrid { namespace kernel { diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index afb2d38970..f1b55e6217 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -6,12 +6,11 @@ #ifndef SIMGRID_ROUTING_NETZONEIMPL_HPP #define SIMGRID_ROUTING_NETZONEIMPL_HPP -#include - -#include "xbt/graph.h" +#include +#include +#include -#include "simgrid/forward.h" -#include "simgrid/s4u/NetZone.hpp" +#include namespace simgrid { namespace kernel { diff --git a/include/simgrid/kernel/routing/RoutedZone.hpp b/include/simgrid/kernel/routing/RoutedZone.hpp index f8ab5d16f6..efe37297ae 100644 --- a/include/simgrid/kernel/routing/RoutedZone.hpp +++ b/include/simgrid/kernel/routing/RoutedZone.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2013-2018. 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. */ @@ -6,7 +6,7 @@ #ifndef SIMGRID_ROUTING_GENERIC_HPP_ #define SIMGRID_ROUTING_GENERIC_HPP_ -#include "simgrid/kernel/routing/NetZoneImpl.hpp" +#include namespace simgrid { namespace kernel { diff --git a/include/xbt/mmalloc.h b/src/include/xbt/mmalloc.h similarity index 87% rename from include/xbt/mmalloc.h rename to src/include/xbt/mmalloc.h index 62d0a00805..ab6ca00e2a 100644 --- a/include/xbt/mmalloc.h +++ b/src/include/xbt/mmalloc.h @@ -12,11 +12,11 @@ #include "src/internal_config.h" #if HAVE_MMALLOC -# include /* for size_t */ -# include /* for NULL */ +#include /* for NULL */ +#include /* for size_t */ -#include "xbt/dynar.h" #include "xbt/dict.h" +#include "xbt/dynar.h" SG_BEGIN_DECL() @@ -27,13 +27,13 @@ SG_BEGIN_DECL() * The heap structure itself is an opaque object that shouldnt be messed with. */ typedef struct mdesc s_xbt_mheap_t; -typedef struct mdesc *xbt_mheap_t; +typedef struct mdesc* xbt_mheap_t; /* Allocate SIZE bytes of memory (and memset it to 0). */ XBT_PUBLIC void* mmalloc(xbt_mheap_t md, size_t size); /* Allocate SIZE bytes of memory (and don't mess with it) */ -void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size); +void* mmalloc_no_memset(xbt_mheap_t mdp, size_t size); /* Re-allocate the previously allocated block in void*, making the new block SIZE bytes long. */ XBT_PUBLIC void* mrealloc(xbt_mheap_t md, void* ptr, size_t size); @@ -59,11 +59,11 @@ xbt_mheap_t mmalloc_set_current_heap(xbt_mheap_t new_heap); xbt_mheap_t mmalloc_get_current_heap(void); size_t mmalloc_get_bytes_used(xbt_mheap_t); -ssize_t mmalloc_get_busy_size(xbt_mheap_t, void *ptr); +ssize_t mmalloc_get_busy_size(xbt_mheap_t, void* ptr); void* malloc_no_memset(size_t n); SG_END_DECL() #endif -#endif /* SIMGRID_MMALLOC_H */ +#endif /* SIMGRID_MMALLOC_H */ 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); diff --git a/src/surf/trace_mgr.cpp b/src/surf/trace_mgr.cpp index 07c5ba6f3e..2e2743ff2c 100644 --- a/src/surf/trace_mgr.cpp +++ b/src/surf/trace_mgr.cpp @@ -126,7 +126,7 @@ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::add_trace(tmgr_trace_t tr { tmgr_trace_event_t trace_iterator = nullptr; - trace_iterator = new s_tmgr_trace_event_t; + trace_iterator = new simgrid::kernel::resource::TraceEvent(); trace_iterator->trace = trace; trace_iterator->idx = 0; trace_iterator->resource = resource; diff --git a/src/surf/trace_mgr.hpp b/src/surf/trace_mgr.hpp index 28cf31937d..bcd2151a92 100644 --- a/src/surf/trace_mgr.hpp +++ b/src/surf/trace_mgr.hpp @@ -11,16 +11,24 @@ #include #include -extern "C" { /* Iterator within a trace */ -struct s_tmgr_trace_event_t { +namespace simgrid { +namespace kernel { +namespace resource { +class TraceEvent { +public: tmgr_trace_t trace; unsigned int idx; sg_resource_t resource; bool free_me; }; -typedef s_tmgr_trace_event_t* tmgr_trace_event_t; + +} // namespace resource +} // namespace kernel +} // namespace simgrid +typedef simgrid::kernel::resource::TraceEvent* tmgr_trace_event_t; +extern "C" { /** * \brief Free a trace event structure diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 7725339e49..6d81ef13e3 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -8,6 +8,7 @@ set(EXTRA_DIST src/include/simgrid/sg_config.h src/include/surf/surf.hpp src/include/xbt/parmap.hpp + src/include/xbt/mmalloc.h src/mc/mc_mmu.hpp src/mc/mc_record.hpp src/mc/PageStore.hpp @@ -741,7 +742,6 @@ set(headers_to_install include/xbt/log.hpp include/xbt/mallocator.h include/xbt/misc.h - include/xbt/mmalloc.h include/xbt/module.h include/xbt/parmap.h include/xbt/range.hpp