@@ -25,6 +25,43 @@ limitations under the License.
2525
2626namespace osp {
2727
28+ template <typename Graph_t>
29+ void compute_lazy_communication_costs (
30+ const BspInstance<Graph_t> &instance,
31+ unsigned number_of_supersteps,
32+ const std::vector<unsigned > &node_to_processor_assignment,
33+ const std::vector<unsigned > &node_to_superstep_assignment,
34+ const unsigned staleness,
35+ std::vector<std::vector<v_commw_t <Graph_t>>> &rec,
36+ std::vector<std::vector<v_commw_t <Graph_t>>> &send) {
37+ for (const auto &node : instance.vertices ()) {
38+
39+ std::vector<unsigned > step_needed (instance.numberOfProcessors (), number_of_supersteps);
40+ for (const auto &target : instance.getComputationalDag ().children (node)) {
41+
42+ if (node_to_processor_assignment[node] != node_to_processor_assignment[target]) {
43+ step_needed[node_to_processor_assignment[target]] = std::min (step_needed[node_to_processor_assignment[target]], node_to_superstep_assignment[target]);
44+ }
45+ }
46+
47+ for (unsigned proc = 0 ; proc < instance.numberOfProcessors (); proc++) {
48+
49+ if (step_needed[proc] < number_of_supersteps) {
50+ send[node_to_processor_assignment[node]][step_needed[proc] - staleness] += instance.sendCosts (node_to_processor_assignment[node], proc) * instance.getComputationalDag ().vertex_comm_weight (node);
51+ rec[proc][step_needed[proc] - staleness] += instance.sendCosts (node_to_processor_assignment[node], proc) * instance.getComputationalDag ().vertex_comm_weight (node);
52+ }
53+ }
54+ }
55+ }
56+
57+ template <typename Graph_t>
58+ void compute_lazy_communication_costs (
59+ const BspSchedule<Graph_t> &schedule,
60+ std::vector<std::vector<v_commw_t <Graph_t>>> &rec,
61+ std::vector<std::vector<v_commw_t <Graph_t>>> &send) {
62+ compute_lazy_communication_costs (schedule.getInstance (), schedule.numberOfSupersteps (), schedule.assignedProcessors (), schedule.assignedSupersteps (), schedule.getStaleness (), rec, send);
63+ }
64+
2865/* *
2966 * @struct LazyCommunicationCost
3067 * @brief Implements the lazy communication cost model.
@@ -41,7 +78,7 @@ struct LazyCommunicationCost {
4178 std::vector<std::vector<v_commw_t <Graph_t>>> rec (number_of_processors, std::vector<v_commw_t <Graph_t>>(number_of_supersteps, 0 ));
4279 std::vector<std::vector<v_commw_t <Graph_t>>> send (number_of_processors, std::vector<v_commw_t <Graph_t>>(number_of_supersteps, 0 ));
4380
44- cost_helpers:: compute_lazy_communication_costs (schedule, rec, send);
81+ compute_lazy_communication_costs (schedule, rec, send);
4582 const auto max_comm_per_step = cost_helpers::compute_max_comm_per_step (schedule, rec, send);
4683
4784 v_commw_t <Graph_t> comm_costs = 0 ;
0 commit comments