Skip to content

Commit d96e172

Browse files
Merge pull request #46 from Algebraic-Programming/schedule_shrink_updates
updating schedule shrinker
2 parents e8abff5 + 0d38672 commit d96e172

File tree

5 files changed

+12
-46
lines changed

5 files changed

+12
-46
lines changed

include/osp/bsp/model/BspSchedule.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,8 @@ class BspSchedule : public IBspSchedule<Graph_t>, public IBspScheduleEval<Graph_
836836
for (const auto& node : instance->vertices())
837837
for (const auto &child : instance->getComputationalDag().children(node))
838838
if(node_to_processor_assignment[node] != node_to_processor_assignment[child])
839-
comm_phase_empty[node_to_superstep_assignment[child]-1] = false;
839+
for(unsigned offset = 1; offset <= getStaleness(); ++offset)
840+
comm_phase_empty[node_to_superstep_assignment[child] - offset] = false;
840841

841842
std::vector<unsigned> new_step_index(number_of_supersteps);
842843
unsigned current_index = 0;

include/osp/bsp/model/BspScheduleCS.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,29 +470,29 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
470470

471471
virtual void shrinkByMergingSupersteps() override {
472472

473-
std::vector<unsigned> comm_phase_latest_dependency(this->number_of_supersteps, 0);
473+
std::vector<unsigned> superstep_latest_dependency(this->number_of_supersteps, 0);
474474
std::vector<std::vector<unsigned> > first_at = getFirstPresence();
475475

476476
for (auto const &[key, val] : commSchedule)
477477
if(this->assignedProcessor(std::get<0>(key)) != std::get<1>(key))
478-
comm_phase_latest_dependency[val] = std::max(comm_phase_latest_dependency[val], first_at[std::get<0>(key)][std::get<1>(key)]);
478+
superstep_latest_dependency[val] = std::max(superstep_latest_dependency[val], first_at[std::get<0>(key)][std::get<1>(key)]);
479479

480480

481481
for (const auto &node : BspSchedule<Graph_t>::instance->getComputationalDag().vertices())
482482
for (const auto &child : BspSchedule<Graph_t>::instance->getComputationalDag().children(node))
483483
if(this->assignedProcessor(node) != this->assignedProcessor(child))
484-
comm_phase_latest_dependency[this->assignedSuperstep(child)] = std::max(comm_phase_latest_dependency[this->assignedSuperstep(child)], first_at[node][this->assignedProcessor(child)]);
484+
superstep_latest_dependency[this->assignedSuperstep(child)] = std::max(superstep_latest_dependency[this->assignedSuperstep(child)], first_at[node][this->assignedProcessor(child)]);
485485

486-
std::vector<bool> comm_phase_deleted(this->number_of_supersteps, false);
486+
std::vector<bool> merge_with_previous(this->number_of_supersteps, false);
487487
for(unsigned step = this->number_of_supersteps-1; step < this->number_of_supersteps; --step)
488488
{
489489
unsigned limit = 0;
490490
while(step > limit)
491491
{
492-
limit = std::max(limit, comm_phase_latest_dependency[step]);
492+
limit = std::max(limit, superstep_latest_dependency[step]);
493493
if(step > limit)
494494
{
495-
comm_phase_deleted[step] = true;
495+
merge_with_previous[step] = true;
496496
--step;
497497
}
498498
}
@@ -502,7 +502,7 @@ class BspScheduleCS : public BspSchedule<Graph_t> {
502502
unsigned current_index = std::numeric_limits<unsigned>::max();
503503
for(unsigned step = 0; step < this->number_of_supersteps; ++step)
504504
{
505-
if(!comm_phase_deleted[step])
505+
if(!merge_with_previous[step])
506506
current_index++;
507507

508508
new_step_index[step] = current_index;

include/osp/bsp/scheduler/LocalSearch/HillClimbing/hill_climbing.hpp

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ class HillClimbingScheduler : public ImprovementScheduler<Graph_t> {
9494
// Create superstep lists (for convenience) for a BSP schedule
9595
void CreateSupstepLists();
9696

97-
// Combine subsequent supersteps whenever there is no communication inbetween
98-
void RemoveNeedlessSupSteps();
99-
10097
// For memory constraints
10198
bool use_memory_constraint = false;
10299
std::vector<std::vector<v_memw_t<Graph_t>>> memory_used;
@@ -178,9 +175,9 @@ RETURN_STATUS HillClimbingScheduler<Graph_t>::improveScheduleWithStepLimit(BspSc
178175

179176
template<typename Graph_t>
180177
void HillClimbingScheduler<Graph_t>::Init() {
181-
if(shrink) // NOTE: shrinking a MaxBspSchedule (without CS) might increase cost
178+
if(shrink)
182179
{
183-
RemoveNeedlessSupSteps();
180+
schedule->shrinkByMergingSupersteps();
184181
CreateSupstepLists();
185182
}
186183

@@ -971,37 +968,6 @@ bool HillClimbingScheduler<Graph_t>::violatesMemConstraint(vertex_idx node, unsi
971968
return false;
972969
}
973970

974-
template<typename Graph_t>
975-
void HillClimbingScheduler<Graph_t>::RemoveNeedlessSupSteps() {
976-
977-
unsigned current_step = 0;
978-
979-
unsigned nextBreak = schedule->numberOfSupersteps(), breakAfterNext = schedule->numberOfSupersteps();
980-
for (unsigned step = 0; step < schedule->numberOfSupersteps(); ++step) {
981-
if (nextBreak == step) {
982-
++current_step;
983-
nextBreak = breakAfterNext;
984-
if (schedule->getStaleness() == 2)
985-
breakAfterNext = schedule->numberOfSupersteps();
986-
}
987-
for (unsigned proc = 0; proc < schedule->getInstance().getArchitecture().numberOfProcessors(); ++proc)
988-
for (const vertex_idx node : supsteplists[step][proc]) {
989-
schedule->setAssignedSuperstep(node, current_step);
990-
for (const vertex_idx &succ : schedule->getInstance().getComputationalDag().children(node))
991-
{
992-
if (schedule->assignedProcessor(node) != schedule->assignedProcessor(succ))
993-
{
994-
nextBreak = std::min(nextBreak, schedule->assignedSuperstep(succ) + 1 - schedule->getStaleness());
995-
if (schedule->getStaleness() == 2)
996-
breakAfterNext = std::min(breakAfterNext, schedule->assignedSuperstep(succ));
997-
}
998-
}
999-
}
1000-
}
1001-
1002-
schedule->updateNumberOfSupersteps();
1003-
}
1004-
1005971
template<typename Graph_t>
1006972
void HillClimbingScheduler<Graph_t>::CreateSupstepLists() {
1007973

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ _add_test( wavefront_scheduler )
152152

153153
_add_test( cuthill_mckee )
154154

155-
_add_test( maxbsp_schedulers )
155+
_add_test( maxbsp_converter_and_hc )
156156

157157
## pebbling ILPs
158158

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ BOOST_AUTO_TEST_CASE(maxbsp_scheduling) {
7070
// hill climbing
7171

7272
HillClimbingScheduler<graph> HC;
73-
HC.setShrink(false);
7473
HC.improveSchedule(maxbsp);
7574
BOOST_CHECK(maxbsp.satisfiesPrecedenceConstraints());
7675
auto cost_hc = maxbsp.computeCosts();

0 commit comments

Comments
 (0)