@@ -1027,46 +1027,57 @@ void ClusteringEngine::buildDataFlowConnections()
10271027 }
10281028
10291029 const int driver_id = itr->second ;
1030+ Cluster* driver_cluster = tree_->maps .id_to_cluster .at (driver_id);
10301031
10311032 for (int hops = 0 ; hops < max_num_of_hops_; hops++) {
10321033 std::set<int > sink_clusters = computeSinks (insts[hops]);
10331034 const float conn_weight = computeConnWeight (hops);
10341035 for (auto & sink : sink_clusters) {
1035- tree_->maps .id_to_cluster [driver_id]-> addConnection (sink, conn_weight );
1036- tree_-> maps . id_to_cluster [sink]-> addConnection (driver_id , conn_weight);
1036+ Cluster* sink_cluster = tree_->maps .id_to_cluster . at (sink);
1037+ connect (driver_cluster, sink_cluster , conn_weight);
10371038 }
10381039 }
10391040 }
10401041
10411042 // macros to ffs
10421043 for (const auto & [iterm, insts] : data_connections_.macro_pins_and_regs ) {
10431044 const int driver_id = tree_->maps .inst_to_cluster_id .at (iterm->getInst ());
1045+ Cluster* driver_cluster = tree_->maps .id_to_cluster .at (driver_id);
10441046
10451047 for (int hops = 0 ; hops < max_num_of_hops_; hops++) {
10461048 std::set<int > sink_clusters = computeSinks (insts[hops]);
10471049 const float conn_weight = computeConnWeight (hops);
10481050 for (auto & sink : sink_clusters) {
1049- tree_->maps .id_to_cluster [driver_id]-> addConnection (sink, conn_weight );
1050- tree_-> maps . id_to_cluster [sink]-> addConnection (driver_id , conn_weight);
1051+ Cluster* sink_cluster = tree_->maps .id_to_cluster . at (sink);
1052+ connect (driver_cluster, sink_cluster , conn_weight);
10511053 }
10521054 }
10531055 }
10541056
10551057 // macros to macros
10561058 for (const auto & [iterm, insts] : data_connections_.macro_pins_and_macros ) {
10571059 const int driver_id = tree_->maps .inst_to_cluster_id .at (iterm->getInst ());
1060+ Cluster* driver_cluster = tree_->maps .id_to_cluster .at (driver_id);
10581061
10591062 for (int hops = 0 ; hops < max_num_of_hops_; hops++) {
10601063 std::set<int > sink_clusters = computeSinks (insts[hops]);
10611064 const float conn_weight = computeConnWeight (hops);
10621065 for (auto & sink : sink_clusters) {
1063- tree_->maps .id_to_cluster [driver_id]-> addConnection (sink, conn_weight );
1064- tree_-> maps . id_to_cluster [sink]-> addConnection (driver_id , conn_weight);
1066+ Cluster* sink_cluster = tree_->maps .id_to_cluster . at (sink);
1067+ connect (driver_cluster, sink_cluster , conn_weight);
10651068 }
10661069 }
10671070 }
10681071}
10691072
1073+ void ClusteringEngine::connect (Cluster* a,
1074+ Cluster* b,
1075+ const float connection_weight) const
1076+ {
1077+ a->addConnection (b, connection_weight);
1078+ b->addConnection (a, connection_weight);
1079+ }
1080+
10701081float ClusteringEngine::computeConnWeight (const int hops)
10711082{
10721083 const float base_remoteness_factor = 2.0 ;
@@ -1863,7 +1874,7 @@ bool ClusteringEngine::attemptMerge(Cluster* receiver, Cluster* incomer)
18631874 for (const auto & [cluster_id, connection_weight] : incomer_connections) {
18641875 Cluster* cluster = tree_->maps .id_to_cluster .at (cluster_id);
18651876 cluster->removeConnection (incomer_id);
1866- cluster->addConnection (receiver-> getId () , connection_weight);
1877+ cluster->addConnection (receiver, connection_weight);
18671878 }
18681879 }
18691880
@@ -1928,13 +1939,12 @@ void ClusteringEngine::buildNetListConnections()
19281939 if (driver_cluster_id != -1 && !load_clusters_ids.empty ()
19291940 && load_clusters_ids.size () < tree_->large_net_threshold ) {
19301941 const float weight = net_has_io_pin ? tree_->virtual_weight : 1.0 ;
1942+ Cluster* driver_cluster = tree_->maps .id_to_cluster .at (driver_cluster_id);
19311943
19321944 for (const int load_cluster_id : load_clusters_ids) {
1933- if (load_cluster_id != driver_cluster_id) { /* undirected connection */
1934- tree_->maps .id_to_cluster [driver_cluster_id]->addConnection (
1935- load_cluster_id, weight);
1936- tree_->maps .id_to_cluster [load_cluster_id]->addConnection (
1937- driver_cluster_id, weight);
1945+ if (load_cluster_id != driver_cluster_id) {
1946+ Cluster* load_cluster = tree_->maps .id_to_cluster .at (load_cluster_id);
1947+ connect (driver_cluster, load_cluster, weight);
19381948 }
19391949 }
19401950 }
0 commit comments