Skip to content

Commit ef03f47

Browse files
committed
fix formatting and warnings
1 parent 2c97bda commit ef03f47

26 files changed

+1871
-1852
lines changed

libs/libvtrutil/src/tl_optional.hpp

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

libs/libvtrutil/src/vtr_optional.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
#pragma once
22

3-
/* std::optional with optional refs.
3+
/* std::optional-like interface with optional references.
44
* currently: import TartanLlama's optional into the vtr namespace
5-
* documentation at https://tl.tartanllama.xyz/en/latest/api/optional.html */
5+
* documentation at https://tl.tartanllama.xyz/en/latest/api/optional.html
6+
* there are three main uses of this:
7+
* 1. replace pointers when refactoring legacy code
8+
* optional<T&> (reference) is in many ways a pointer, it even has * and -> operators,
9+
* but it can't be allocated or freed. this property is very helpful when
10+
* refactoring code with a lot of malloc, free, new and delete.
11+
* 2. explicit alternative for containers
12+
* optional<T> (non-reference) allows you to put non-empty-initializable
13+
* objects into a container which owns them. it is an alternative to
14+
* unique_ptr<T> in that sense, but with a cleaner interface.
15+
* 3. function return types
16+
* returning an optional<T> gives the caller a clear hint to check the return value.
17+
*/
618

719
#include "tl_optional.hpp"
820

@@ -14,4 +26,4 @@ using nullopt_t = tl::nullopt_t;
1426
static constexpr nullopt_t nullopt = tl::nullopt;
1527

1628
using bad_optional_access = tl::bad_optional_access;
17-
}
29+
} // namespace vtr

