From: Martin Quinson Date: Tue, 21 Nov 2023 13:53:32 +0000 (+0100) Subject: Merge branch 'master' of framagit.org:simgrid/simgrid X-Git-Tag: v3.35~7 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/365a83d3a1407923acccab758f9225e11408b5c6?hp=3fad6617c013e4fca6b2333a85751079421baaf4 Merge branch 'master' of framagit.org:simgrid/simgrid --- diff --git a/ChangeLog b/ChangeLog index 915012c79a..1ef61d16df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -60,6 +60,9 @@ Python: - Comm::waitall/waitany/testany() are gone. Please use ActivitySet() instead. - Comm::waitallfor() is gone too. Its semantic was unclear on timeout anyway. - Io::waitany() and waitanyfor() are gone. Please use ActivitySet() instead. + - Do not export the values of enums. So you need to write e.g. SharingPolicy.LINEAR + while it should have been possible to write LINEAR alone before. This is the advised + behavior for modern C++ code. C API: - Introduce sg_activity_set_t and deprecate wait_all/wait_any/test_any for diff --git a/docs/find-missing.ignore b/docs/find-missing.ignore index f7581519da..bd2d73068c 100644 --- a/docs/find-missing.ignore +++ b/docs/find-missing.ignore @@ -20,6 +20,7 @@ It is only used by find-missing, that will not report any definition linked here # These are used to make the C++ objects visible from the C world .. doxygentypedef:: s4u_Actor +.. doxygentypedef:: s4u_ActivitySet .. doxygentypedef:: s4u_Barrier .. doxygentypedef:: s4u_Comm .. doxygentypedef:: s4u_ConditionVariable diff --git a/docs/find-missing.py b/docs/find-missing.py index 7d370d5ba0..ac61890030 100755 --- a/docs/find-missing.py +++ b/docs/find-missing.py @@ -94,6 +94,9 @@ def handle_python_module(fullname, englobing, elm): elif isinstance(elm, (int, str)): # We do have such a data, directly in the SimGrid top module found_decl("data", fullname) # print('.. autodata:: {}'.format(fullname)) + elif inspect.isclass(type(elm)): # Enum classes are of that kind + found_decl("data", fullname) + #print('.. autodata:: {}'.format(fullname)) elif inspect.ismodule(elm) or inspect.isclass(elm): for name, data in inspect.getmembers(elm): if name.startswith('__'): @@ -101,7 +104,7 @@ def handle_python_module(fullname, englobing, elm): # print("Recurse on {}.{}".format(fullname, name)) handle_python_module("{}.{}".format(fullname, name), elm, data) else: - print('UNHANDLED TYPE {} : {!r} Type: {}'.format(fullname, elm, type(elm))) + print('UNHANDLED TYPE {} : {!r} Type: {} Englobing: {} str: {} Members: \n{}\n'.format(fullname, elm, type(elm), englobing, str(elm), inspect.getmembers(elm))) # Start the recursion on the provided Python modules for name in python_modules: diff --git a/docs/source/app_s4u.rst b/docs/source/app_s4u.rst index 84c2a706e5..ff648e0f6f 100644 --- a/docs/source/app_s4u.rst +++ b/docs/source/app_s4u.rst @@ -1200,11 +1200,17 @@ Querying info .. doxygenfunction:: simgrid::s4u::Disk::set_property(const std::string &, const std::string &value) .. doxygenfunction:: simgrid::s4u::Disk::set_sharing_policy + .. doxygenenum:: simgrid::s4u::Disk::Operation + .. doxygenenum:: simgrid::s4u::Disk::SharingPolicy + .. group-tab:: Python .. autoattribute:: simgrid.Disk.name .. automethod:: simgrid.Disk.set_sharing_policy + .. autoclass:: simgrid.Disk.Operation + .. autoclass:: simgrid.Disk.SharingPolicy + I/O operations -------------- @@ -1611,52 +1617,70 @@ Querying info .. group-tab:: C++ - .. doxygenfunction:: simgrid::s4u::Link::get_bandwidth() const .. doxygenfunction:: simgrid::s4u::Link::get_cname() const - .. doxygenfunction:: simgrid::s4u::Link::get_latency() const .. doxygenfunction:: simgrid::s4u::Link::get_name() const - .. doxygenfunction:: simgrid::s4u::Link::get_sharing_policy() const - .. doxygenfunction:: simgrid::s4u::Link::get_concurrency_limit() const .. doxygenfunction:: simgrid::s4u::Link::get_load() const .. doxygenfunction:: simgrid::s4u::Link::is_used() const .. group-tab:: Python - .. autoattribute:: simgrid.Link.bandwidth - .. autoattribute:: simgrid.Link.latency + .. autoattribute:: simgrid.Link.name .. group-tab:: C - .. doxygenfunction:: sg_link_get_bandwidth(const_sg_link_t link) - .. doxygenfunction:: sg_link_get_latency(const_sg_link_t link) .. doxygenfunction:: sg_link_get_name(const_sg_link_t link) .. doxygenfunction:: sg_link_is_shared(const_sg_link_t link) -Modifying characteristics -------------------------- +Performance +----------- .. tabs:: .. group-tab:: C++ + .. doxygenfunction:: simgrid::s4u::Link::get_bandwidth() const + .. doxygenfunction:: simgrid::s4u::Link::get_latency() const .. doxygenfunction:: simgrid::s4u::Link::set_bandwidth(double value) .. doxygenfunction:: simgrid::s4u::Link::set_latency(double value) .. doxygenfunction:: simgrid::s4u::Link::set_latency(const std::string& value) - .. doxygenfunction:: simgrid::s4u::Link::set_concurrency_limit(int limit) - .. doxygenfunction:: simgrid::s4u::Link::set_sharing_policy .. group-tab:: Python + .. autoattribute:: simgrid.Link.bandwidth + .. autoattribute:: simgrid.Link.latency .. automethod:: simgrid.Link.set_bandwidth .. automethod:: simgrid.Link.set_latency - .. automethod:: simgrid.Link.set_concurrency_limit - .. automethod:: simgrid.Link.set_sharing_policy .. group-tab:: C + .. doxygenfunction:: sg_link_get_bandwidth(const_sg_link_t link) + .. doxygenfunction:: sg_link_get_latency(const_sg_link_t link) .. doxygenfunction:: sg_link_set_bandwidth(sg_link_t link, double value) .. doxygenfunction:: sg_link_set_latency(sg_link_t link, double value) +Model policy +------------ + +.. tabs:: + + .. group-tab:: C++ + + .. doxygenenum:: simgrid::s4u::Link::SharingPolicy + + .. doxygenfunction:: simgrid::s4u::Link::get_sharing_policy() const + .. doxygenfunction:: simgrid::s4u::Link::set_sharing_policy + + .. doxygenfunction:: simgrid::s4u::Link::get_concurrency_limit() const + .. doxygenfunction:: simgrid::s4u::Link::set_concurrency_limit(int limit) + + .. group-tab:: Python + + .. automethod:: simgrid.Link.set_concurrency_limit + .. automethod:: simgrid.Link.set_sharing_policy + + .. group-tab:: C + + User data and properties ------------------------ diff --git a/examples/python/comm-ready/comm-ready.py b/examples/python/comm-ready/comm-ready.py index f874bd9748..20065327c5 100644 --- a/examples/python/comm-ready/comm-ready.py +++ b/examples/python/comm-ready/comm-ready.py @@ -58,7 +58,7 @@ def peer(my_id: int, message_count: int, payload_size: int, peers_count: int): start = Engine.clock received: str = my_mailbox.get() waiting_time = Engine.clock - start - if waiting_time != 0.0: + if waiting_time > 0.0: raise AssertionError(f"Expecting the waiting time to be 0.0 because the communication was supposedly " f"ready, but got {waiting_time} instead") this_actor.info(f"I got a '{received}'.") diff --git a/examples/sthread/pthread-mutex-recursive.c b/examples/sthread/pthread-mutex-recursive.c index 482cf3ee7f..63c9cccb23 100644 --- a/examples/sthread/pthread-mutex-recursive.c +++ b/examples/sthread/pthread-mutex-recursive.c @@ -40,7 +40,8 @@ static void* thread_function(void* arg) int main() { - pthread_t thread1, thread2; + pthread_t thread1; + pthread_t thread2; pthread_mutex_t mutex_dflt = PTHREAD_MUTEX_INITIALIZER; // Non-recursive mutex pthread_mutexattr_t attr; diff --git a/include/simgrid/plugins/battery.hpp b/include/simgrid/plugins/battery.hpp index 61937a91a6..fc395053df 100644 --- a/include/simgrid/plugins/battery.hpp +++ b/include/simgrid/plugins/battery.hpp @@ -105,7 +105,7 @@ private: double energy_consumed_j_ = 0; double last_updated_ = 0; - explicit Battery(); + explicit Battery() = default; explicit Battery(const std::string& name, double state_of_charge, double nominal_charge_power_w, double nominal_discharge_power_w, double charge_efficiency, double discharge_efficiency, double initial_capacity_wh, int cycles); @@ -133,7 +133,7 @@ public: void set_load(const std::string& name, double power_w); void set_load(const std::string& name, bool active); void connect_host(s4u::Host* host, bool active = true); - std::string get_name() {return name_;} + std::string get_name() const { return name_; } double get_state_of_charge(); double get_state_of_health(); double get_capacity(); diff --git a/include/simgrid/plugins/chiller.hpp b/include/simgrid/plugins/chiller.hpp index 11fa173477..78d1db0343 100644 --- a/include/simgrid/plugins/chiller.hpp +++ b/include/simgrid/plugins/chiller.hpp @@ -100,7 +100,7 @@ public: double get_temp_in() { return temp_in_c_; } double get_power() { return power_w_; } double get_energy_consumed() { return energy_consumed_j_; } - double get_time_to_goal_temp(); + double get_time_to_goal_temp() const; }; } // namespace simgrid::plugins diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index fbef8cccc9..2bdb4a9cce 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -93,8 +93,8 @@ public: /** @verbatim embed:rst:inline Bind an actor name that could be found in :ref:`pf_tag_actor` tag to a class name passed as a template parameter. See the :ref:`example `. @endverbatim */ template void register_actor(const std::string& name) { - kernel::actor::ActorCodeFactory code_factory = [](std::vector args) { - return kernel::actor::ActorCode([args = std::move(args)]() mutable { + kernel::actor::ActorCodeFactory code_factory = [](std::vector args_factory) { + return kernel::actor::ActorCode([args = std::move(args_factory)]() mutable { F code(std::move(args)); code(); }); @@ -104,8 +104,8 @@ public: /** @verbatim embed:rst:inline Bind an actor name that could be found in :ref:`pf_tag_actor` tag to a function name passed as a parameter. See the :ref:`example `. @endverbatim */ template void register_actor(const std::string& name, F code) { - kernel::actor::ActorCodeFactory code_factory = [code](std::vector args) { - return kernel::actor::ActorCode([code, args = std::move(args)]() mutable { code(std::move(args)); }); + kernel::actor::ActorCodeFactory code_factory = [code](std::vector args_factory) { + return kernel::actor::ActorCode([code, args = std::move(args_factory)]() mutable { code(std::move(args)); }); }; register_function(name, code_factory); } diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index c79ca462ac..c2ac18e036 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -45,7 +45,21 @@ protected: #endif public: - enum class SharingPolicy { NONLINEAR = 4, WIFI = 3, SPLITDUPLEX = 2, SHARED = 1, FATPIPE = 0 }; + /** Specifies how a given link is shared between concurrent communications */ + enum class SharingPolicy { + /// This policy takes a callback that specifies the maximal capacity as a function of the number of usage. See the + /// examples with 'degradation' in their name. + NONLINEAR = 4, + /// Pseudo-sharing policy requesting wifi-specific sharing. + WIFI = 3, + /// Each link is split in 2, UP and DOWN, one per direction. These links are SHARED. + SPLITDUPLEX = 2, + /// The bandwidth is shared between all comms using that link, regardless of their direction. + SHARED = 1, + /// Each comm can use the link fully, with no sharing (only a maximum). This is intended to represent the backbone + /// links that cannot be saturated by concurrent links, but have a maximal bandwidth. + FATPIPE = 0 + }; kernel::resource::StandardLinkImpl* get_impl() const; diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index 76125f3c49..ab535fa289 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -62,7 +62,7 @@ public: /** @brief Get the gateway associated to this netzone */ kernel::routing::NetPoint* get_gateway() const; kernel::routing::NetPoint* get_gateway(const std::string& name) const; - void set_gateway(s4u::Host* router) { set_gateway(router->get_netpoint()); } + void set_gateway(const s4u::Host* router) { set_gateway(router->get_netpoint()); } void set_gateway(kernel::routing::NetPoint* router); void set_gateway(const std::string& name, kernel::routing::NetPoint* router); diff --git a/include/simgrid/s4u/Task.hpp b/include/simgrid/s4u/Task.hpp index 28a9211376..4c44875690 100644 --- a/include/simgrid/s4u/Task.hpp +++ b/include/simgrid/s4u/Task.hpp @@ -55,7 +55,7 @@ protected: virtual void fire(std::string instance); void complete(std::string instance); - void store_activity(ActivityPtr a, std::string instance) { current_activities_[instance].push_back(a); } + void store_activity(ActivityPtr a, const std::string& instance) { current_activities_[instance].push_back(a); } virtual void add_instances(int n); virtual void remove_instances(int n); diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 7cac37dac4..7f5f6b9ed0 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -294,7 +294,7 @@ PYBIND11_MODULE(simgrid, m) .def("create_router", &simgrid::s4u::NetZone::create_router, "Create a router") .def("set_parent", &simgrid::s4u::NetZone::set_parent, "Set the parent of this zone") .def("set_property", &simgrid::s4u::NetZone::set_property, "Add a property to this zone") - .def("set_gateway", py::overload_cast(&simgrid::s4u::NetZone::set_gateway), + .def("set_gateway", py::overload_cast(&simgrid::s4u::NetZone::set_gateway), "Specify the gateway of this zone, to be used for inter-zone routes") .def("set_gateway", py::overload_cast(&simgrid::s4u::NetZone::set_gateway), "Specify the gateway of this zone, to be used for inter-zone routes") @@ -452,8 +452,7 @@ PYBIND11_MODULE(simgrid, m) py::enum_(host, "SharingPolicy") .value("NONLINEAR", simgrid::s4u::Host::SharingPolicy::NONLINEAR) - .value("LINEAR", simgrid::s4u::Host::SharingPolicy::LINEAR) - .export_values(); + .value("LINEAR", simgrid::s4u::Host::SharingPolicy::LINEAR); /* Class Disk */ py::class_> disk( @@ -476,13 +475,11 @@ PYBIND11_MODULE(simgrid, m) "Textual representation of the Disk"); py::enum_(disk, "SharingPolicy") .value("NONLINEAR", simgrid::s4u::Disk::SharingPolicy::NONLINEAR) - .value("LINEAR", simgrid::s4u::Disk::SharingPolicy::LINEAR) - .export_values(); + .value("LINEAR", simgrid::s4u::Disk::SharingPolicy::LINEAR); py::enum_(disk, "Operation") .value("READ", simgrid::s4u::Disk::Operation::READ) .value("WRITE", simgrid::s4u::Disk::Operation::WRITE) - .value("READWRITE", simgrid::s4u::Disk::Operation::READWRITE) - .export_values(); + .value("READWRITE", simgrid::s4u::Disk::Operation::READWRITE); /* Class NetPoint */ py::class_> @@ -574,12 +571,17 @@ PYBIND11_MODULE(simgrid, m) "__repr__", [](const Link* l) { return "Link(" + l->get_name() + ")"; }, "Textual representation of the Link"); py::enum_(link, "SharingPolicy") - .value("NONLINEAR", Link::SharingPolicy::NONLINEAR) - .value("WIFI", Link::SharingPolicy::WIFI) - .value("SPLITDUPLEX", Link::SharingPolicy::SPLITDUPLEX) - .value("SHARED", Link::SharingPolicy::SHARED) - .value("FATPIPE", Link::SharingPolicy::FATPIPE) - .export_values(); + .value("NONLINEAR", Link::SharingPolicy::NONLINEAR, + "This policy takes a callback that specifies the maximal capacity as a function of the number of usage. " + "See the examples with 'degradation' in their name.") + .value("WIFI", Link::SharingPolicy::WIFI, "Pseudo-sharing policy requesting wifi-specific sharing.") + .value("SPLITDUPLEX", Link::SharingPolicy::SPLITDUPLEX, + "Each link is split in 2, UP and DOWN, one per direction. These links are SHARED.") + .value("SHARED", Link::SharingPolicy::SHARED, + "The bandwidth is shared between all comms using that link, regardless of their direction.") + .value("FATPIPE", Link::SharingPolicy::FATPIPE, + "Each comm can use the link fully, with no sharing (only a maximum). This is intended to represent the " + "backbone links that cannot be saturated by concurrent links, but have a maximal bandwidth."); /* Class LinkInRoute */ py::class_ linkinroute(m, "LinkInRoute", "Abstraction to add link in routes"); @@ -588,8 +590,7 @@ PYBIND11_MODULE(simgrid, m) py::enum_(linkinroute, "Direction") .value("UP", simgrid::s4u::LinkInRoute::Direction::UP) .value("DOWN", simgrid::s4u::LinkInRoute::Direction::DOWN) - .value("NONE", simgrid::s4u::LinkInRoute::Direction::NONE) - .export_values(); + .value("NONE", simgrid::s4u::LinkInRoute::Direction::NONE); /* Class Split-Duplex Link */ py::class_>( diff --git a/src/kernel/activity/MutexImpl.hpp b/src/kernel/activity/MutexImpl.hpp index 75cb5d6874..8bf71be533 100644 --- a/src/kernel/activity/MutexImpl.hpp +++ b/src/kernel/activity/MutexImpl.hpp @@ -52,10 +52,10 @@ class XBT_PUBLIC MutexAcquisitionImpl : public ActivityImpl_Tget_id() : 0)) + " mbox:" + - std::to_string(mbox_->get_id()) + " tag: " + std::to_string(tag_) + ")"; + return "CommAsyncSend(comm_id: " + std::to_string(comm_ ? comm_->get_id() : 0) + + " mbox:" + std::to_string(mbox_->get_id()) + " tag: " + std::to_string(tag_) + ")"; } void CommIrecvSimcall::serialize(std::stringstream& stream) const @@ -237,8 +237,8 @@ void CommIrecvSimcall::serialize(std::stringstream& stream) const std::string CommIrecvSimcall::to_string() const { - return "CommAsyncRecv(comm_id: " + std::to_string((comm_ ? comm_->get_id() : 0)) + " mbox:" + - std::to_string(mbox_->get_id()) + " tag: " + std::to_string(tag_) + ")"; + return "CommAsyncRecv(comm_id: " + std::to_string(comm_ ? comm_->get_id() : 0) + + " mbox:" + std::to_string(mbox_->get_id()) + " tag: " + std::to_string(tag_) + ")"; } void MessIputSimcall::serialize(std::stringstream& stream) const diff --git a/src/kernel/actor/SimcallObserver.hpp b/src/kernel/actor/SimcallObserver.hpp index c7d1353620..de3f4fc27c 100644 --- a/src/kernel/actor/SimcallObserver.hpp +++ b/src/kernel/actor/SimcallObserver.hpp @@ -111,7 +111,7 @@ public: class ActorSleepSimcall final : public SimcallObserver { public: - ActorSleepSimcall(ActorImpl* actor) : SimcallObserver(actor) {} + explicit ActorSleepSimcall(ActorImpl* actor) : SimcallObserver(actor) {} void serialize(std::stringstream& stream) const override; std::string to_string() const override; }; diff --git a/src/mc/api/State.cpp b/src/mc/api/State.cpp index 52ffde6044..f537a484b5 100644 --- a/src/mc/api/State.cpp +++ b/src/mc/api/State.cpp @@ -245,7 +245,7 @@ void State::sprout_tree_from_parent_state() "to schedule from the wakeup tree? Trace so far:", get_transition_in()->to_string(false).c_str(), get_transition_in()->aid_, min_process_node.value()->get_action()->to_string(false).c_str(), min_process_node.value()->get_actor()); - for (auto elm : Exploration::get_instance()->get_textual_trace()) + for (auto const& elm : Exploration::get_instance()->get_textual_trace()) XBT_ERROR("%s", elm.c_str()); xbt_abort(); } diff --git a/src/mc/api/strategy/BasicStrategy.hpp b/src/mc/api/strategy/BasicStrategy.hpp index 3d7d01bbd6..ca44509880 100644 --- a/src/mc/api/strategy/BasicStrategy.hpp +++ b/src/mc/api/strategy/BasicStrategy.hpp @@ -31,7 +31,7 @@ public: "--cfg=model-check/max-depth. Here are the 100 first trace elements", _sg_mc_max_depth.get()); auto trace = Exploration::get_instance()->get_textual_trace(100); - for (auto elm : trace) + for (auto const& elm : trace) XBT_CERROR(mc_dfs, " %s", elm.c_str()); xbt_die("Aborting now."); } diff --git a/src/mc/explo/DFSExplorer.cpp b/src/mc/explo/DFSExplorer.cpp index 0466d6654f..b328d15773 100644 --- a/src/mc/explo/DFSExplorer.cpp +++ b/src/mc/explo/DFSExplorer.cpp @@ -433,7 +433,7 @@ void DFSExplorer::backtrack() // Search how to restore the backtracking point std::deque replay_recipe; - for (auto* s = backtracking_point.get(); s != nullptr; s = s->get_parent_state().get()) { + for (const auto* s = backtracking_point.get(); s != nullptr; s = s->get_parent_state().get()) { if (s->get_transition_in() != nullptr) // The root has no transition_in replay_recipe.push_front(s->get_transition_in().get()); } diff --git a/src/mc/transition/TransitionActor.cpp b/src/mc/transition/TransitionActor.cpp index 16a17a3d09..3e1027b576 100644 --- a/src/mc/transition/TransitionActor.cpp +++ b/src/mc/transition/TransitionActor.cpp @@ -49,18 +49,14 @@ bool ActorJoinTransition::depends(const Transition* other) const bool ActorJoinTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::ACTOR_JOIN: - // ActorJoin races with another event iff its target `T` is the same as - // the actor executing the other transition. Clearly, then, we could not join - // on that actor `T` and then run a transition by `T`, so no race is reversible - return false; - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::ACTOR_JOIN, "Unexpected transition type %s", to_c_str(type_)); + + // ActorJoin races with another event iff its target `T` is the same as the actor executing the other transition. + // Clearly, then, we could not join on that actor `T` and then run a transition by `T`, so no race is reversible + return false; } -ActorSleepTransition::ActorSleepTransition(aid_t issuer, int times_considered, std::stringstream& stream) +ActorSleepTransition::ActorSleepTransition(aid_t issuer, int times_considered, std::stringstream&) : Transition(Type::ACTOR_SLEEP, issuer, times_considered) { XBT_DEBUG("ActorSleepTransition()"); @@ -81,12 +77,9 @@ bool ActorSleepTransition::depends(const Transition* other) const bool ActorSleepTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::ACTOR_SLEEP: - return true; // Always enabled - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::ACTOR_SLEEP, "Unexpected transition type %s", to_c_str(type_)); + + return true; // Always enabled } } // namespace simgrid::mc diff --git a/src/mc/transition/TransitionAny.cpp b/src/mc/transition/TransitionAny.cpp index 580fb44389..b3c7b63cb3 100644 --- a/src/mc/transition/TransitionAny.cpp +++ b/src/mc/transition/TransitionAny.cpp @@ -45,12 +45,9 @@ bool TestAnyTransition::depends(const Transition* other) const } bool TestAnyTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::TESTANY: - return true; // TestAny is always enabled - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::TESTANY, "Unexpected transition type %s", to_c_str(type_)); + + return true; // TestAny is always enabled } WaitAnyTransition::WaitAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream) @@ -81,13 +78,10 @@ bool WaitAnyTransition::depends(const Transition* other) const } bool WaitAnyTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::WAITANY: - // TODO: We need to check if any of the transitions waited on occurred before `e1` - return true; // Let's overapproximate to not miss branches - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::WAITANY, "Unexpected transition type %s", to_c_str(type_)); + + // TODO: We need to check if any of the transitions waited on occurred before `e1` + return true; // Let's overapproximate to not miss branches } } // namespace simgrid::mc diff --git a/src/mc/transition/TransitionComm.cpp b/src/mc/transition/TransitionComm.cpp index 19d8ebfde9..d23cd86fb8 100644 --- a/src/mc/transition/TransitionComm.cpp +++ b/src/mc/transition/TransitionComm.cpp @@ -59,13 +59,10 @@ bool CommWaitTransition::depends(const Transition* other) const bool CommWaitTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::COMM_WAIT: - // If the other event is a communication event, then we are not reversible; otherwise we are reversible. - return other->type_ != Transition::Type::COMM_ASYNC_SEND && other->type_ != Transition::Type::COMM_ASYNC_RECV; - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::COMM_WAIT, "Unexpected transition type %s", to_c_str(type_)); + + // If the other event is a communication event, then we are not reversible; otherwise we are reversible. + return other->type_ != Transition::Type::COMM_ASYNC_SEND && other->type_ != Transition::Type::COMM_ASYNC_RECV; } CommTestTransition::CommTestTransition(aid_t issuer, int times_considered, unsigned comm_, aid_t sender_, @@ -114,12 +111,8 @@ bool CommTestTransition::depends(const Transition* other) const bool CommTestTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::COMM_TEST: - return true; // CommTest is always enabled - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::COMM_TEST, "Unexpected transition type %s", to_c_str(type_)); + return true; // CommTest is always enabled } CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, int tag_) @@ -189,12 +182,9 @@ bool CommRecvTransition::depends(const Transition* other) const bool CommRecvTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::COMM_ASYNC_RECV: - return true; // CommRecv is always enabled - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::COMM_ASYNC_RECV, "Unexpected transition type %s", to_c_str(type_)); + + return true; // CommRecv is always enabled } CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, int tag_) @@ -265,12 +255,9 @@ bool CommSendTransition::depends(const Transition* other) const bool CommSendTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::COMM_ASYNC_SEND: - return true; // CommSend is always enabled - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::COMM_ASYNC_SEND, "Unexpected transition type %s", to_c_str(type_)); + + return true; // CommSend is always enabled } } // namespace simgrid::mc diff --git a/src/mc/transition/TransitionObjectAccess.cpp b/src/mc/transition/TransitionObjectAccess.cpp index 33b4163012..f32e459008 100644 --- a/src/mc/transition/TransitionObjectAccess.cpp +++ b/src/mc/transition/TransitionObjectAccess.cpp @@ -48,12 +48,9 @@ bool ObjectAccessTransition::depends(const Transition* o) const bool ObjectAccessTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::OBJECT_ACCESS: - return true; // Object access is always enabled - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::OBJECT_ACCESS, "Unexpected transition type %s", to_c_str(type_)); + + return true; // Object access is always enabled } } // namespace simgrid::mc diff --git a/src/mc/transition/TransitionRandom.cpp b/src/mc/transition/TransitionRandom.cpp index 81eab72a0d..7470be286d 100644 --- a/src/mc/transition/TransitionRandom.cpp +++ b/src/mc/transition/TransitionRandom.cpp @@ -25,12 +25,9 @@ RandomTransition::RandomTransition(aid_t issuer, int times_considered, std::stri bool RandomTransition::reversible_race(const Transition* other) const { - switch (type_) { - case Type::RANDOM: - return true; // Random is always enabled - default: - xbt_die("Unexpected transition type %s", to_c_str(type_)); - } + xbt_assert(type_ == Type::RANDOM, "Unexpected transition type %s", to_c_str(type_)); + + return true; // Random is always enabled } } // namespace simgrid::mc diff --git a/src/plugins/battery.cpp b/src/plugins/battery.cpp index c682e178ac..0cbfdbc8c5 100644 --- a/src/plugins/battery.cpp +++ b/src/plugins/battery.cpp @@ -270,8 +270,6 @@ double Battery::next_occurring_handler() return time_delta; } -Battery::Battery() {} - Battery::Battery(const std::string& name, double state_of_charge, double nominal_charge_power_w, double nominal_discharge_power_w, double charge_efficiency, double discharge_efficiency, double initial_capacity_wh, int cycles) diff --git a/src/plugins/chiller.cpp b/src/plugins/chiller.cpp index 7d2b9de4c7..0a4d3afe4d 100644 --- a/src/plugins/chiller.cpp +++ b/src/plugins/chiller.cpp @@ -283,7 +283,7 @@ ChillerPtr Chiller::remove_host(s4u::Host* host) /** @ingroup plugin_chiller * @return The time to reach to goal temp, assuming that the system remain in the same state. */ -double Chiller::get_time_to_goal_temp() +double Chiller::get_time_to_goal_temp() const { if (goal_temp_c_ == temp_in_c_) return 0; diff --git a/src/s4u/s4u_ActivitySet.cpp b/src/s4u/s4u_ActivitySet.cpp index 92a65cedf0..61957a3f9e 100644 --- a/src/s4u/s4u_ActivitySet.cpp +++ b/src/s4u/s4u_ActivitySet.cpp @@ -103,13 +103,13 @@ ActivityPtr ActivitySet::wait_any_for(double timeout) return ret; } catch (const HostFailureException& e) { handle_failed_activities(); - throw e; + throw; } catch (const NetworkFailureException& e) { handle_failed_activities(); - throw e; + throw; } catch (const StorageFailureException& e) { handle_failed_activities(); - throw e; + throw; } } diff --git a/src/smpi/bindings/smpi_pmpi_request.cpp b/src/smpi/bindings/smpi_pmpi_request.cpp index 73ea9b9b7c..0dc9e32f21 100644 --- a/src/smpi/bindings/smpi_pmpi_request.cpp +++ b/src/smpi/bindings/smpi_pmpi_request.cpp @@ -382,7 +382,7 @@ int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int CHECK_BUFFER(1, sendbuf, sendcount, sendtype) CHECK_BUFFER(6, recvbuf, recvcount, recvtype) CHECK_ARGS(sendbuf == recvbuf && sendcount > 0 && recvcount > 0, MPI_ERR_BUFFER, - "%s: Invalid parameters 1 and 6: sendbuf and recvbuf must be disjoint", __func__); + "%s: Invalid parameters 1 and 6: sendbuf and recvbuf must be disjoint", __func__) CHECK_TAG(10, recvtag) CHECK_COMM(11) const SmpiBenchGuard suspend_bench; @@ -443,7 +443,7 @@ int PMPI_Isendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, in CHECK_BUFFER(1, sendbuf, sendcount, sendtype) CHECK_BUFFER(6, recvbuf, recvcount, recvtype) CHECK_ARGS(sendbuf == recvbuf && sendcount > 0 && recvcount > 0, MPI_ERR_BUFFER, - "%s: Invalid parameters 1 and 6: sendbuf and recvbuf must be disjoint", __func__); + "%s: Invalid parameters 1 and 6: sendbuf and recvbuf must be disjoint", __func__) CHECK_TAG(10, recvtag) CHECK_COMM(11) CHECK_REQUEST(12) diff --git a/src/sthread/sthread.c b/src/sthread/sthread.c index af260220f2..ad27e3fa1d 100644 --- a/src/sthread/sthread.c +++ b/src/sthread/sthread.c @@ -30,7 +30,7 @@ static int (*raw_pthread_mutex_destroy)(pthread_mutex_t*); static int (*raw_pthread_mutexattr_init)(pthread_mutexattr_t*); static int (*raw_pthread_mutexattr_settype)(pthread_mutexattr_t*, int); -static int (*raw_pthread_mutexattr_gettype)(const pthread_mutexattr_t* restrict, int* restrict); +static int (*raw_pthread_mutexattr_gettype)(const pthread_mutexattr_t*, int*); static int (*raw_pthread_mutexattr_getrobust)(const pthread_mutexattr_t*, int*); static int (*raw_pthread_mutexattr_setrobust)(pthread_mutexattr_t*, int); @@ -125,12 +125,12 @@ void sthread_disable(void) intercepted_pthcall(mutexattr_init, (pthread_mutexattr_t * attr), (attr), ((sthread_mutexattr_t*)attr)); intercepted_pthcall(mutexattr_settype, (pthread_mutexattr_t * attr, int type), (attr, type), ((sthread_mutexattr_t*)attr, type)); -intercepted_pthcall(mutexattr_gettype, (const pthread_mutexattr_t* restrict attr, int* type), (attr, type), +intercepted_pthcall(mutexattr_gettype, (const pthread_mutexattr_t* attr, int* type), (attr, type), ((sthread_mutexattr_t*)attr, type)); -intercepted_pthcall(mutexattr_setrobust, (pthread_mutexattr_t* restrict attr, int robustness), (attr, robustness), +intercepted_pthcall(mutexattr_setrobust, (pthread_mutexattr_t * attr, int robustness), (attr, robustness), + ((sthread_mutexattr_t*)attr, robustness)); +intercepted_pthcall(mutexattr_getrobust, (const pthread_mutexattr_t* attr, int* robustness), (attr, robustness), ((sthread_mutexattr_t*)attr, robustness)); -intercepted_pthcall(mutexattr_getrobust, (const pthread_mutexattr_t* restrict attr, int* restrict robustness), - (attr, robustness), ((sthread_mutexattr_t*)attr, robustness)); intercepted_pthcall(create, (pthread_t * thread, const pthread_attr_t* attr, void* (*start_routine)(void*), void* arg), (thread, attr, start_routine, arg), ((sthread_t*)thread, attr, start_routine, arg));