diff --git a/include/osp/bsp/model/BspSchedule.hpp b/include/osp/bsp/model/BspSchedule.hpp index c998dbe6..1f214b00 100644 --- a/include/osp/bsp/model/BspSchedule.hpp +++ b/include/osp/bsp/model/BspSchedule.hpp @@ -836,7 +836,8 @@ class BspSchedule : public IBspSchedule, public IBspScheduleEvalvertices()) for (const auto &child : instance->getComputationalDag().children(node)) if(node_to_processor_assignment[node] != node_to_processor_assignment[child]) - comm_phase_empty[node_to_superstep_assignment[child]-1] = false; + for(unsigned offset = 1; offset <= getStaleness(); ++offset) + comm_phase_empty[node_to_superstep_assignment[child] - offset] = false; std::vector new_step_index(number_of_supersteps); unsigned current_index = 0; diff --git a/include/osp/bsp/model/BspScheduleCS.hpp b/include/osp/bsp/model/BspScheduleCS.hpp index 4729c394..89d16757 100644 --- a/include/osp/bsp/model/BspScheduleCS.hpp +++ b/include/osp/bsp/model/BspScheduleCS.hpp @@ -470,29 +470,29 @@ class BspScheduleCS : public BspSchedule { virtual void shrinkByMergingSupersteps() override { - std::vector comm_phase_latest_dependency(this->number_of_supersteps, 0); + std::vector superstep_latest_dependency(this->number_of_supersteps, 0); std::vector > first_at = getFirstPresence(); for (auto const &[key, val] : commSchedule) if(this->assignedProcessor(std::get<0>(key)) != std::get<1>(key)) - comm_phase_latest_dependency[val] = std::max(comm_phase_latest_dependency[val], first_at[std::get<0>(key)][std::get<1>(key)]); + superstep_latest_dependency[val] = std::max(superstep_latest_dependency[val], first_at[std::get<0>(key)][std::get<1>(key)]); for (const auto &node : BspSchedule::instance->getComputationalDag().vertices()) for (const auto &child : BspSchedule::instance->getComputationalDag().children(node)) if(this->assignedProcessor(node) != this->assignedProcessor(child)) - comm_phase_latest_dependency[this->assignedSuperstep(child)] = std::max(comm_phase_latest_dependency[this->assignedSuperstep(child)], first_at[node][this->assignedProcessor(child)]); + superstep_latest_dependency[this->assignedSuperstep(child)] = std::max(superstep_latest_dependency[this->assignedSuperstep(child)], first_at[node][this->assignedProcessor(child)]); - std::vector comm_phase_deleted(this->number_of_supersteps, false); + std::vector merge_with_previous(this->number_of_supersteps, false); for(unsigned step = this->number_of_supersteps-1; step < this->number_of_supersteps; --step) { unsigned limit = 0; while(step > limit) { - limit = std::max(limit, comm_phase_latest_dependency[step]); + limit = std::max(limit, superstep_latest_dependency[step]); if(step > limit) { - comm_phase_deleted[step] = true; + merge_with_previous[step] = true; --step; } } @@ -502,7 +502,7 @@ class BspScheduleCS : public BspSchedule { unsigned current_index = std::numeric_limits::max(); for(unsigned step = 0; step < this->number_of_supersteps; ++step) { - if(!comm_phase_deleted[step]) + if(!merge_with_previous[step]) current_index++; new_step_index[step] = current_index; diff --git a/include/osp/bsp/scheduler/LocalSearch/HillClimbing/hill_climbing.hpp b/include/osp/bsp/scheduler/LocalSearch/HillClimbing/hill_climbing.hpp index 22795e68..c58031e8 100644 --- a/include/osp/bsp/scheduler/LocalSearch/HillClimbing/hill_climbing.hpp +++ b/include/osp/bsp/scheduler/LocalSearch/HillClimbing/hill_climbing.hpp @@ -94,9 +94,6 @@ class HillClimbingScheduler : public ImprovementScheduler { // Create superstep lists (for convenience) for a BSP schedule void CreateSupstepLists(); - // Combine subsequent supersteps whenever there is no communication inbetween - void RemoveNeedlessSupSteps(); - // For memory constraints bool use_memory_constraint = false; std::vector>> memory_used; @@ -178,9 +175,9 @@ RETURN_STATUS HillClimbingScheduler::improveScheduleWithStepLimit(BspSc template void HillClimbingScheduler::Init() { - if(shrink) // NOTE: shrinking a MaxBspSchedule (without CS) might increase cost + if(shrink) { - RemoveNeedlessSupSteps(); + schedule->shrinkByMergingSupersteps(); CreateSupstepLists(); } @@ -971,37 +968,6 @@ bool HillClimbingScheduler::violatesMemConstraint(vertex_idx node, unsi return false; } -template -void HillClimbingScheduler::RemoveNeedlessSupSteps() { - - unsigned current_step = 0; - - unsigned nextBreak = schedule->numberOfSupersteps(), breakAfterNext = schedule->numberOfSupersteps(); - for (unsigned step = 0; step < schedule->numberOfSupersteps(); ++step) { - if (nextBreak == step) { - ++current_step; - nextBreak = breakAfterNext; - if (schedule->getStaleness() == 2) - breakAfterNext = schedule->numberOfSupersteps(); - } - for (unsigned proc = 0; proc < schedule->getInstance().getArchitecture().numberOfProcessors(); ++proc) - for (const vertex_idx node : supsteplists[step][proc]) { - schedule->setAssignedSuperstep(node, current_step); - for (const vertex_idx &succ : schedule->getInstance().getComputationalDag().children(node)) - { - if (schedule->assignedProcessor(node) != schedule->assignedProcessor(succ)) - { - nextBreak = std::min(nextBreak, schedule->assignedSuperstep(succ) + 1 - schedule->getStaleness()); - if (schedule->getStaleness() == 2) - breakAfterNext = std::min(breakAfterNext, schedule->assignedSuperstep(succ)); - } - } - } - } - - schedule->updateNumberOfSupersteps(); -} - template void HillClimbingScheduler::CreateSupstepLists() { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6aa90375..74cac6c7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -152,7 +152,7 @@ _add_test( wavefront_scheduler ) _add_test( cuthill_mckee ) -_add_test( maxbsp_schedulers ) +_add_test( maxbsp_converter_and_hc ) ## pebbling ILPs diff --git a/tests/maxbsp_schedulers.cpp b/tests/maxbsp_converter_and_hc.cpp similarity index 99% rename from tests/maxbsp_schedulers.cpp rename to tests/maxbsp_converter_and_hc.cpp index a58214f1..3747e121 100644 --- a/tests/maxbsp_schedulers.cpp +++ b/tests/maxbsp_converter_and_hc.cpp @@ -70,7 +70,6 @@ BOOST_AUTO_TEST_CASE(maxbsp_scheduling) { // hill climbing HillClimbingScheduler HC; - HC.setShrink(false); HC.improveSchedule(maxbsp); BOOST_CHECK(maxbsp.satisfiesPrecedenceConstraints()); auto cost_hc = maxbsp.computeCosts();