utils/fasm/test/test_lut.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TEST_CASE("default_lut", "[fasm]") {
1212
fasm::Lut lut(num_inputs);
1313

1414
const LogicVec &table = lut.table();
15-
CHECK(table.size() == (1 << num_inputs));
15+
CHECK(table.size() == size_t(1 << num_inputs));
1616

1717
for(const vtr::LogicValue & value : table) {
1818
CHECK(value == vtr::LogicValue::FALSE);
@@ -27,7 +27,7 @@ TEST_CASE("const_true", "[fasm]") {
2727
lut.SetConstant(vtr::LogicValue::TRUE);
2828

2929
const LogicVec &table = lut.table();
30-
CHECK(table.size() == (1 << num_inputs));
30+
CHECK(table.size() == size_t(1 << num_inputs));
3131

3232
for(const vtr::LogicValue & value : table) {
3333
CHECK(value == vtr::LogicValue::TRUE);
@@ -42,7 +42,7 @@ TEST_CASE("const_false", "[fasm]") {
4242
lut.SetConstant(vtr::LogicValue::FALSE);
4343

4444
const LogicVec &table = lut.table();
45-
CHECK(table.size() == (1 << num_inputs));
45+
CHECK(table.size() == size_t(1 << num_inputs));
4646

4747
for(const vtr::LogicValue & value : table) {
4848
CHECK(value == vtr::LogicValue::FALSE);
@@ -58,7 +58,7 @@ TEST_CASE("wire", "[fasm]") {
5858
lut.CreateWire(input_pin);
5959

6060
const LogicVec &table = lut.table();
61-
CHECK(table.size() == (1 << num_inputs));
61+
CHECK(table.size() == size_t(1 << num_inputs));
6262
for(size_t i = 0; i < table.size(); ++i) {
6363
if(((1 << input_pin) & i) != 0) {
6464
CHECK(table[i] == vtr::LogicValue::TRUE);

vpr/src/base/old_traceback.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static t_trace* traceback_to_route_tree_branch(t_trace* trace,
7171
RouteTree& tree,
7272
std::unordered_map<RRNodeId, vtr::optional<RouteTreeNode&>>& rr_node_to_rt) {
7373
t_trace* next = nullptr;
74-
if(!trace)
74+
if (!trace)
7575
return nullptr;
7676

7777
vtr::optional<RouteTreeNode&> node;
@@ -132,7 +132,7 @@ static t_trace* traceback_to_route_tree_branch(t_trace* trace,
132132
std::pair<t_trace*, t_trace*> traceback_from_route_tree_recurr(t_trace* head, t_trace* tail, const RouteTreeNode& node) {
133133
if (node.child_nodes().size() > 0) {
134134
//Recursively add children
135-
for(auto& child: node.child_nodes()){
135+
for (auto& child : node.child_nodes()) {
136136
t_trace* curr = alloc_trace_data();
137137
curr->index = size_t(node.inode);
138138
curr->net_pin_index = node.net_pin_index;
@@ -176,15 +176,15 @@ std::pair<t_trace*, t_trace*> traceback_from_route_tree_recurr(t_trace* head, t_
176176
}
177177

178178
/* Creates the traceback for net inet from the route tree rooted at root */
179-
t_trace* traceback_from_route_tree(const RouteTreeNode& root, int num_routed_sinks) {
179+
t_trace* traceback_from_route_tree(const RouteTree& tree, int num_routed_sinks) {
180180
auto& device_ctx = g_vpr_ctx.device();
181181
const auto& rr_graph = device_ctx.rr_graph;
182182

183183
t_trace* head;
184184
t_trace* tail;
185185
std::unordered_set<int> nodes;
186186

187-
std::tie(head, tail) = traceback_from_route_tree_recurr(nullptr, nullptr, root);
187+
std::tie(head, tail) = traceback_from_route_tree_recurr(nullptr, nullptr, tree.root);
188188

189189
VTR_ASSERT(head);
190190
VTR_ASSERT(tail);

vpr/src/base/stats.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ static void load_channel_occupancies(const Netlist<>& net_list,
262262
continue;
263263

264264
auto& tree = route_ctx.route_trees[net_id];
265-
if(!tree)
265+
if (!tree)
266266
continue;
267267

268-
for(auto& rt_node: tree.value()) {
268+
for (auto& rt_node : tree.value()) {
269269
RRNodeId inode = rt_node.inode;
270270
t_rr_type rr_type = rr_graph.node_type(inode);
271271

@@ -299,17 +299,17 @@ void get_num_bends_and_length(ParentNetId inet, int* bends_ptr, int* len_ptr, in
299299
length = 0;
300300
segments = 0;
301301

302-
const vtr::optional<RouteTree>& tree = route_ctx.route_trees[inet];
303-
if(!tree){
302+
const vtr::optional<RouteTree>& tree = route_ctx.route_trees[inet];
303+
if (!tree) {
304304
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
305305
"in get_num_bends_and_length: net #%lu has no routing.\n", size_t(inet));
306-
}
306+
}
307307

308-
for(auto &rt_node: tree.value()){
308+
for (auto& rt_node : tree.value()) {
309309
RRNodeId inode = rt_node.inode;
310310
t_rr_type curr_type = rr_graph.node_type(inode);
311311

312-
if(!rt_node.parent)
312+
if (!rt_node.parent)
313313
continue;
314314

315315
t_rr_type prev_type = rr_graph.node_type(rt_node.parent->inode);

vpr/src/base/vpr_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
#include "iostream"
9797

9898
#ifdef VPR_USE_TBB
99-
#define TBB_PREVIEW_GLOBAL_CONTROL 1
99+
# define TBB_PREVIEW_GLOBAL_CONTROL 1
100100
# include <tbb/task_arena.h>
101101
# include <tbb/global_control.h>
102102
#endif

vpr/src/draw/draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ bool trace_routed_connection_rr_nodes_recurr(const RouteTreeNode& rt_node,
871871
return true;
872872
}
873873

874-
for(const RouteTreeNode& child_rt_node: rt_node.child_nodes()){
874+
for (const RouteTreeNode& child_rt_node : rt_node.child_nodes()) {
875875
bool on_path_to_sink = trace_routed_connection_rr_nodes_recurr(
876876
child_rt_node, sink_rr_node, rr_nodes_on_path);
877877
if (on_path_to_sink) {

vpr/src/draw/draw_basic.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,11 @@ void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {
546546
if (cluster_ctx.clb_nlist.net_is_ignored(convert_to_cluster_net_id(net_id))) /* Don't draw. */
547547
return;
548548

549-
if (!route_ctx.route_trees[net_id]) // No routing -> Skip. (Allows me to draw partially complete routes)
549+
if (!route_ctx.route_trees[net_id]) // No routing -> Skip. (Allows me to draw partially complete routes)
550550
return;
551551

552552
std::vector<int> rr_nodes_to_draw;
553-
for (auto &rt_node: route_ctx.route_trees[net_id].value()) {
553+
for (auto& rt_node : route_ctx.route_trees[net_id].value()) {
554554
int inode = size_t(rt_node.inode);
555555

556556
if (draw_if_net_highlighted(convert_to_cluster_net_id(net_id))) {
@@ -565,7 +565,7 @@ void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {
565565

566566
rr_nodes_to_draw.push_back(inode);
567567

568-
if (rt_node.child_nodes().empty()) { // End of branch
568+
if (rt_node.child_nodes().empty()) { // End of branch
569569
draw_partial_route(rr_nodes_to_draw, g);
570570
rr_nodes_to_draw.clear();
571571
}

vpr/src/draw/draw_searchbar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ void highlight_nets(char* message, int hit_node, bool is_flat) {
173173
t_draw_state* draw_state = get_draw_state_vars();
174174

175175
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
176-
if(!route_ctx.route_trees[net_id])
176+
if (!route_ctx.route_trees[net_id])
177177
continue;
178178
ParentNetId parent_id = get_cluster_net_parent_id(g_vpr_ctx.atom().lookup, net_id, is_flat);
179179

180-
for (auto& rt_node: route_ctx.route_trees[parent_id].value()) {
180+
for (auto& rt_node : route_ctx.route_trees[parent_id].value()) {
181181
int inode = size_t(rt_node.inode);
182182
if (draw_state->draw_rr_node[inode].color == ezgl::MAGENTA) {
183183
draw_state->net_color[net_id] = draw_state->draw_rr_node[inode].color;

vpr/src/power/power.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,9 @@ static void power_usage_routing(t_power_usage* power_usage,
813813
/* Populate net indices into rr graph */
814814
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
815815
ParentNetId parent_id = get_cluster_net_parent_id(g_vpr_ctx.atom().lookup, net_id, is_flat);
816-
if(!route_ctx.route_trees[parent_id])
816+
if (!route_ctx.route_trees[parent_id])
817817
continue;
818-
for (auto& rt_node: route_ctx.route_trees[parent_id].value()) {
818+
for (auto& rt_node : route_ctx.route_trees[parent_id].value()) {
819819
rr_node_power[size_t(rt_node.inode)].visited = false;
820820
rr_node_power[size_t(rt_node.inode)].net_num = net_id;
821821
}
@@ -824,9 +824,9 @@ static void power_usage_routing(t_power_usage* power_usage,
824824
/* Populate net indices into rr graph */
825825
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
826826
ParentNetId parent_id = get_cluster_net_parent_id(g_vpr_ctx.atom().lookup, net_id, is_flat);
827-
if(!route_ctx.route_trees[parent_id])
827+
if (!route_ctx.route_trees[parent_id])
828828
continue;
829-
for (auto& rt_node: route_ctx.route_trees[parent_id].value()) {
829+
for (auto& rt_node : route_ctx.route_trees[parent_id].value()) {
830830
t_rr_node_power* node_power = &rr_node_power[size_t(rt_node.inode)];
831831

832832
if (node_power->visited) {

vpr/src/route/annotate_routing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ vtr::vector<RRNodeId, ParentNetId> annotate_rr_node_nets(const Netlist<>& net_li
4242
continue;
4343
}
4444

45-
for (auto& rt_node: routing_ctx.route_trees[net_id].value()) {
45+
for (auto& rt_node : routing_ctx.route_trees[net_id].value()) {
4646
const RRNodeId rr_node = rt_node.inode;
4747
/* Ignore source and sink nodes, they are the common node multiple starting and ending points */
4848
if ((SOURCE != rr_graph.node_type(rr_node))

vpr/src/route/check_route.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void check_route(const Netlist<>& net_list,
109109

110110
std::fill_n(pin_done.get(), net_list.net_pins(net_id).size(), false);
111111

112-
if(!route_ctx.route_trees[net_id]){
112+
if (!route_ctx.route_trees[net_id]) {
113113
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
114114
"in check_route: net %d has no routing.\n", size_t(net_id));
115115
}
@@ -123,22 +123,22 @@ void check_route(const Netlist<>& net_list,
123123

124124
/* Check the rest of the net */
125125
size_t num_sinks = 0;
126-
for(auto& rt_node: route_ctx.route_trees[net_id].value()){
126+
for (auto& rt_node : route_ctx.route_trees[net_id].value()) {
127127
RRNodeId inode = rt_node.inode;
128128
int net_pin_index = rt_node.net_pin_index;
129129
check_node_and_range(inode, route_type, is_flat);
130130
check_switch(rt_node, num_switches);
131131

132-
if(rt_node.parent){
132+
if (rt_node.parent) {
133133
connects = check_adjacent(rt_node.parent->inode, rt_node.inode, is_flat);
134134
if (!connects) {
135135
VPR_ERROR(VPR_ERROR_ROUTE,
136-
"in check_route: found non-adjacent segments in traceback while checking net %d:\n"
137-
" %s\n"
138-
" %s\n",
139-
size_t(net_id),
140-
describe_rr_node(rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, size_t(rt_node.parent->inode), is_flat).c_str(),
141-
describe_rr_node(rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, size_t(inode), is_flat).c_str());
136+
"in check_route: found non-adjacent segments in traceback while checking net %d:\n"
137+
" %s\n"
138+
" %s\n",
139+
size_t(net_id),
140+
describe_rr_node(rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, size_t(rt_node.parent->inode), is_flat).c_str(),
141+
describe_rr_node(rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, size_t(inode), is_flat).c_str());
142142
}
143143
}
144144

@@ -481,13 +481,13 @@ void recompute_occupancy_from_scratch(const Netlist<>& net_list, bool is_flat) {
481481
/* Now go through each net and count the tracks and pins used everywhere */
482482

483483
for (auto net_id : net_list.nets()) {
484-
if(!route_ctx.route_trees[net_id])
484+
if (!route_ctx.route_trees[net_id])
485485
continue;
486486

487487
if (net_list.net_is_ignored(net_id)) /* Skip ignored nets. */
488488
continue;
489489

490-
for (auto &rt_node: route_ctx.route_trees[net_id].value()) {
490+
for (auto& rt_node : route_ctx.route_trees[net_id].value()) {
491491
size_t inode = size_t(rt_node.inode);
492492
route_ctx.rr_node_route_inf[inode].set_occ(route_ctx.rr_node_route_inf[inode].occ() + 1);
493493
}
@@ -603,13 +603,13 @@ static bool check_non_configurable_edges(const Netlist<>& net_list,
603603
const auto& device_ctx = g_vpr_ctx.device();
604604
auto& route_ctx = g_vpr_ctx.mutable_routing();
605605

606-
if(!route_ctx.route_trees[net]) // no routing
606+
if (!route_ctx.route_trees[net]) // no routing
607607
return true;
608608

609609
// Collect all the edges used by this net's routing
610610
std::set<t_node_edge> routing_edges;
611611
std::set<int> routing_nodes;
612-
for (auto& rt_node: route_ctx.route_trees[net].value()){
612+
for (auto& rt_node : route_ctx.route_trees[net].value()) {
613613
routing_nodes.insert(size_t(rt_node.inode));
614614
if (!rt_node.parent)
615615
continue;
@@ -810,7 +810,7 @@ bool StubFinder::CheckNet(ParentNetId net) {
810810
auto& route_ctx = g_vpr_ctx.mutable_routing();
811811
stub_nodes_.clear();
812812

813-
if(!route_ctx.route_trees[net])
813+
if (!route_ctx.route_trees[net])
814814
return false;
815815

816816
RecurseTree(route_ctx.route_trees[net].value().root);
@@ -833,7 +833,7 @@ bool StubFinder::RecurseTree(RouteTreeNode& rt_node) {
833833
}
834834

835835
bool is_stub = true;
836-
for(RouteTreeNode& child_node: rt_node.child_nodes()){
836+
for (RouteTreeNode& child_node : rt_node.child_nodes()) {
837837
bool driver_switch_configurable = rr_graph.rr_switch_inf(child_node.parent_switch).configurable();
838838
bool child_is_stub = RecurseTree(child_node);
839839
if (!child_is_stub) {

vpr/src/route/connection_router.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ std::vector<t_heap> ConnectionRouter<Heap>::timing_driven_find_all_shortest_path
314314
// Add the route tree to the heap with no specific target node
315315
int target_node = OPEN;
316316
add_route_tree_to_heap(rt_root, target_node, cost_params, false);
317-
heap_.build_heap(); // via sifting down everything
317+
heap_.build_heap(); // via sifting down everything
318318

319319
auto res = timing_driven_find_all_shortest_paths_from_heap(cost_params, bounding_box);
320320
heap_.empty_heap();
@@ -337,7 +337,7 @@ std::vector<t_heap> ConnectionRouter<Heap>::timing_driven_find_all_shortest_path
337337

338338
VTR_ASSERT_SAFE(heap_.is_valid());
339339

340-
if (heap_.is_empty_heap()) { // No source
340+
if (heap_.is_empty_heap()) { // No source
341341
VTR_LOGV_DEBUG(router_debug_, " Initial heap empty (no source)\n");
342342
}
343343

@@ -508,10 +508,10 @@ void ConnectionRouter<Heap>::timing_driven_expand_neighbour(t_heap* current,
508508
// BB-pruning
509509
// Disable BB-pruning if RCV is enabled, as this can make it harder for circuits with high negative hold slack to resolve this
510510
// TODO: Only disable pruning if the net has negative hold slack, maybe go off budgets
511-
if ((to_xhigh < bounding_box.xmin // Strictly left of BB left-edge
512-
|| to_xlow > bounding_box.xmax // Strictly right of BB right-edge
513-
|| to_yhigh < bounding_box.ymin // Strictly below BB bottom-edge
514-
|| to_ylow > bounding_box.ymax) // Strictly above BB top-edge
511+
if ((to_xhigh < bounding_box.xmin // Strictly left of BB left-edge
512+
|| to_xlow > bounding_box.xmax // Strictly right of BB right-edge
513+
|| to_yhigh < bounding_box.ymin // Strictly below BB bottom-edge
514+
|| to_ylow > bounding_box.ymax) // Strictly above BB top-edge
515515
&& !rcv_path_manager.is_enabled()) {
516516
VTR_LOGV_DEBUG(router_debug_,
517517
" Pruned expansion of node %d edge %zu -> %d"
@@ -901,8 +901,8 @@ void ConnectionRouter<Heap>::add_route_tree_to_heap(
901901
false);
902902
}
903903

904-
for(const RouteTreeNode& child_node: rt_node.child_nodes()){
905-
if (is_flat_) {
904+
for (const RouteTreeNode& child_node : rt_node.child_nodes()) {
905+
if (is_flat_) {
906906
if (relevant_node_to_target(rr_graph_,
907907
child_node.inode,
908908
RRNodeId(target_node))) {
@@ -1125,4 +1125,3 @@ std::unique_ptr<ConnectionRouterInterface> make_connection_router(e_heap_type he
11251125
heap_type);
11261126
}
11271127
}
1128-

vpr/src/route/overuse_report.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ void generate_overused_nodes_to_congested_net_lookup(const Netlist<>& net_list,
172172
//Create overused nodes to congested nets look up by
173173
//traversing through the net trace backs linked lists
174174
for (ParentNetId net_id : net_list.nets()) {
175-
if(!route_ctx.route_trees[net_id])
175+
if (!route_ctx.route_trees[net_id])
176176
continue;
177177

178-
for (auto& rt_node: route_ctx.route_trees[net_id].value()) {
178+
for (auto& rt_node : route_ctx.route_trees[net_id].value()) {
179179
RRNodeId inode = rt_node.inode;
180180
int overuse = route_ctx.rr_node_route_inf[size_t(inode)].occ() - rr_graph.node_capacity(inode);
181181
if (overuse > 0) {
@@ -192,10 +192,10 @@ static void generate_node_to_net_lookup(const Netlist<>& net_list,
192192
//Create overused nodes to congested nets look up by
193193
//traversing through the net trace backs linked lists
194194
for (ParentNetId net_id : net_list.nets()) {
195-
if(!route_ctx.route_trees[net_id])
195+
if (!route_ctx.route_trees[net_id])
196196
continue;
197197

198-
for (const RouteTreeNode& rt_node: route_ctx.route_trees[net_id].value()){
198+
for (const RouteTreeNode& rt_node : route_ctx.route_trees[net_id].value()) {
199199
rr_node_to_net_map[rt_node.inode].insert(net_id);
200200
}
201201
}

0 commit comments

Comments
 (0)