Skip to content

Commit 64e8df5

Browse files
committed
pr comments
1 parent 55e8e57 commit 64e8df5

File tree

4 files changed

+68
-8
lines changed

4 files changed

+68
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ class kl_base : public ImprovementScheduler<Graph_t>, public Ikl_cost_function {
437437
node_best_proc = proc;
438438
rand_count = 0;
439439

440-
} else if (node_max_gain <= proc_max) {
440+
} else if (node_max_gain <= proc_max) { // only ==
441441

442442
if (rand() % (2 + rand_count) == 0) {
443443
node_max_gain = proc_max;

include/osp/bsp/scheduler/LocalSearch/KernighanLin_v2/kl_improver.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ class kl_improver : public ImprovementScheduler<Graph_t> {
9393
constexpr static unsigned window_range = 2 * window_size + 1;
9494
constexpr static bool enable_quick_moves = true;
9595
constexpr static bool enable_preresolving_violations = true;
96-
97-
const double EPSILON = 1e-9;
96+
constexpr static double EPSILON = 1e-9;
9897

9998
using memw_t = v_memw_t<Graph_t>;
10099
using commw_t = v_commw_t<Graph_t>;

include/osp/dag_divider/isomorphism_divider/IsomorphicSubgraphScheduler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ class IsomorphicSubgraphScheduler {
478478
// Map (superstep, processor) -> relative partition ID
479479
std::map<std::pair<unsigned, unsigned>, vertex_idx_t<Graph_t>> sp_proc_to_relative_partition;
480480
vertex_idx_t<Graph_t> num_partitions_per_subgraph = 0;
481-
for (vertex_idx_t<Graph_t> j = 0; j < rep_subgraph_vertices_sorted.size(); ++j) {
481+
for (vertex_idx_t<Graph_t> j = 0; j < static_cast<vertex_idx_t<Graph_t>>(rep_subgraph_vertices_sorted.size()); ++j) {
482482
const auto sp_pair = std::make_pair(bsp_schedule.assignedSuperstep(j), bsp_schedule.assignedProcessor(j));
483483
if (sp_proc_to_relative_partition.find(sp_pair) == sp_proc_to_relative_partition.end()) {
484484
sp_proc_to_relative_partition[sp_pair] = num_partitions_per_subgraph++;
@@ -489,7 +489,7 @@ class IsomorphicSubgraphScheduler {
489489
MerkleHashComputer<Constr_Graph_t> rep_hasher(representative_instance.getComputationalDag());
490490

491491
// Replicate the schedule pattern for ALL subgraphs in the group ---
492-
for (vertex_idx_t<Graph_t> i = 0; i < group.subgraphs.size(); ++i) {
492+
for (vertex_idx_t<Graph_t> i = 0; i < static_cast<vertex_idx_t<Graph_t>>(group.subgraphs.size()); ++i) {
493493
auto current_subgraph_vertices_sorted = group.subgraphs[i];
494494
std::sort(current_subgraph_vertices_sorted.begin(), current_subgraph_vertices_sorted.end());
495495

tests/graph_vector_adapter.cpp

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ limitations under the License.
4343
using namespace osp;
4444

4545

46-
BOOST_AUTO_TEST_CASE(test_dag_vector_adapter) {
46+
BOOST_AUTO_TEST_CASE(test_dag_vector_adapter_edge) {
4747

4848
std::vector<std::vector<int>> out_neighbors{{1, 2, 3}, {4, 6}, {4, 5}, {7}, {7}, {}, {}, {}};
4949

5050
std::vector<std::vector<int>> in_neighbors{{}, {0}, {0}, {0}, {1, 2}, {2}, {1}, {4, 3}};
5151

5252
using v_impl = cdag_vertex_impl<unsigned, int, int, int, unsigned>;
5353
using graph_t = dag_vector_adapter<v_impl,int>;
54-
//using graph_constr_t = computational_dag_vector_impl<v_impl>;
5554
using graph_constr_t = computational_dag_edge_idx_vector_impl<v_impl, cdag_edge_impl_int>;
5655
using CoarseGraphType = Compact_Sparse_Graph<true, true, true, true, true, vertex_idx_t<graph_t>, std::size_t, v_workw_t<graph_t>, v_workw_t<graph_t>, v_workw_t<graph_t>, v_type_t<graph_t>>;
5756

@@ -83,7 +82,69 @@ BOOST_AUTO_TEST_CASE(test_dag_vector_adapter) {
8382
ComboScheduler<graph_constr_t> children_kl(children, kl);
8483

8584
GreedyMetaScheduler<graph_constr_t> scheduler;
86-
// scheduler.addScheduler(growlocal_kl);
85+
scheduler.addScheduler(locking_kl);
86+
scheduler.addScheduler(children_kl);
87+
scheduler.addSerialScheduler();
88+
89+
IsomorphicSubgraphScheduler<graph_t, graph_constr_t> iso_scheduler(scheduler);
90+
91+
auto partition = iso_scheduler.compute_partition(instance);
92+
93+
graph_constr_t corase_graph;
94+
coarser_util::construct_coarse_dag(instance.getComputationalDag(), corase_graph, partition);
95+
bool acyc = is_acyclic(corase_graph);
96+
BOOST_CHECK(acyc);
97+
98+
SarkarMul<graph_t, CoarseGraphType> coarser;
99+
100+
CoarseGraphType coarse_dag;
101+
std::vector<unsigned> reverse_vertex_map;
102+
coarser.coarsenDag(graph, coarse_dag, reverse_vertex_map);
103+
104+
acyc = is_acyclic(coarse_dag);
105+
BOOST_CHECK(acyc);
106+
}
107+
108+
109+
BOOST_AUTO_TEST_CASE(test_dag_vector_adapter) {
110+
111+
std::vector<std::vector<int>> out_neighbors{{1, 2, 3}, {4, 6}, {4, 5}, {7}, {7}, {}, {}, {}};
112+
113+
std::vector<std::vector<int>> in_neighbors{{}, {0}, {0}, {0}, {1, 2}, {2}, {1}, {4, 3}};
114+
115+
using v_impl = cdag_vertex_impl<unsigned, int, int, int, unsigned>;
116+
using graph_t = dag_vector_adapter<v_impl,int>;
117+
using graph_constr_t = computational_dag_vector_impl<v_impl>;
118+
using CoarseGraphType = Compact_Sparse_Graph<true, true, true, true, true, vertex_idx_t<graph_t>, std::size_t, v_workw_t<graph_t>, v_workw_t<graph_t>, v_workw_t<graph_t>, v_type_t<graph_t>>;
119+
120+
graph_t graph(out_neighbors, in_neighbors);
121+
122+
for (auto v : graph.vertices()) {
123+
graph.set_vertex_work_weight(v, 10);
124+
}
125+
126+
BspInstance<graph_t> instance;
127+
instance.getComputationalDag() = graph;
128+
129+
instance.getArchitecture().setProcessorsWithTypes({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1});
130+
instance.setDiagonalCompatibilityMatrix(2);
131+
instance.setSynchronisationCosts(1000);
132+
instance.setCommunicationCosts(1);
133+
134+
135+
136+
// Set up the scheduler
137+
GrowLocalAutoCores<graph_constr_t> growlocal;
138+
BspLocking<graph_constr_t> locking;
139+
GreedyChildren<graph_constr_t> children;
140+
kl_total_lambda_comm_improver<graph_constr_t> kl(42);
141+
kl.setSuperstepRemoveStrengthParameter(2.0);
142+
kl.setTimeQualityParameter(5.0);
143+
ComboScheduler<graph_constr_t> growlocal_kl(growlocal, kl);
144+
ComboScheduler<graph_constr_t> locking_kl(locking, kl);
145+
ComboScheduler<graph_constr_t> children_kl(children, kl);
146+
147+
GreedyMetaScheduler<graph_constr_t> scheduler;
87148
scheduler.addScheduler(locking_kl);
88149
scheduler.addScheduler(children_kl);
89150
scheduler.addSerialScheduler();

0 commit comments

Comments
 (0)