Skip to content

Commit 0f2a868

Browse files
committed
BspScheduleCS fix datastructure
1 parent cdc8231 commit 0f2a868

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

include/osp/bsp/model/BspScheduleCS.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
391391
if (require_sending[proc].empty() ||
392392
std::get<0>(*require_sending[proc].rbegin()) + send_cost[proc] >
393393
max_comm_cost)
394-
continue;
395-
auto iter = require_sending[proc].begin();
396-
while (iter != require_sending[proc].cend()) {
394+
continue; // This check is not strictly necessary with the new loop but can be a fast exit.
395+
auto iter = require_sending[proc].rbegin();
396+
while (iter != require_sending[proc].rend()) {
397397
const auto& [comm_cost, node_to_send, dest_proc] = *iter;
398398
if (comm_cost + send_cost[proc] > max_comm_cost ||
399399
comm_cost + receive_cost[dest_proc] > max_comm_cost) {
@@ -403,11 +403,11 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
403403
node_to_proc_been_sent[node_to_send][dest_proc] = true;
404404
send_cost[proc] += comm_cost;
405405
receive_cost[dest_proc] += comm_cost;
406-
iter = require_sending[proc].erase(iter);
406+
iter = std::make_reverse_iterator(require_sending[proc].erase(std::next(iter).base()));
407407
if (require_sending[proc].empty() ||
408408
std::get<0>(*require_sending[proc].rbegin()) + send_cost[proc] >
409409
max_comm_cost)
410-
break;
410+
break; // Exit if no more sends can possibly fit.
411411
}
412412
}
413413
}

0 commit comments

Comments
 (0)