Skip to content

Commit 05cc868

Browse files
committed
update tests
1 parent 5676de8 commit 05cc868

7 files changed

Lines changed: 493 additions & 527 deletions

File tree

include/osp/bsp/scheduler/LocalSearch/KernighanLin/comm_cost_modules/kl_max_bsp_comm_cost.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ struct KlMaxBspCommCostFunction {
281281
const CostT secondMaxWorkAtFrom = static_cast<CostT>(activeSchedule_->GetStepSecondMaxWork(nodeStep));
282282
const bool isSoleMaxProc
283283
= (activeSchedule_->GetStepMaxWorkProcessorCount()[nodeStep] == 1)
284-
&& (maxWorkAtFrom == static_cast<CostT>(activeSchedule_->GetStepProcessorWork(nodeStep, nodeProc)));
284+
&& (maxWorkAtFrom <= static_cast<CostT>(activeSchedule_->GetStepProcessorWork(nodeStep, nodeProc)));
285285

286286
const CostT workRemoval = isSoleMaxProc ? std::min(static_cast<CostT>(nodeWeight), maxWorkAtFrom - secondMaxWorkAtFrom)
287287
: CostT(0);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
*/
1818

1919
#pragma once
20-
#define KL_DEBUG_COST_CHECK
20+
// #define KL_DEBUG_COST_CHECK
2121
#include <algorithm>
2222
#include <chrono>
2323
#include <cstdlib>

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ limitations under the License.
1818

1919
#pragma once
2020

21-
// Parallel implementations
22-
#include "kl_improver_sync_parallel.hpp"
23-
24-
// Cost function modules (already pulled in by kl_improver.hpp, but
25-
// explicit for readability)
2621
#include "comm_cost_modules/kl_bsp_comm_cost.hpp"
2722
#include "comm_cost_modules/kl_hyper_total_comm_cost.hpp"
2823
#include "comm_cost_modules/kl_max_bsp_comm_cost.hpp"
2924
#include "comm_cost_modules/kl_total_comm_cost.hpp"
25+
#include "kl_improver_sync_parallel.hpp"
3026

3127
// Memory constraint modules
3228
#include "osp/bsp/scheduler/LocalSearch/LocalSearchMemoryConstraintModules.hpp"

tests/kl_bsp_cost_policies.cpp

Lines changed: 170 additions & 170 deletions
Large diffs are not rendered by default.

tests/kl_bsp_max_improver_test.cpp

Lines changed: 209 additions & 209 deletions
Large diffs are not rendered by default.

tests/kl_lambda.cpp

Lines changed: 56 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -635,73 +635,73 @@ BOOST_AUTO_TEST_CASE(KlLambdaImproverInnerLoopLambdaMapTest) {
635635
BOOST_CHECK_CLOSE(kl.GetCommCostF().ComputeScheduleCostTest(), kl.GetCurrentCost(), 0.00001);
636636
}
637637

638-
BOOST_AUTO_TEST_CASE(kl_lambda_total_comm_large_test_graphs) {
639-
std::vector<std::string> filenames_graph = LargeSpaaGraphs();
640-
using graph = ComputationalDagEdgeIdxVectorImplDefIntT;
641-
// Getting root git directory
642-
std::filesystem::path cwd = std::filesystem::current_path();
643-
std::cout << cwd << std::endl;
644-
while ((!cwd.empty()) && (cwd.filename() != "OneStopParallel")) {
645-
cwd = cwd.parent_path();
646-
std::cout << cwd << std::endl;
647-
}
638+
// BOOST_AUTO_TEST_CASE(kl_lambda_total_comm_large_test_graphs) {
639+
// std::vector<std::string> filenames_graph = LargeSpaaGraphs();
640+
// using graph = ComputationalDagEdgeIdxVectorImplDefIntT;
641+
// // Getting root git directory
642+
// std::filesystem::path cwd = std::filesystem::current_path();
643+
// std::cout << cwd << std::endl;
644+
// while ((!cwd.empty()) && (cwd.filename() != "OneStopParallel")) {
645+
// cwd = cwd.parent_path();
646+
// std::cout << cwd << std::endl;
647+
// }
648648

649-
for (auto &filename_graph : filenames_graph) {
650-
GreedyBspScheduler<ComputationalDagEdgeIdxVectorImplDefIntT> test_scheduler;
651-
BspInstance<graph> instance;
652-
bool status_graph
653-
= file_reader::ReadComputationalDagHyperdagFormatDB((cwd / filename_graph).string(), instance.GetComputationalDag());
649+
// for (auto &filename_graph : filenames_graph) {
650+
// GreedyBspScheduler<ComputationalDagEdgeIdxVectorImplDefIntT> test_scheduler;
651+
// BspInstance<graph> instance;
652+
// bool status_graph
653+
// = file_reader::ReadComputationalDagHyperdagFormatDB((cwd / filename_graph).string(), instance.GetComputationalDag());
654654

655-
instance.GetArchitecture().SetSynchronisationCosts(500);
656-
instance.GetArchitecture().SetCommunicationCosts(5);
657-
instance.GetArchitecture().SetNumberOfProcessors(4);
655+
// instance.GetArchitecture().SetSynchronisationCosts(500);
656+
// instance.GetArchitecture().SetCommunicationCosts(5);
657+
// instance.GetArchitecture().SetNumberOfProcessors(4);
658658

659-
std::vector<std::vector<int>> send_cost = {
660-
{0, 1, 4, 4},
661-
{1, 0, 4, 4},
662-
{4, 4, 0, 1},
663-
{4, 4, 1, 0}
664-
};
659+
// std::vector<std::vector<int>> send_cost = {
660+
// {0, 1, 4, 4},
661+
// {1, 0, 4, 4},
662+
// {4, 4, 0, 1},
663+
// {4, 4, 1, 0}
664+
// };
665665

666-
instance.GetArchitecture().SetSendCosts(send_cost);
666+
// instance.GetArchitecture().SetSendCosts(send_cost);
667667

668-
if (!status_graph) {
669-
std::cout << "Reading files failed." << std::endl;
670-
BOOST_CHECK(false);
671-
}
668+
// if (!status_graph) {
669+
// std::cout << "Reading files failed." << std::endl;
670+
// BOOST_CHECK(false);
671+
// }
672672

673-
AddMemWeights(instance.GetComputationalDag());
673+
// AddMemWeights(instance.GetComputationalDag());
674674

675-
BspSchedule<graph> schedule(instance);
676-
const auto result = test_scheduler.ComputeSchedule(schedule);
675+
// BspSchedule<graph> schedule(instance);
676+
// const auto result = test_scheduler.ComputeSchedule(schedule);
677677

678-
schedule.UpdateNumberOfSupersteps();
678+
// schedule.UpdateNumberOfSupersteps();
679679

680-
std::cout << "initial scedule with costs: " << TotalLambdaCommunicationCost<graph>()(schedule) << " and "
681-
<< schedule.NumberOfSupersteps() << " number of supersteps" << std::endl;
680+
// std::cout << "initial scedule with costs: " << TotalLambdaCommunicationCost<graph>()(schedule) << " and "
681+
// << schedule.NumberOfSupersteps() << " number of supersteps" << std::endl;
682682

683-
BspSchedule<graph> schedule_2(schedule);
683+
// BspSchedule<graph> schedule_2(schedule);
684684

685-
BOOST_CHECK_EQUAL(ReturnStatus::OSP_SUCCESS, result);
686-
BOOST_CHECK_EQUAL(&schedule.GetInstance(), &instance);
687-
BOOST_CHECK(schedule.SatisfiesPrecedenceConstraints());
685+
// BOOST_CHECK_EQUAL(ReturnStatus::OSP_SUCCESS, result);
686+
// BOOST_CHECK_EQUAL(&schedule.GetInstance(), &instance);
687+
// BOOST_CHECK(schedule.SatisfiesPrecedenceConstraints());
688688

689-
KlTotalLambdaCommImprover<graph, NoLocalSearchMemoryConstraint, 1> kl;
690-
auto start_time = std::chrono::high_resolution_clock::now();
691-
auto status = kl.ImproveSchedule(schedule);
692-
auto finish_time = std::chrono::high_resolution_clock::now();
693-
auto duration = std::chrono::duration_cast<std::chrono::seconds>(finish_time - start_time).count();
689+
// KlTotalLambdaCommImprover<graph, NoLocalSearchMemoryConstraint, 1> kl;
690+
// auto start_time = std::chrono::high_resolution_clock::now();
691+
// auto status = kl.ImproveSchedule(schedule);
692+
// auto finish_time = std::chrono::high_resolution_clock::now();
693+
// auto duration = std::chrono::duration_cast<std::chrono::seconds>(finish_time - start_time).count();
694694

695-
std::cout << "kl new finished in " << duration << " seconds, costs: " << TotalLambdaCommunicationCost<graph>()(schedule)
696-
<< " with " << schedule.NumberOfSupersteps() << " number of supersteps" << std::endl;
695+
// std::cout << "kl new finished in " << duration << " seconds, costs: " << TotalLambdaCommunicationCost<graph>()(schedule)
696+
// << " with " << schedule.NumberOfSupersteps() << " number of supersteps" << std::endl;
697697

698-
BOOST_CHECK(status == ReturnStatus::OSP_SUCCESS || status == ReturnStatus::BEST_FOUND);
699-
BOOST_CHECK_EQUAL(schedule.SatisfiesPrecedenceConstraints(), true);
700-
}
701-
}
698+
// BOOST_CHECK(status == ReturnStatus::OSP_SUCCESS || status == ReturnStatus::BEST_FOUND);
699+
// BOOST_CHECK_EQUAL(schedule.SatisfiesPrecedenceConstraints(), true);
700+
// }
701+
// }
702702

703703
// BOOST_AUTO_TEST_CASE(kl_lambda_total_comm_large_test_graphs_mt) {
704-
// std::vector<std::string> filenames_graph = large_spaa_graphs();
704+
// std::vector<std::string> filenames_graph = LargeSpaaGraphs();
705705
// using graph = ComputationalDagEdgeIdxVectorImplDefIntT;
706706
// // Getting root git directory
707707
// std::filesystem::path cwd = std::filesystem::current_path();
@@ -734,14 +734,14 @@ BOOST_AUTO_TEST_CASE(kl_lambda_total_comm_large_test_graphs) {
734734
// BOOST_CHECK(false);
735735
// }
736736

737-
// add_mem_weights(instance.GetComputationalDag());
737+
// AddMemWeights(instance.GetComputationalDag());
738738

739739
// BspSchedule<graph> schedule(instance);
740740
// const auto result = test_scheduler.ComputeSchedule(schedule);
741741

742742
// schedule.UpdateNumberOfSupersteps();
743743

744-
// std::cout << "initial scedule with costs: " << schedule.computeTotalLambdaCosts() << " and " <<
744+
// std::cout << "initial scedule with costs: " << TotalLambdaCommunicationCost<graph>()(schedule) << " and " <<
745745
// schedule.NumberOfSupersteps() << " number of supersteps"<< std::endl;
746746

747747
// BspSchedule<graph> schedule_2(schedule);
@@ -750,31 +750,18 @@ BOOST_AUTO_TEST_CASE(kl_lambda_total_comm_large_test_graphs) {
750750
// BOOST_CHECK_EQUAL(&schedule.GetInstance(), &instance);
751751
// BOOST_CHECK(schedule.SatisfiesPrecedenceConstraints());
752752

753-
// KlTotalLambdaCommImprover_mt<graph,NoLocalSearchMemoryConstraint,1> kl;
753+
// KlTotalLambdaCommImproverMt<graph,NoLocalSearchMemoryConstraint,1> kl;
754754
// auto start_time = std::chrono::high_resolution_clock::now();
755755
// auto status = kl.ImproveSchedule(schedule);
756756
// auto finish_time = std::chrono::high_resolution_clock::now();
757757
// auto duration = std::chrono::duration_cast<std::chrono::seconds>(finish_time - start_time).count();
758758

759-
// std::cout << "kl new finished in " << duration << " seconds, costs: " << schedule.computeTotalLambdaCosts() << " with "
759+
// std::cout << "kl new finished in " << duration << " seconds, costs: " <<
760+
// TotalLambdaCommunicationCost<graph>()(schedule) << " with "
760761
// << schedule.NumberOfSupersteps() << " number of supersteps"<< std::endl;
761762

762763
// BOOST_CHECK(status == ReturnStatus::OSP_SUCCESS || status == ReturnStatus::BEST_FOUND);
763764
// BOOST_CHECK_EQUAL(schedule.SatisfiesPrecedenceConstraints(), true);
764765

765-
// // kl_total_comm_test<graph> kl_old;
766-
767-
// // start_time = std::chrono::high_resolution_clock::now();
768-
// // status = kl_old.improve_schedule_test_2(schedule_2);
769-
// // finish_time = std::chrono::high_resolution_clock::now();
770-
771-
// // duration = std::chrono::duration_cast<std::chrono::seconds>(finish_time - start_time).count();
772-
773-
// // std::cout << "kl old finished in " << duration << " seconds, costs: " << schedule_2.computeTotalCosts() << " with "
774-
// << schedule_2.NumberOfSupersteps() << " number of supersteps"<< std::endl;
775-
776-
// // BOOST_CHECK(status == ReturnStatus::OSP_SUCCESS || status == ReturnStatus::BEST_FOUND);
777-
// // BOOST_CHECK_EQUAL(schedule_2.SatisfiesPrecedenceConstraints(), true);
778-
779766
// }
780767
// }

tests/kl_total.cpp

Lines changed: 55 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -889,73 +889,73 @@ BOOST_AUTO_TEST_CASE(KlImprover_incremental_update_test) {
889889
CheckEqualAffinityTable(affinity, kl_6.GetAffinityTable(), nodes_to_check);
890890
};
891891

892-
BOOST_AUTO_TEST_CASE(kl_total_comm_large_test_graphs) {
893-
std::vector<std::string> filenames_graph = LargeSpaaGraphs();
894-
using graph = ComputationalDagEdgeIdxVectorImplDefIntT;
892+
// BOOST_AUTO_TEST_CASE(kl_total_comm_large_test_graphs) {
893+
// std::vector<std::string> filenames_graph = LargeSpaaGraphs();
894+
// using graph = ComputationalDagEdgeIdxVectorImplDefIntT;
895895

896-
// Getting root git directory
897-
std::filesystem::path cwd = std::filesystem::current_path();
898-
std::cout << cwd << std::endl;
899-
while ((!cwd.empty()) && (cwd.filename() != "OneStopParallel")) {
900-
cwd = cwd.parent_path();
901-
std::cout << cwd << std::endl;
902-
}
896+
// // Getting root git directory
897+
// std::filesystem::path cwd = std::filesystem::current_path();
898+
// std::cout << cwd << std::endl;
899+
// while ((!cwd.empty()) && (cwd.filename() != "OneStopParallel")) {
900+
// cwd = cwd.parent_path();
901+
// std::cout << cwd << std::endl;
902+
// }
903903

904-
for (auto &filename_graph : filenames_graph) {
905-
GreedyBspScheduler<ComputationalDagEdgeIdxVectorImplDefIntT> test_scheduler;
906-
BspInstance<graph> instance;
907-
bool status_graph
908-
= file_reader::ReadComputationalDagHyperdagFormatDB((cwd / filename_graph).string(), instance.GetComputationalDag());
904+
// for (auto &filename_graph : filenames_graph) {
905+
// GreedyBspScheduler<ComputationalDagEdgeIdxVectorImplDefIntT> test_scheduler;
906+
// BspInstance<graph> instance;
907+
// bool status_graph
908+
// = file_reader::ReadComputationalDagHyperdagFormatDB((cwd / filename_graph).string(), instance.GetComputationalDag());
909909

910-
instance.GetArchitecture().SetSynchronisationCosts(500);
911-
instance.GetArchitecture().SetCommunicationCosts(5);
912-
instance.GetArchitecture().SetNumberOfProcessors(4);
910+
// instance.GetArchitecture().SetSynchronisationCosts(500);
911+
// instance.GetArchitecture().SetCommunicationCosts(5);
912+
// instance.GetArchitecture().SetNumberOfProcessors(4);
913913

914-
std::vector<std::vector<int>> send_cost = {
915-
{0, 1, 4, 4},
916-
{1, 0, 4, 4},
917-
{4, 4, 0, 1},
918-
{4, 4, 1, 0}
919-
};
914+
// std::vector<std::vector<int>> send_cost = {
915+
// {0, 1, 4, 4},
916+
// {1, 0, 4, 4},
917+
// {4, 4, 0, 1},
918+
// {4, 4, 1, 0}
919+
// };
920920

921-
instance.GetArchitecture().SetSendCosts(send_cost);
921+
// instance.GetArchitecture().SetSendCosts(send_cost);
922922

923-
if (!status_graph) {
924-
std::cout << "Reading files failed." << std::endl;
925-
BOOST_CHECK(false);
926-
}
923+
// if (!status_graph) {
924+
// std::cout << "Reading files failed." << std::endl;
925+
// BOOST_CHECK(false);
926+
// }
927927

928-
AddMemWeights(instance.GetComputationalDag());
928+
// AddMemWeights(instance.GetComputationalDag());
929929

930-
BspSchedule<graph> schedule(instance);
931-
const auto result = test_scheduler.ComputeSchedule(schedule);
930+
// BspSchedule<graph> schedule(instance);
931+
// const auto result = test_scheduler.ComputeSchedule(schedule);
932932

933-
schedule.UpdateNumberOfSupersteps();
933+
// schedule.UpdateNumberOfSupersteps();
934934

935-
std::cout << "initial scedule with costs: " << TotalCommunicationCost<graph>()(schedule) << " and "
936-
<< schedule.NumberOfSupersteps() << " number of supersteps" << std::endl;
935+
// std::cout << "initial scedule with costs: " << TotalCommunicationCost<graph>()(schedule) << " and "
936+
// << schedule.NumberOfSupersteps() << " number of supersteps" << std::endl;
937937

938-
BspSchedule<graph> schedule_2(schedule);
938+
// BspSchedule<graph> schedule_2(schedule);
939939

940-
BOOST_CHECK_EQUAL(ReturnStatus::OSP_SUCCESS, result);
941-
BOOST_CHECK_EQUAL(&schedule.GetInstance(), &instance);
942-
BOOST_CHECK(schedule.SatisfiesPrecedenceConstraints());
940+
// BOOST_CHECK_EQUAL(ReturnStatus::OSP_SUCCESS, result);
941+
// BOOST_CHECK_EQUAL(&schedule.GetInstance(), &instance);
942+
// BOOST_CHECK(schedule.SatisfiesPrecedenceConstraints());
943943

944-
KlTotalCommImprover<graph, NoLocalSearchMemoryConstraint, 1, true> kl;
944+
// KlTotalCommImprover<graph, NoLocalSearchMemoryConstraint, 1, true> kl;
945945

946-
auto start_time = std::chrono::high_resolution_clock::now();
947-
auto status = kl.ImproveSchedule(schedule);
948-
auto finish_time = std::chrono::high_resolution_clock::now();
946+
// auto start_time = std::chrono::high_resolution_clock::now();
947+
// auto status = kl.ImproveSchedule(schedule);
948+
// auto finish_time = std::chrono::high_resolution_clock::now();
949949

950-
auto duration = std::chrono::duration_cast<std::chrono::seconds>(finish_time - start_time).count();
950+
// auto duration = std::chrono::duration_cast<std::chrono::seconds>(finish_time - start_time).count();
951951

952-
std::cout << "kl new finished in " << duration << " seconds, costs: " << TotalCommunicationCost<graph>()(schedule)
953-
<< " with " << schedule.NumberOfSupersteps() << " number of supersteps" << std::endl;
952+
// std::cout << "kl new finished in " << duration << " seconds, costs: " << TotalCommunicationCost<graph>()(schedule)
953+
// << " with " << schedule.NumberOfSupersteps() << " number of supersteps" << std::endl;
954954

955-
BOOST_CHECK(status == ReturnStatus::OSP_SUCCESS || status == ReturnStatus::BEST_FOUND);
956-
BOOST_CHECK_EQUAL(schedule.SatisfiesPrecedenceConstraints(), true);
957-
}
958-
}
955+
// BOOST_CHECK(status == ReturnStatus::OSP_SUCCESS || status == ReturnStatus::BEST_FOUND);
956+
// BOOST_CHECK_EQUAL(schedule.SatisfiesPrecedenceConstraints(), true);
957+
// }
958+
// }
959959

960960
// BOOST_AUTO_TEST_CASE(kl_total_comm_large_test_graphs_mt) {
961961
// std::vector<std::string> filenames_graph = LargeSpaaGraphs();
@@ -999,7 +999,8 @@ BOOST_AUTO_TEST_CASE(kl_total_comm_large_test_graphs) {
999999

10001000
// schedule.UpdateNumberOfSupersteps();
10011001

1002-
// std::cout << "initial scedule with costs: " << schedule.computeTotalCosts() << " and " << schedule.NumberOfSupersteps()
1002+
// std::cout << "initial scedule with costs: " << TotalCommunicationCost<graph>()(schedule)<< " and " <<
1003+
// schedule.NumberOfSupersteps()
10031004
// << " number of supersteps"<< std::endl;
10041005

10051006
// BspSchedule<graph> schedule_2(schedule);
@@ -1008,37 +1009,19 @@ BOOST_AUTO_TEST_CASE(kl_total_comm_large_test_graphs) {
10081009
// BOOST_CHECK_EQUAL(&schedule.GetInstance(), &instance);
10091010
// BOOST_CHECK(schedule.SatisfiesPrecedenceConstraints());
10101011

1011-
// using MtImprover = KlImproverMt<graph,
1012-
// KlMaxBspCommCostFunction<graph, double, NoLocalSearchMemoryConstraint, EagerCommCostPolicy, 1>,
1013-
// NoLocalSearchMemoryConstraint, 1, double>;
1014-
1015-
// KlTotalCommImprover_mt<graph,NoLocalSearchMemoryConstraint,1,true> kl;
1012+
// KlTotalCommImproverMt<graph,NoLocalSearchMemoryConstraint,1,true> kl;
10161013

10171014
// auto start_time = std::chrono::high_resolution_clock::now();
10181015
// auto status = kl.ImproveSchedule(schedule);
10191016
// auto finish_time = std::chrono::high_resolution_clock::now();
10201017

10211018
// auto duration = std::chrono::duration_cast<std::chrono::seconds>(finish_time - start_time).count();
10221019

1023-
// std::cout << "kl new finished in " << duration << " seconds, costs: " << schedule.computeTotalCosts() << " with " <<
1024-
// schedule.NumberOfSupersteps() << " number of supersteps"<< std::endl;
1020+
// std::cout << "kl new finished in " << duration << " seconds, costs: " << TotalCommunicationCost<graph>()(schedule) << "
1021+
// with " << schedule.NumberOfSupersteps() << " number of supersteps"<< std::endl;
10251022

10261023
// BOOST_CHECK(status == ReturnStatus::OSP_SUCCESS || status == ReturnStatus::BEST_FOUND);
10271024
// BOOST_CHECK_EQUAL(schedule.SatisfiesPrecedenceConstraints(), true);
10281025

1029-
// // kl_total_comm_test<graph> kl_old;
1030-
1031-
// // start_time = std::chrono::high_resolution_clock::now();
1032-
// // status = kl_old.improve_schedule_test_2(schedule_2);
1033-
// // finish_time = std::chrono::high_resolution_clock::now();
1034-
1035-
// // duration = std::chrono::duration_cast<std::chrono::seconds>(finish_time - start_time).count();
1036-
1037-
// // std::cout << "kl old finished in " << duration << " seconds, costs: " << schedule_2.computeTotalCosts() << " with "
1038-
// << schedule_2.NumberOfSupersteps() << " number of supersteps"<< std::endl;
1039-
1040-
// // BOOST_CHECK(status == ReturnStatus::OSP_SUCCESS || status == ReturnStatus::BEST_FOUND);
1041-
// // BOOST_CHECK_EQUAL(schedule_2.SatisfiesPrecedenceConstraints(), true);
1042-
10431026
// }
10441027
// }

0 commit comments

Comments
 (0)