Skip to content

Commit 3d65e95

Browse files
renaming and merge fixes
1 parent bd29c0b commit 3d65e95

File tree

9 files changed

+26
-31
lines changed

9 files changed

+26
-31
lines changed

include/osp/bsp/model/BspSchedule.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ class BspSchedule : public IBspSchedule<Graph_t>, public IBspScheduleEval<Graph_
830830
return num;
831831
}
832832

833-
virtual void shrinkSchedule() {
833+
virtual void shrinkByMergingSupersteps() {
834834

835835
std::vector<bool> comm_phase_empty(number_of_supersteps, true);
836836
for (const auto& node : instance->vertices())

include/osp/bsp/model/BspScheduleCS.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
468468
}
469469
}
470470

471-
virtual void shrinkSchedule() override {
471+
virtual void shrinkByMergingSupersteps() override {
472472

473473
std::vector<unsigned> comm_phase_latest_dependency(this->number_of_supersteps, 0);
474474
std::vector<std::vector<unsigned> > first_at = getFirstPresence();
@@ -515,6 +515,7 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
515515
this->setNumberOfSupersteps(current_index+1);
516516
}
517517

518+
// for each vertex v and processor p, find the first superstep where v is present on p by the end of the compute phase
518519
std::vector<std::vector<unsigned> > getFirstPresence() const {
519520

520521
std::vector<std::vector<unsigned> > first_at(BspSchedule<Graph_t>::instance->numberOfVertices(),

include/osp/bsp/scheduler/IlpSchedulers/CoptCommScheduleOptimizer.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CoptCommScheduleOptimizer {
4848
VarArray max_comm_superstep_var;
4949
std::vector<std::vector<std::vector<VarArray>>> comm_processor_to_processor_superstep_node_var;
5050

51-
void setupVariablesConstraintsObjective(const BspScheduleCS<Graph_t>& schedule, Model& model, bool num_supersteps_can_change);
51+
void setupVariablesConstraintsObjective(const BspScheduleCS<Graph_t>& schedule, Model& model);
5252

5353
void setInitialSolution(BspScheduleCS<Graph_t>& schedule, Model &model);
5454

@@ -59,6 +59,7 @@ class CoptCommScheduleOptimizer {
5959
public:
6060

6161
using KeyTriple = std::tuple<vertex_idx_t<Graph_t>, unsigned int, unsigned int>;
62+
virtual ~CoptCommScheduleOptimizer() = default;
6263

6364
virtual RETURN_STATUS improveSchedule(BspScheduleCS<Graph_t> &schedule);
6465

@@ -76,7 +77,7 @@ RETURN_STATUS CoptCommScheduleOptimizer<Graph_t>::improveSchedule(BspScheduleCS<
7677
Envr env;
7778
Model model = env.CreateModel("bsp_schedule_cs");
7879

79-
setupVariablesConstraintsObjective(schedule, model, true);
80+
setupVariablesConstraintsObjective(schedule, model);
8081

8182
setInitialSolution(schedule, model);
8283

@@ -89,7 +90,7 @@ RETURN_STATUS CoptCommScheduleOptimizer<Graph_t>::improveSchedule(BspScheduleCS<
8990
{
9091
updateCommSchedule(schedule);
9192
if (canShrinkResultingSchedule(schedule.numberOfSupersteps()))
92-
schedule.shrinkSchedule();
93+
schedule.shrinkByMergingSupersteps();
9394
}
9495

9596
if (model.GetIntAttr(COPT_INTATTR_MIPSTATUS) == COPT_MIPSTATUS_OPTIMAL) {
@@ -219,7 +220,7 @@ void CoptCommScheduleOptimizer<Graph_t>::setInitialSolution(BspScheduleCS<Graph_
219220
}
220221

221222
template<typename Graph_t>
222-
void CoptCommScheduleOptimizer<Graph_t>::setupVariablesConstraintsObjective(const BspScheduleCS<Graph_t>& schedule, Model& model, bool num_supersteps_can_change) {
223+
void CoptCommScheduleOptimizer<Graph_t>::setupVariablesConstraintsObjective(const BspScheduleCS<Graph_t>& schedule, Model& model) {
223224

224225
const unsigned &max_number_supersteps = schedule.numberOfSupersteps();
225226
const unsigned &num_processors = schedule.getInstance().numberOfProcessors();

include/osp/bsp/scheduler/IlpSchedulers/CoptPartialScheduler.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class CoptPartialScheduler {
8181
virtual void setTimeLimitSeconds(unsigned int limit) { timeLimitSeconds = limit; }
8282
inline unsigned int getTimeLimitSeconds() const { return timeLimitSeconds; }
8383
virtual void setStartAndEndSuperstep(unsigned start_, unsigned end_) { start_superstep = start_; end_superstep = end_; }
84+
85+
virtual ~CoptPartialScheduler() = default;
8486
};
8587

8688
template<typename Graph_t>
@@ -277,7 +279,7 @@ void CoptPartialScheduler<Graph_t>::updateSchedule(BspScheduleCS<Graph_t>& sched
277279
}
278280

279281
schedule.cleanCommSchedule();
280-
schedule.shrinkSchedule();
282+
schedule.shrinkByMergingSupersteps();
281283

282284
};
283285

@@ -466,7 +468,7 @@ void CoptPartialScheduler<Graph_t>::setupVariablesConstraintsObjective(const Bsp
466468
}
467469

468470
// boundary conditions at the end
469-
for(const std::pair<vertex_idx_t<Graph_t>, unsigned>& node_and_proc : node_needed_after_on_proc)
471+
for(const std::pair<vertex_idx_t<Graph_t>, unsigned> node_and_proc : node_needed_after_on_proc)
470472
{
471473
Expr expr;
472474
for (unsigned int p_from = 0; p_from < num_processors; p_from++)
@@ -475,7 +477,7 @@ void CoptPartialScheduler<Graph_t>::setupVariablesConstraintsObjective(const Bsp
475477
model.AddConstr(expr >= 1);
476478
}
477479

478-
for(const std::pair<vertex_idx_t<Graph_t>, unsigned>& source_and_proc : source_needed_after_on_proc)
480+
for(const std::pair<vertex_idx_t<Graph_t>, unsigned> source_and_proc : source_needed_after_on_proc)
479481
{
480482
Expr expr = present_on_processor_superstep_source_var[source_and_proc.second][max_number_supersteps - 1][static_cast<int>(source_and_proc.first)];
481483
expr += comm_to_processor_superstep_source_var[source_and_proc.second][max_number_supersteps][static_cast<int>(source_and_proc.first)];

include/osp/bsp/scheduler/IlpSchedulers/TotalCommunicationScheduler.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
9595

9696
for (unsigned processor = 0; processor < instance_ptr->numberOfProcessors(); processor++) {
9797

98-
for (unsigned step = 0; step < (unsigned)(*node_to_processor_superstep_var_ptr)[0][0].Size();
98+
for (unsigned step = 0; step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size());
9999
step++) {
100100

101101
assert(size < std::numeric_limits<int>::max());
@@ -170,7 +170,7 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
170170

171171
for (unsigned processor = 0; processor < instance_ptr->numberOfProcessors(); processor++) {
172172

173-
for (unsigned step = 0; step < (unsigned)(*node_to_processor_superstep_var_ptr)[0][0].Size();
173+
for (unsigned step = 0; step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size());
174174
step++) {
175175
assert(step <= std::numeric_limits<int>::max());
176176
if (GetSolution(
@@ -203,7 +203,7 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
203203

204204
for (unsigned processor = 0; processor < instance_ptr->numberOfProcessors(); processor++) {
205205

206-
for (unsigned step = 0; step < (unsigned)(*node_to_processor_superstep_var_ptr)[0][0].Size();
206+
for (unsigned step = 0; step < static_cast<unsigned>((*node_to_processor_superstep_var_ptr)[0][0].Size());
207207
step++) {
208208

209209
if (schedule.assignedProcessor(node) == processor && schedule.assignedSuperstep(node) == step) {
@@ -438,7 +438,7 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
438438
expr += node_to_processor_superstep_var[node][processor][static_cast<int>(step)];
439439
}
440440
}
441-
model.AddConstr(expr <= (double)(instance.numberOfVertices() * instance.numberOfProcessors()) *
441+
model.AddConstr(expr <= static_cast<double>(instance.numberOfVertices() * instance.numberOfProcessors()) *
442442
superstep_used_var.GetVar(static_cast<int>(step)));
443443
}
444444

@@ -576,13 +576,13 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
576576
assert(step <= std::numeric_limits<int>::max());
577577
for (unsigned int processor = 0; processor < instance.numberOfProcessors(); processor++) {
578578

579-
Expr expr;
579+
Expr expr_work;
580580
for (const auto &node : instance.vertices()) {
581-
expr += instance.getComputationalDag().vertex_work_weight(node) *
581+
expr_work += instance.getComputationalDag().vertex_work_weight(node) *
582582
node_to_processor_superstep_var[node][processor][static_cast<int>(step)];
583583
}
584584

585-
model.AddConstr(max_work_superstep_var[static_cast<int>(step)] >= expr);
585+
model.AddConstr(max_work_superstep_var[static_cast<int>(step)] >= expr_work);
586586
}
587587
}
588588

@@ -597,7 +597,7 @@ class TotalCommunicationScheduler : public Scheduler<Graph_t> {
597597
Objective function
598598
*/
599599

600-
double comm_cost = (double)instance.communicationCosts() / instance.numberOfProcessors();
600+
double comm_cost = static_cast<double>(instance.communicationCosts()) / instance.numberOfProcessors();
601601
model.SetObjective(comm_cost * total_edges_cut + expr - instance.synchronisationCosts(), COPT_MINIMIZE);
602602
}
603603

include/osp/bsp/scheduler/LocalSearch/KernighanLin/kl_base.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class kl_base : public ImprovementScheduler<Graph_t>, public Ikl_cost_function {
455455
(*node_heap_handles[node]).to_step = node_best_step;
456456
(*node_heap_handles[node]).change_in_cost = node_change_in_cost;
457457

458-
if ((*node_heap_handles[node]).gain != node_max_gain) {
458+
if ((*node_heap_handles[node]).gain >= node_max_gain) {
459459

460460
(*node_heap_handles[node]).gain = node_max_gain;
461461
max_gain_heap.update(node_heap_handles[node]);
@@ -642,7 +642,7 @@ class kl_base : public ImprovementScheduler<Graph_t>, public Ikl_cost_function {
642642
unsigned count = 0;
643643
for (auto iter = max_gain_heap.ordered_begin(); iter != max_gain_heap.ordered_end(); ++iter) {
644644

645-
if (iter->gain == max_gain_heap.top().gain && count < local_max) {
645+
if (iter->gain >= max_gain_heap.top().gain && count < local_max) {
646646
max_nodes[count] = (iter->node);
647647
count++;
648648

@@ -1146,7 +1146,7 @@ class kl_base : public ImprovementScheduler<Graph_t>, public Ikl_cost_function {
11461146
compute_node_gain(node);
11471147
moves.push_back(best_move_change_superstep(node));
11481148

1149-
if (moves.back().gain == std::numeric_limits<double>::lowest()) {
1149+
if (moves.back().gain <= std::numeric_limits<double>::lowest()) {
11501150
abort = true;
11511151
break;
11521152
}

include/osp/pebbling/pebblers/pebblingILP/PebblingPartialILP.hpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ RETURN_STATUS PebblingPartialILP<Graph_t>::computePebbling(PebblingSchedule<Grap
113113
// AUX: check for isomorphism
114114

115115
// create set of nodes & external sources for all parts, and the nodes that need to have blue pebble at the end
116-
std::vector<std::set<vertex_idx> > nodes_in_part(nr_parts), extra_sources(nr_parts), needs_blue_at_end(nr_parts);
116+
std::vector<std::set<vertex_idx> > nodes_in_part(nr_parts), extra_sources(nr_parts);
117117
std::vector<std::map<vertex_idx, vertex_idx> > original_node_id(nr_parts);
118118
std::vector<std::map<unsigned, unsigned> > original_proc_id(nr_parts);
119119
for(vertex_idx node = 0; node < instance.numberOfVertices(); ++node)
@@ -125,13 +125,6 @@ RETURN_STATUS PebblingPartialILP<Graph_t>::computePebbling(PebblingSchedule<Grap
125125
for (const vertex_idx &pred : instance.getComputationalDag().parents(node))
126126
if(assignment_to_parts[node] != assignment_to_parts[pred])
127127
extra_sources[assignment_to_parts[node]].insert(pred);
128-
129-
for (const vertex_idx &succ : instance.getComputationalDag().children(node))
130-
if(assignment_to_parts[node] != assignment_to_parts[succ])
131-
needs_blue_at_end[assignment_to_parts[node]].insert(node);
132-
133-
if(instance.getComputationalDag().out_degree(node) == 0)
134-
needs_blue_at_end[assignment_to_parts[node]].insert(node);
135128
}
136129

137130
std::vector<Graph_t> subDags;

include/osp/pebbling/pebblers/pebblingILP/partialILP/AcyclicDagDivider.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class AcyclicDagDivider {
3434
protected:
3535
using vertex_idx = vertex_idx_t<Graph_t>;
3636

37-
std::vector<unsigned> node_to_part;
38-
3937
unsigned minPartitionSize = 40, maxPartitionSize = 80;
4038
bool ignore_sources_in_size = true;
4139

include/osp/pebbling/pebblers/pebblingILP/partialILP/SubproblemMultiScheduling.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ RETURN_STATUS SubproblemMultiScheduling<Graph_t>::computeMultiSchedule(const Bsp
183183

184184
++itr_latest;
185185
}
186-
std::vector<std::pair<vertex_idx, unsigned> > new_assingments = makeAssignment(instance, possible_nodes, free_procs);
186+
new_assingments = makeAssignment(instance, possible_nodes, free_procs);
187187
for(auto entry : new_assingments)
188188
{
189189
vertex_idx node = entry.first;

0 commit comments

Comments
 (0)