diff --git a/include/osp/bsp/model/BspSchedule.hpp b/include/osp/bsp/model/BspSchedule.hpp index 299e1716..21dc4646 100644 --- a/include/osp/bsp/model/BspSchedule.hpp +++ b/include/osp/bsp/model/BspSchedule.hpp @@ -67,38 +67,6 @@ class BspSchedule : public IBspSchedule, public IBspScheduleEval node_to_processor_assignment; std::vector node_to_superstep_assignment; - template - inline bool satisfies_precedence_constraints_staleness() const { - - if (node_to_processor_assignment.size() != instance->numberOfVertices() || - node_to_superstep_assignment.size() != instance->numberOfVertices()) { - return false; - } - - for (const auto &v : instance->vertices()) { - - if (node_to_superstep_assignment[v] >= number_of_supersteps) { - return false; - } - - if (node_to_processor_assignment[v] >= instance->numberOfProcessors()) { - return false; - } - - for (const auto &target : instance->getComputationalDag().children(v)) { - - const unsigned different_processors = - (node_to_processor_assignment[v] == node_to_processor_assignment[target]) ? 0u : staleness; - - if (node_to_superstep_assignment[v] + different_processors > node_to_superstep_assignment[target]) { - return false; - } - } - } - - return true; - } - void compute_lazy_communication_costs_helper(std::vector>> & rec, std::vector>> & send) const { for (const auto &node : instance->vertices()) { @@ -580,9 +548,36 @@ class BspSchedule : public IBspSchedule, public IBspScheduleEval(); - }; + inline bool satisfiesPrecedenceConstraints() const { + + if (node_to_processor_assignment.size() != instance->numberOfVertices() || + node_to_superstep_assignment.size() != instance->numberOfVertices()) { + return false; + } + + for (const auto &v : instance->vertices()) { + + if (node_to_superstep_assignment[v] >= number_of_supersteps) { + return false; + } + + if (node_to_processor_assignment[v] >= instance->numberOfProcessors()) { + return false; + } + + for (const auto &target : instance->getComputationalDag().children(v)) { + + const unsigned different_processors = + (node_to_processor_assignment[v] == node_to_processor_assignment[target]) ? 0u : getStaleness(); + + if (node_to_superstep_assignment[v] + different_processors > node_to_superstep_assignment[target]) { + return false; + } + } + } + + return true; + } bool satisfiesNodeTypeConstraints() const { @@ -834,6 +829,8 @@ class BspSchedule : public IBspSchedule, public IBspScheduleEval { return false; first_at[std::get<0>(key)][std::get<2>(key)] = - std::min(first_at[std::get<0>(key)][std::get<2>(key)], val + 1); + std::min(first_at[std::get<0>(key)][std::get<2>(key)], val + this->getStaleness()); } for (auto const &[key, val] : cs) { diff --git a/include/osp/bsp/model/MaxBspSchedule.hpp b/include/osp/bsp/model/MaxBspSchedule.hpp index 55dc5472..fdcd36cd 100644 --- a/include/osp/bsp/model/MaxBspSchedule.hpp +++ b/include/osp/bsp/model/MaxBspSchedule.hpp @@ -86,19 +86,6 @@ class MaxBspSchedule : public BspSchedule { * @brief Destructor for the BspSchedule class. */ virtual ~MaxBspSchedule() = default; - - /** - * @brief Returns true if the schedule satisfies the precedence constraints of the computational DAG. - * - * The precedence constraints of the computational DAG are satisfied if, for each directed edge (u, v) such that u - * and v are assigned to different processors, the superstep assigned to node u is less than the superstep assigned - * to node v. - * - * @return True if the schedule satisfies the precedence constraints of the computational DAG, false otherwise. - */ - virtual bool satisfiesPrecedenceConstraints() const override { - return this->template satisfies_precedence_constraints_staleness<2>(); - }; virtual v_workw_t computeCosts() const override { @@ -123,6 +110,8 @@ class MaxBspSchedule : public BspSchedule { } return costs; } + + unsigned virtual getStaleness() const override { return 2; } }; } // namespace osp \ No newline at end of file diff --git a/include/osp/bsp/model/MaxBspScheduleCS.hpp b/include/osp/bsp/model/MaxBspScheduleCS.hpp index b921218d..e5e7e1e9 100644 --- a/include/osp/bsp/model/MaxBspScheduleCS.hpp +++ b/include/osp/bsp/model/MaxBspScheduleCS.hpp @@ -80,19 +80,6 @@ class MaxBspScheduleCS : public BspScheduleCS { * @brief Destructor for the BspSchedule class. */ virtual ~MaxBspScheduleCS() = default; - - /** - * @brief Returns true if the schedule satisfies the precedence constraints of the computational DAG. - * - * The precedence constraints of the computational DAG are satisfied if, for each directed edge (u, v) such that u - * and v are assigned to different processors, the superstep assigned to node u is less than the superstep assigned - * to node v. - * - * @return True if the schedule satisfies the precedence constraints of the computational DAG, false otherwise. - */ - virtual bool satisfiesPrecedenceConstraints() const override { - return this->template satisfies_precedence_constraints_staleness<2>(); - }; virtual v_workw_t computeCosts() const override { @@ -117,6 +104,8 @@ class MaxBspScheduleCS : public BspScheduleCS { } return costs; } + + unsigned virtual getStaleness() const override { return 2; } }; } // namespace osp \ No newline at end of file