From 0758e803c55b61a32c41b83c60bd128edc22601f Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 4 Apr 2023 17:08:57 +0200 Subject: [PATCH] An integer seems good enough to handle priorities, and is not subject to rounding errors. --- src/mc/api/State.cpp | 2 +- src/mc/api/State.hpp | 4 ++-- src/mc/api/strategy/BasicStrategy.hpp | 6 +++--- src/mc/api/strategy/Strategy.hpp | 6 +++--- src/mc/api/strategy/WaitStrategy.hpp | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/mc/api/State.cpp b/src/mc/api/State.cpp index 69fae98b37..b5f8eba6a3 100644 --- a/src/mc/api/State.cpp +++ b/src/mc/api/State.cpp @@ -121,7 +121,7 @@ aid_t State::next_transition() const return -1; } -std::pair State::next_transition_guided() const +std::pair State::next_transition_guided() const { return strategy_->next_transition(); } diff --git a/src/mc/api/State.hpp b/src/mc/api/State.hpp index 2b2a62577b..6d984370d2 100644 --- a/src/mc/api/State.hpp +++ b/src/mc/api/State.hpp @@ -62,9 +62,9 @@ public: /* Returns a positive number if there is another transition to pick, or -1 if not */ aid_t next_transition() const; // this function should disapear as it is redundant with the next one - /* Same as next_transition, but choice is now guided, and a double corresponding to the + /* Same as next_transition, but choice is now guided, and an integer corresponding to the internal cost of the transition is returned */ - std::pair next_transition_guided() const; + std::pair next_transition_guided() const; /* Explore a new path on the remote app; the parameter 'next' must be the result of a previous call to * next_transition() */ diff --git a/src/mc/api/strategy/BasicStrategy.hpp b/src/mc/api/strategy/BasicStrategy.hpp index dfdbd5d546..93ebd6cc6c 100644 --- a/src/mc/api/strategy/BasicStrategy.hpp +++ b/src/mc/api/strategy/BasicStrategy.hpp @@ -16,7 +16,7 @@ public: return; } - std::pair next_transition() const override + std::pair next_transition() const override { for (auto const& [aid, actor] : actors_to_run_) { /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */ @@ -24,9 +24,9 @@ public: continue; } - return std::make_pair(aid, 1.0); + return std::make_pair(aid, 1); } - return std::make_pair(-1, 0.0); + return std::make_pair(-1, 0); } void execute_next(aid_t aid, RemoteApp& app) override { return; } diff --git a/src/mc/api/strategy/Strategy.hpp b/src/mc/api/strategy/Strategy.hpp index c1bf76b415..ef5b87f37b 100644 --- a/src/mc/api/strategy/Strategy.hpp +++ b/src/mc/api/strategy/Strategy.hpp @@ -23,9 +23,9 @@ public: return; } - virtual std::pair next_transition() const = 0; - virtual void execute_next(aid_t aid, RemoteApp& app) = 0; - virtual void consider_best() = 0; + virtual std::pair next_transition() const = 0; + virtual void execute_next(aid_t aid, RemoteApp& app) = 0; + virtual void consider_best() = 0; // Mark the first enabled and not yet done transition as todo // If there's already a transition marked as todo, does nothing diff --git a/src/mc/api/strategy/WaitStrategy.hpp b/src/mc/api/strategy/WaitStrategy.hpp index edf75b2f39..e2d466b3a7 100644 --- a/src/mc/api/strategy/WaitStrategy.hpp +++ b/src/mc/api/strategy/WaitStrategy.hpp @@ -13,8 +13,8 @@ namespace simgrid::mc { /** Wait MC guiding class that aims at minimizing the number of in-fly communication. * When possible, it will try to take the wait transition. */ class WaitStrategy : public Strategy { - double taken_wait_ = 0; - bool taking_wait_ = false; + int taken_wait_ = 0; + bool taking_wait_ = false; public: void operator=(const WaitStrategy& guide) { taken_wait_ = guide.taken_wait_; } @@ -25,9 +25,9 @@ public: type == Transition::Type::MUTEX_WAIT or type == Transition::Type::SEM_WAIT; } - std::pair next_transition() const override + std::pair next_transition() const override { - std::pair if_no_wait = std::make_pair(-1, 0.0); + std::pair if_no_wait = std::make_pair(-1, 0); for (auto const& [aid, actor] : actors_to_run_) { if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) continue; -- 2.20.1