Skip to content

Commit 80a0497

Browse files
committed
bug fix
1 parent 6ee2a23 commit 80a0497

File tree

5 files changed

+94
-167
lines changed

5 files changed

+94
-167
lines changed

include/osp/dag_divider/isomorphism_divider/MerkleHashComputer.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,19 @@ struct bwd_merkle_node_hash_func {
161161

162162
MerkleHashComputer<Graph_t, uniform_node_hash_func<vertex_idx_t<Graph_t>>, false> bw_merkle_hash;
163163

164-
bwd_merkle_node_hash_func(const Graph_t & graph) : bw_merkle_hash(graph) {}
164+
const Graph_t & graph_;
165+
166+
bwd_merkle_node_hash_func(const Graph_t & graph) : bw_merkle_hash(graph), graph_(graph) {}
165167

166168
std::size_t operator()(const vertex_idx_t<Graph_t> & v) const {
167-
return bw_merkle_hash.get_vertex_hash(v);
169+
std::size_t hash = bw_merkle_hash.get_vertex_hash(v);
170+
hash_combine(hash, graph_.vertex_work_weight(v));
171+
172+
if constexpr (has_typed_vertices_v<Graph_t>) {
173+
hash_combine(hash, graph_.vertex_type(v));
174+
}
175+
176+
return hash;
168177
}
169178
};
170179

include/osp/dag_divider/isomorphism_divider/OrbitGraphProcessor.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ class OrbitGraphProcessor {
148148
const std::vector< vertex_idx_t<Constr_Graph_t> > vertexPoset = get_top_node_distance<Constr_Graph_t, vertex_idx_t<Constr_Graph_t>>(current_coarse_graph);
149149
const std::vector< vertex_idx_t<Constr_Graph_t> > vertexBotPoset = get_bottom_node_distance<Constr_Graph_t, vertex_idx_t<Constr_Graph_t>>(current_coarse_graph);
150150

151-
152151
changed = false;
153152
for (const auto& edge : edges(current_coarse_graph)) {
154153
VertexType u = source(edge, current_coarse_graph);
@@ -190,7 +189,7 @@ class OrbitGraphProcessor {
190189
continue;
191190
}
192191

193-
const bool crtical_path_longer = critical_path_weight(temp_coarse_graph) > critical_path_weight(current_coarse_graph);
192+
const bool crtical_path_longer = critical_path_weight(temp_coarse_graph) > (80 * new_subgraphs.size() + critical_path_weight(current_coarse_graph));
194193
// Check if merging increases the critical path
195194
if (crtical_path_longer) {
196195
if constexpr (verbose) { std::cout << " - Merge of " << u << " and " << v << " increases critical path. Skipping.\n"; }
@@ -282,14 +281,15 @@ class OrbitGraphProcessor {
282281
std::sort(all_nodes.begin(), all_nodes.end());
283282

284283
Constr_Graph_t induced_subgraph;
285-
create_induced_subgraph(original_dag, induced_subgraph, all_nodes);
284+
auto map = create_induced_subgraph_map(original_dag, induced_subgraph, all_nodes);
286285

287286
std::vector<VertexType> components; // local -> component_id
288287
size_t num_components = compute_weakly_connected_components(induced_subgraph, components);
289288

290289
out_new_subgraphs.assign(num_components, std::vector<VertexType>());
291-
for (VertexType i = 0; i < induced_subgraph.num_vertices(); ++i) {
292-
out_new_subgraphs[components[i]].push_back(all_nodes[i]);
290+
291+
for (const auto & node : all_nodes) {
292+
out_new_subgraphs[components[map[node]]].push_back(node);
293293
}
294294

295295
if (num_components < symmetry_threshold_) {

tests/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ _add_test( isomorphism_mapper )
6868

6969
_add_test( merkle_hash_computer )
7070

71-
#_add_test( merkle_hash_divider )
72-
7371
_add_test( orbit_graph_processor )
7472

7573
_add_test( eft_subgraph_scheduler )
@@ -78,6 +76,11 @@ _add_test( wavefront_component_divider )
7876

7977
_add_test( hill_climbing )
8078

79+
# --- Standalone Debugging Executables ---
80+
add_executable(debug_merkle_divider debug_merkle_divider.cpp)
81+
target_link_libraries(debug_merkle_divider PRIVATE OneStopParallel ProjectExecutableFlags)
82+
83+
8184
## bsp model
8285
_add_test( bsp_architecture )
8386

tests/debug_merkle_divider.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Copyright 2024 Huawei Technologies Co., Ltd.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
@author Toni Boehnlein, Benjamin Lozes, Pal Andras Papp, Raphael S. Steiner
17+
*/
18+
19+
#include <iostream>
20+
#include "osp/auxiliary/io/dot_graph_file_reader.hpp"
21+
#include "osp/auxiliary/io/DotFileWriter.hpp"
22+
#include "osp/bsp/scheduler/GreedySchedulers/BspLocking.hpp"
23+
#include "osp/bsp/scheduler/LocalSearch/KernighanLin_v2/kl_include_mt.hpp"
24+
#include "osp/coarser/coarser_util.hpp"
25+
#include "osp/dag_divider/isomorphism_divider/IsomorphicSubgraphScheduler.hpp"
26+
#include "osp/graph_implementations/adj_list_impl/computational_dag_vector_impl.hpp"
27+
28+
using namespace osp;
29+
30+
int main(int argc, char* argv[]) {
31+
if (argc < 2) {
32+
std::cerr << "Usage: " << argv[0] << " <path_to_dot_file>" << std::endl;
33+
return 1;
34+
}
35+
36+
std::string dot_file_path = argv[1];
37+
38+
using graph_t = computational_dag_vector_impl_def_t;
39+
using graph_t2 = graph_t;
40+
41+
BspInstance<graph_t2> instance;
42+
if (!file_reader::readComputationalDagDotFormat(dot_file_path, instance.getComputationalDag())) {
43+
std::cerr << "Failed to read graph from " << dot_file_path << std::endl;
44+
return 1;
45+
}
46+
47+
std::cout << "Graph loaded successfully. " << instance.numberOfVertices() << " vertices." << std::endl;
48+
49+
// Set up architecture
50+
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});
51+
instance.setDiagonalCompatibilityMatrix(2);
52+
instance.setSynchronisationCosts(20000);
53+
instance.setCommunicationCosts(10);
54+
55+
// Set up the scheduler
56+
BspLocking<graph_t> greedy;
57+
kl_total_lambda_comm_improver_mt<graph_t> kl;
58+
ComboScheduler<graph_t> combo(greedy, kl);
59+
60+
IsomorphicSubgraphScheduler<graph_t2, graph_t> iso_scheduler(combo);
61+
iso_scheduler.set_symmetry(4);
62+
iso_scheduler.set_plot_dot_graphs(true); // Enable plotting for debug
63+
64+
std::cout << "Starting partition computation..." << std::endl;
65+
66+
// This is the call that is expected to throw the exception
67+
auto partition = iso_scheduler.compute_partition(instance);
68+
69+
std::cout << "Partition computation finished." << std::endl;
70+
std::cout << "Generated " << std::set<vertex_idx_t<graph_t>>(partition.begin(), partition.end()).size() << " partitions." << std::endl;
71+
72+
return 0;
73+
}

tests/merkle_hash_divider.cpp

Lines changed: 0 additions & 158 deletions
This file was deleted.

0 commit comments

Comments
 (0)