Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 32 additions & 35 deletions include/osp/bsp/model/BspSchedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,6 @@ class BspSchedule : public IBspSchedule<Graph_t>, public IBspScheduleEval<Graph_
std::vector<unsigned> node_to_processor_assignment;
std::vector<unsigned> node_to_superstep_assignment;

template<unsigned staleness>
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<std::vector<v_commw_t<Graph_t>>> & rec, std::vector<std::vector<v_commw_t<Graph_t>>> & send) const {
for (const auto &node : instance->vertices()) {

Expand Down Expand Up @@ -580,9 +548,36 @@ class BspSchedule : public IBspSchedule<Graph_t>, public IBspScheduleEval<Graph_
*
* @return True if the schedule satisfies the precedence constraints of the computational DAG, false otherwise.
*/
virtual bool satisfiesPrecedenceConstraints() const {
return satisfies_precedence_constraints_staleness<1>();
};
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 {

Expand Down Expand Up @@ -834,6 +829,8 @@ class BspSchedule : public IBspSchedule<Graph_t>, public IBspScheduleEval<Graph_

return num;
}

unsigned virtual getStaleness() const { return 1; }
};

} // namespace osp
2 changes: 1 addition & 1 deletion include/osp/bsp/model/BspScheduleCS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
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) {
Expand Down
15 changes: 2 additions & 13 deletions include/osp/bsp/model/MaxBspSchedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,6 @@ class MaxBspSchedule : public BspSchedule<Graph_t> {
* @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<Graph_t> computeCosts() const override {

Expand All @@ -123,6 +110,8 @@ class MaxBspSchedule : public BspSchedule<Graph_t> {
}
return costs;
}

unsigned virtual getStaleness() const override { return 2; }
};

} // namespace osp
15 changes: 2 additions & 13 deletions include/osp/bsp/model/MaxBspScheduleCS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,6 @@ class MaxBspScheduleCS : public BspScheduleCS<Graph_t> {
* @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<Graph_t> computeCosts() const override {

Expand All @@ -117,6 +104,8 @@ class MaxBspScheduleCS : public BspScheduleCS<Graph_t> {
}
return costs;
}

unsigned virtual getStaleness() const override { return 2; }
};

} // namespace osp