Skip to content

Commit be66f83

Browse files
Merge branch 'master' into noc_pack_part
2 parents 5eb7a07 + 109c5ad commit be66f83

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

vpr/src/route/route_common.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,28 @@ void pathfinder_update_acc_cost_and_overuse_info(float acc_fac, OveruseInfo& ove
190190
auto& device_ctx = g_vpr_ctx.device();
191191
const auto& rr_graph = device_ctx.rr_graph;
192192
auto& route_ctx = g_vpr_ctx.mutable_routing();
193+
194+
#ifdef VPR_USE_TBB
195+
tbb::combinable<size_t> overused_nodes(0), total_overuse(0), worst_overuse(0);
196+
tbb::parallel_for_each(rr_graph.nodes().begin(), rr_graph.nodes().end(), [&](RRNodeId rr_id) {
197+
int overuse = route_ctx.rr_node_route_inf[rr_id].occ() - rr_graph.node_capacity(rr_id);
198+
199+
// If overused, update the acc_cost and add this node to the overuse info
200+
// If not, do nothing
201+
if (overuse > 0) {
202+
route_ctx.rr_node_route_inf[rr_id].acc_cost += overuse * acc_fac;
203+
204+
++overused_nodes.local();
205+
total_overuse.local() += overuse;
206+
worst_overuse.local() = std::max(worst_overuse.local(), size_t(overuse));
207+
}
208+
});
209+
210+
// Update overuse info
211+
overuse_info.overused_nodes = overused_nodes.combine(std::plus<size_t>());
212+
overuse_info.total_overuse = total_overuse.combine(std::plus<size_t>());
213+
overuse_info.worst_overuse = worst_overuse.combine([](size_t a, size_t b) { return std::max(a, b); });
214+
#else
193215
size_t overused_nodes = 0, total_overuse = 0, worst_overuse = 0;
194216

195217
for (const RRNodeId& rr_id : rr_graph.nodes()) {
@@ -210,6 +232,7 @@ void pathfinder_update_acc_cost_and_overuse_info(float acc_fac, OveruseInfo& ove
210232
overuse_info.overused_nodes = overused_nodes;
211233
overuse_info.total_overuse = total_overuse;
212234
overuse_info.worst_overuse = worst_overuse;
235+
#endif
213236
}
214237

215238
/** Update pathfinder cost of all nodes rooted at rt_node, including rt_node itself */

vpr/src/route/route_net.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,23 @@ WirelengthInfo calculate_wirelength_info(const Netlist<>& net_list, size_t avail
251251

252252
auto& route_ctx = g_vpr_ctx.routing();
253253

254+
#ifdef VPR_USE_TBB
255+
tbb::combinable<size_t> thread_used_wirelength(0);
256+
257+
tbb::parallel_for_each(net_list.nets().begin(), net_list.nets().end(), [&](ParentNetId net_id) {
258+
if (!net_list.net_is_ignored(net_id)
259+
&& net_list.net_sinks(net_id).size() != 0 /* Globals don't count. */
260+
&& route_ctx.route_trees[net_id]) {
261+
int bends, wirelength, segments;
262+
bool is_absorbed;
263+
get_num_bends_and_length(net_id, &bends, &wirelength, &segments, &is_absorbed);
264+
265+
thread_used_wirelength.local() += wirelength;
266+
}
267+
});
268+
269+
used_wirelength = thread_used_wirelength.combine(std::plus<size_t>());
270+
#else
254271
for (auto net_id : net_list.nets()) {
255272
if (!net_list.net_is_ignored(net_id)
256273
&& net_list.net_sinks(net_id).size() != 0 /* Globals don't count. */
@@ -262,6 +279,7 @@ WirelengthInfo calculate_wirelength_info(const Netlist<>& net_list, size_t avail
262279
used_wirelength += wirelength;
263280
}
264281
}
282+
#endif
265283

266284
return WirelengthInfo(available_wirelength, used_wirelength);
267285
}

0 commit comments

Comments
 (0)