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
4 changes: 2 additions & 2 deletions include/osp/bsp/model/BspSchedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ class BspSchedule : public IBspSchedule<Graph_t>, public IBspScheduleEval<Graph_

if (step_needed[proc] < number_of_supersteps) {

send[node_to_processor_assignment[node]][step_needed[proc] - 1] +=
send[node_to_processor_assignment[node]][step_needed[proc] - getStaleness()] +=
instance->sendCosts(node_to_processor_assignment[node], proc) *
instance->getComputationalDag().vertex_comm_weight(node);

rec[proc][step_needed[proc] - 1] += instance->sendCosts(node_to_processor_assignment[node], proc) *
rec[proc][step_needed[proc] - getStaleness()] += instance->sendCosts(node_to_processor_assignment[node], proc) *
instance->getComputationalDag().vertex_comm_weight(node);
}
}
Expand Down
10 changes: 5 additions & 5 deletions include/osp/bsp/model/BspScheduleCS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
for (const auto &source : BspSchedule<Graph_t>::instance->getComputationalDag().parents(node)) {

if (!node_to_proc_been_sent[source][proc]) {
assert(BspSchedule<Graph_t>::node_to_superstep_assignment[source] < step);
assert(BspSchedule<Graph_t>::node_to_superstep_assignment[source] < step + 1 - this->getStaleness());
commSchedule.emplace(
std::make_tuple(source, BspSchedule<Graph_t>::node_to_processor_assignment[source],
proc),
step - 1);
step - this->getStaleness());
node_to_proc_been_sent[source][proc] = true;
v_commw_t<Graph_t> comm_cost =
BspSchedule<Graph_t>::instance->getComputationalDag().vertex_comm_weight(source) *
Expand Down Expand Up @@ -399,7 +399,7 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
comm_cost + receive_cost[dest_proc] > max_comm_cost) {
iter++;
} else {
commSchedule.emplace(std::make_tuple(node_to_send, proc, dest_proc), step - 1);
commSchedule.emplace(std::make_tuple(node_to_send, proc, dest_proc), step - this->getStaleness());
node_to_proc_been_sent[node_to_send][dest_proc] = true;
send_cost[proc] += comm_cost;
receive_cost[dest_proc] += comm_cost;
Expand Down Expand Up @@ -441,11 +441,11 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
const auto tmp = std::make_tuple(source, BspSchedule<Graph_t>::node_to_processor_assignment[source],
BspSchedule<Graph_t>::node_to_processor_assignment[target]);
if (commSchedule.find(tmp) == commSchedule.end()) {
commSchedule[tmp] = BspSchedule<Graph_t>::node_to_superstep_assignment[target] - 1;
commSchedule[tmp] = BspSchedule<Graph_t>::node_to_superstep_assignment[target] - this->getStaleness();

} else {
commSchedule[tmp] =
std::min(BspSchedule<Graph_t>::node_to_superstep_assignment[target] - 1, commSchedule[tmp]);
std::min(BspSchedule<Graph_t>::node_to_superstep_assignment[target] - this->getStaleness(), commSchedule[tmp]);
}
}
}
Expand Down
53 changes: 29 additions & 24 deletions include/osp/bsp/model/BspScheduleCostEvaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,30 +86,6 @@ class BspScheduleCostEvaluator {
return max_comm_per_step;
}

std::vector<v_workw_t<Graph_t>> compute_max_work_per_step_helper() const {
const unsigned number_of_supersteps = schedule.numberOfSupersteps();
std::vector<std::vector<v_workw_t<Graph_t>>> work = std::vector<std::vector<v_workw_t<Graph_t>>>(
number_of_supersteps, std::vector<v_workw_t<Graph_t>>(instance.numberOfProcessors(), 0));
for (const auto &node : instance.vertices()) {
work[schedule.assignedSuperstep(node)][schedule.assignedProcessor(node)] +=
instance.getComputationalDag().vertex_work_weight(node);
}

std::vector<v_workw_t<Graph_t>> max_work_per_step(number_of_supersteps, 0);
for (unsigned step = 0; step < number_of_supersteps; step++) {
v_workw_t<Graph_t> max_work = 0;
for (unsigned proc = 0; proc < instance.numberOfProcessors(); proc++) {
if (max_work < work[step][proc]) {
max_work = work[step][proc];
}
}

max_work_per_step[step] = max_work;
}

return max_work_per_step;
}

public:
/**
* @brief Construct a new Bsp Schedule Cost Evaluator object.
Expand Down Expand Up @@ -150,6 +126,35 @@ class BspScheduleCostEvaluator {
return costs;
}

/**
* @brief Computes the work costs for each superstep.
*
* @return The work cost per superstep.
*/
std::vector<v_workw_t<Graph_t>> compute_max_work_per_step_helper() const {
const unsigned number_of_supersteps = schedule.numberOfSupersteps();
std::vector<std::vector<v_workw_t<Graph_t>>> work = std::vector<std::vector<v_workw_t<Graph_t>>>(
number_of_supersteps, std::vector<v_workw_t<Graph_t>>(instance.numberOfProcessors(), 0));
for (const auto &node : instance.vertices()) {
work[schedule.assignedSuperstep(node)][schedule.assignedProcessor(node)] +=
instance.getComputationalDag().vertex_work_weight(node);
}

std::vector<v_workw_t<Graph_t>> max_work_per_step(number_of_supersteps, 0);
for (unsigned step = 0; step < number_of_supersteps; step++) {
v_workw_t<Graph_t> max_work = 0;
for (unsigned proc = 0; proc < instance.numberOfProcessors(); proc++) {
if (max_work < work[step][proc]) {
max_work = work[step][proc];
}
}

max_work_per_step[step] = max_work;
}

return max_work_per_step;
}

/**
* @brief Computes the total work costs of the schedule.
*
Expand Down
2 changes: 2 additions & 0 deletions include/osp/bsp/model/MaxBspSchedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class MaxBspSchedule : public BspSchedule<Graph_t> {

MaxBspSchedule(const IBspSchedule<Graph_t> &schedule) : BspSchedule<Graph_t>(schedule) {}

MaxBspSchedule(IBspSchedule<Graph_t> &&schedule) : BspSchedule<Graph_t>(std::move(schedule)) {}

MaxBspSchedule(const MaxBspSchedule<Graph_t> &schedule) = default;

MaxBspSchedule<Graph_t> &operator=(const MaxBspSchedule<Graph_t> &schedule) = default;
Expand Down
8 changes: 8 additions & 0 deletions include/osp/bsp/model/MaxBspScheduleCS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class MaxBspScheduleCS : public BspScheduleCS<Graph_t> {
MaxBspScheduleCS(const BspScheduleCS<Graph_t> &schedule) : BspScheduleCS<Graph_t>(schedule) {}
MaxBspScheduleCS(BspScheduleCS<Graph_t> &&schedule) : BspScheduleCS<Graph_t>(std::move(schedule)) {}

MaxBspScheduleCS(const MaxBspSchedule<Graph_t> &schedule) : BspScheduleCS<Graph_t>(schedule) {
this->setAutoCommunicationSchedule();
}

MaxBspScheduleCS(MaxBspSchedule<Graph_t> &&schedule) : BspScheduleCS<Graph_t>(std::move(schedule)) {
this->setAutoCommunicationSchedule();
}

MaxBspScheduleCS(const MaxBspScheduleCS<Graph_t> &schedule) = default;
MaxBspScheduleCS(MaxBspScheduleCS<Graph_t> &&schedule) = default;

Expand Down
Loading