Skip to content

Commit ac4d870

Browse files
committed
2 parents 01d3b7d + afe5466 commit ac4d870

File tree

87 files changed

+217
-262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+217
-262
lines changed

README.developers.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,29 @@ For large scale reformatting (should only be performed by VTR maintainers) the s
179179

180180
Python files are automatically checked using `pylint` to ensure they follow established Python conventions. You can run `pylint` on the entire repository by running `./dev/pylint_check.py`. Certain files which were created before we adopted Python lint checking are grandfathered and are not checked. To check *all* files, provide the `--check_grandfathered` argument. You can also manually check individual files using `./dev/pylint_check.py <path_to_file1> <path_to_file2> ...`.
181181

182+
# Sanitizing Includes
183+
184+
You can use include-what-you-use or the clangd language server to make sure includes are correct and you don't have missing or unused includes.
185+
186+
## include-what-you-use
187+
188+
First, install include-what-you-use. Ubuntu/Debian users can run `sudo apt install iwyu` and Fedora/RHEL users can run `sudo dnf install iwyu`. You can then compile VTR with include-what-you-use enabled to get diagnostic messages about includes in all files with the following command:
189+
190+
```
191+
make CMAKE_PARAMS="-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use"
192+
```
193+
194+
Note that this method checks all source files and the diagnostic messages can be very long.
195+
196+
## clangd language server
197+
198+
Alternatively, if your editor supports clangd, you can use it to get diagnostic messages for the specific file you are working with. Visual Studio Code users can use the clangd extension to use clangd instead of Microsoft's C/C++ extension. To enable include diagnostics, create a file named `.clangd` in VTR root directory and add the following lines to it:
199+
```
200+
Diagnostics:
201+
UnusedIncludes: Strict
202+
MissingIncludes: Strict
203+
```
204+
182205
# Running Tests
183206

184207
VTR has a variety of tests which are used to check for correctness, performance and Quality of Result (QoR).

doc/src/vpr/command_line_usage.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ General Options
223223

224224
If this option is not specified it may be set from the ``VPR_NUM_WORKERS`` environment variable; otherwise the default is used.
225225

226+
If this option is set to something other than 1, the following algorithms can be run in parallel:
227+
228+
* Timing Analysis
229+
* Routing (If routing algorithm is set to parallel or parallel_decomp; See :option:`--router_algorithm`)
230+
* Portions of analytical placement (If using the analytical placement flow and compiled VPR with Eigen enabled; See :option:`--analytical_place`)
231+
226232
.. note:: To compile VPR to allow the usage of parallel workers, ``libtbb-dev`` must be installed in the system.
227233

228234
**Default:** ``1``

libs/libarchfpga/src/arch_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define TOKENS " \t\n"
1717

1818
/* Value for UNDEFINED data */
19-
constexpr int UNDEFINED = -1;
19+
constexpr int ARCH_FPGA_UNDEFINED_VAL = -1;
2020

2121
/* Maximum value for minimum channel width to avoid overflows of short data type. */
2222
constexpr int MAX_CHANNEL_WIDTH = 8000;

libs/libarchfpga/src/arch_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ t_physical_tile_type get_empty_physical_type(const char* name /*= EMPTY_BLOCK_NA
444444
type.capacity = 0;
445445
type.num_drivers = 0;
446446
type.num_receivers = 0;
447-
type.area = UNDEFINED;
447+
type.area = ARCH_FPGA_UNDEFINED_VAL;
448448
type.switchblock_locations = vtr::Matrix<e_sb_type>({{size_t(type.width), size_t(type.height)}}, e_sb_type::FULL);
449449
type.switchblock_switch_overrides = vtr::Matrix<int>({{size_t(type.width), size_t(type.height)}}, DEFAULT_SWITCH);
450450
type.is_input_type = false;

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,7 +3079,7 @@ static void ProcessChanWidthDistrDir(pugi::xml_node Node, t_chan* chan, const pu
30793079
"Unknown property %s for chan_width_distr x\n", Prop);
30803080
}
30813081

3082-
chan->peak = get_attribute(Node, "peak", loc_data).as_float(UNDEFINED);
3082+
chan->peak = get_attribute(Node, "peak", loc_data).as_float(ARCH_FPGA_UNDEFINED_VAL);
30833083
chan->width = get_attribute(Node, "width", loc_data, hasWidth).as_float(0);
30843084
chan->xpeak = get_attribute(Node, "xpeak", loc_data, hasXpeak).as_float(0);
30853085
chan->dc = get_attribute(Node, "dc", loc_data, hasDc).as_float(0);
@@ -3186,7 +3186,7 @@ static void ProcessTileProps(pugi::xml_node Node,
31863186
/* Load properties */
31873187
PhysicalTileType->width = get_attribute(Node, "width", loc_data, ReqOpt::OPTIONAL).as_uint(1);
31883188
PhysicalTileType->height = get_attribute(Node, "height", loc_data, ReqOpt::OPTIONAL).as_uint(1);
3189-
PhysicalTileType->area = get_attribute(Node, "area", loc_data, ReqOpt::OPTIONAL).as_float(UNDEFINED);
3189+
PhysicalTileType->area = get_attribute(Node, "area", loc_data, ReqOpt::OPTIONAL).as_float(ARCH_FPGA_UNDEFINED_VAL);
31903190

31913191
if (atof(Prop) < 0) {
31923192
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Node),
@@ -4556,8 +4556,8 @@ static std::vector<t_arch_switch_inf> ProcessSwitches(pugi::xml_node Parent,
45564556
static void ProcessSwitchTdel(pugi::xml_node Node, const bool timing_enabled, t_arch_switch_inf& arch_switch, const pugiutil::loc_data& loc_data) {
45574557
/* check if switch node has the Tdel property */
45584558
bool has_Tdel_prop = false;
4559-
float Tdel_prop_value = get_attribute(Node, "Tdel", loc_data, ReqOpt::OPTIONAL).as_float(UNDEFINED);
4560-
if (Tdel_prop_value != UNDEFINED) {
4559+
float Tdel_prop_value = get_attribute(Node, "Tdel", loc_data, ReqOpt::OPTIONAL).as_float(ARCH_FPGA_UNDEFINED_VAL);
4560+
if (Tdel_prop_value != ARCH_FPGA_UNDEFINED_VAL) {
45614561
has_Tdel_prop = true;
45624562
}
45634563

libs/librrgraph/src/base/rr_graph_builder.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,29 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) {
4444
short node_layer = node_storage_.node_layer(node);
4545
short node_twist = node_storage_.node_ptc_twist(node);
4646
int node_offset = 0;
47+
4748
for (int ix = node_storage_.node_xlow(node); ix <= node_storage_.node_xhigh(node); ix++) {
4849
for (int iy = node_storage_.node_ylow(node); iy <= node_storage_.node_yhigh(node); iy++) {
4950
node_ptc_num += node_twist * node_offset;
5051
node_offset++;
52+
5153
switch (node_type) {
5254
case e_rr_type::SOURCE:
5355
case e_rr_type::SINK:
5456
case e_rr_type::CHANY:
55-
node_lookup_.add_node(node, node_layer, ix, iy, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
56-
break;
5757
case e_rr_type::CHANX:
58-
/* Currently need to swap x and y for CHANX because of chan, seg convention
59-
* TODO: Once the builders is reworked for use consistent (x, y) convention,
60-
* the following swapping can be removed
61-
*/
62-
node_lookup_.add_node(node, node_layer, iy, ix, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
58+
node_lookup_.add_node(node, node_layer, ix, iy, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
6359
break;
60+
6461
case e_rr_type::OPIN:
6562
case e_rr_type::IPIN:
66-
for (const e_side& side : TOTAL_2D_SIDES) {
63+
for (const e_side side : TOTAL_2D_SIDES) {
6764
if (node_storage_.is_node_on_specific_side(node, side)) {
6865
node_lookup_.add_node(node,node_layer, ix, iy, node_type, node_ptc_num, side);
6966
}
7067
}
7168
break;
69+
7270
default:
7371
VTR_LOG_ERROR("Invalid node type for node '%lu' in the routing resource graph file", size_t(node));
7472
break;

libs/librrgraph/src/base/rr_graph_storage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ size_t t_rr_graph_storage::count_rr_switches(
467467

468468
if (arch_switch_inf[iswitch].fixed_Tdel()) {
469469
//If delay is independent of fanin drop the unique fanin info
470-
fanin = UNDEFINED;
470+
fanin = ARCH_FPGA_UNDEFINED_VAL;
471471
}
472472

473473
if (arch_switch_fanins[iswitch].count(fanin) == 0) { //New fanin for this switch
@@ -485,7 +485,7 @@ size_t t_rr_graph_storage::count_rr_switches(
485485
for(size_t iswitch = 0; iswitch < arch_switch_counts.size(); ++iswitch) {
486486
if(arch_switch_fanins[iswitch].empty()){
487487
if(arch_switch_inf[iswitch].fixed_Tdel()){
488-
arch_switch_fanins[iswitch][UNDEFINED] = num_rr_switches++;
488+
arch_switch_fanins[iswitch][ARCH_FPGA_UNDEFINED_VAL] = num_rr_switches++;
489489
}
490490
}
491491
}
@@ -507,8 +507,8 @@ void t_rr_graph_storage::remap_rr_node_switch_indices(const t_arch_switch_fanin&
507507
int switch_index = edge_switch_[edge];
508508
int fanin = node_fan_in_[to_node];
509509

510-
if (switch_fanin[switch_index].count(UNDEFINED) == 1) {
511-
fanin = UNDEFINED;
510+
if (switch_fanin[switch_index].count(ARCH_FPGA_UNDEFINED_VAL) == 1) {
511+
fanin = ARCH_FPGA_UNDEFINED_VAL;
512512
}
513513

514514
auto itr = switch_fanin[switch_index].find(fanin);

libs/librrgraph/src/base/rr_graph_view.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class RRGraphView {
363363

364364
start_x = " (" + std::to_string(node_xhigh(node)) + ","; //start coordinates have large value
365365
start_y = std::to_string(node_yhigh(node)) + ",";
366-
start_layer_str = std::to_string(node_layer_num);
366+
start_layer_str = std::to_string(node_layer_num) + ")";
367367
end_x = " (" + std::to_string(node_xlow(node)) + ","; //end coordinates have smaller value
368368
end_y = std::to_string(node_ylow(node)) + ",";
369369
end_layer_str = std::to_string(node_layer_num) + ")";
@@ -372,7 +372,7 @@ class RRGraphView {
372372
else { // signal travels in increasing direction, stays at same point, or can travel both directions
373373
start_x = " (" + std::to_string(node_xlow(node)) + ","; //start coordinates have smaller value
374374
start_y = std::to_string(node_ylow(node)) + ",";
375-
start_layer_str = std::to_string(node_layer_num);
375+
start_layer_str = std::to_string(node_layer_num) + ")";
376376
end_x = " (" + std::to_string(node_xhigh(node)) + ","; //end coordinates have larger value
377377
end_y = std::to_string(node_yhigh(node)) + ",";
378378
end_layer_str = std::to_string(node_layer_num) + ")"; //layer number

libs/librrgraph/src/base/rr_spatial_lookup.cpp

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
#include "vtr_log.h"
33
#include "rr_spatial_lookup.h"
44

5-
RRSpatialLookup::RRSpatialLookup() {
6-
}
7-
85
RRNodeId RRSpatialLookup::find_node(int layer,
96
int x,
107
int y,
@@ -34,18 +31,6 @@ RRNodeId RRSpatialLookup::find_node(int layer,
3431
return RRNodeId::INVALID();
3532
}
3633

37-
/* Currently need to swap x and y for CHANX because of chan, seg convention
38-
* This is due to that the fast look-up builders uses (y, x) coordinate when
39-
* registering a CHANX node in the look-up
40-
* TODO: Once the builders is reworked for use consistent (x, y) convention,
41-
* the following swapping can be removed
42-
*/
43-
size_t node_x = x;
44-
size_t node_y = y;
45-
if (type == e_rr_type::CHANX) {
46-
std::swap(node_x, node_y);
47-
}
48-
4934
VTR_ASSERT_SAFE(4 == rr_node_indices_[type].ndims());
5035

5136
/* Sanity check to ensure the layer, x, y, side and ptc are in range
@@ -60,23 +45,23 @@ RRNodeId RRSpatialLookup::find_node(int layer,
6045
return RRNodeId::INVALID();
6146
}
6247

63-
if (node_x >= rr_node_indices_[type].dim_size(1)) {
48+
if (size_t(x) >= rr_node_indices_[type].dim_size(1)) {
6449
return RRNodeId::INVALID();
6550
}
6651

67-
if(node_y >= rr_node_indices_[type].dim_size(2)){
52+
if (size_t(y) >= rr_node_indices_[type].dim_size(2)){
6853
return RRNodeId::INVALID();
6954
}
7055

7156
if (node_side >= rr_node_indices_[type].dim_size(3)) {
7257
return RRNodeId::INVALID();
7358
}
7459

75-
if (size_t(ptc) >= rr_node_indices_[type][layer][node_x][node_y][node_side].size()) {
60+
if (size_t(ptc) >= rr_node_indices_[type][layer][x][y][node_side].size()) {
7661
return RRNodeId::INVALID();
7762
}
7863

79-
return rr_node_indices_[type][layer][node_x][node_y][node_side][ptc];
64+
return rr_node_indices_[type][layer][x][y][node_side][ptc];
8065
}
8166

8267
std::vector<RRNodeId> RRSpatialLookup::find_nodes_in_range(int layer,
@@ -115,18 +100,6 @@ std::vector<RRNodeId> RRSpatialLookup::find_nodes(int layer,
115100
return nodes;
116101
}
117102

118-
/* Currently need to swap x and y for CHANX because of chan, seg convention
119-
* This is due to that the fast look-up builders uses (y, x) coordinate when
120-
* registering a CHANX node in the look-up
121-
* TODO: Once the builders is reworked for use consistent (x, y) convention,
122-
* the following swapping can be removed
123-
*/
124-
size_t node_x = x;
125-
size_t node_y = y;
126-
if (type == e_rr_type::CHANX) {
127-
std::swap(node_x, node_y);
128-
}
129-
130103
VTR_ASSERT_SAFE(4 == rr_node_indices_[type].ndims());
131104

132105
/* Sanity check to ensure the x, y, side are in range
@@ -141,11 +114,11 @@ std::vector<RRNodeId> RRSpatialLookup::find_nodes(int layer,
141114
return nodes;
142115
}
143116

144-
if (node_x >= rr_node_indices_[type].dim_size(1)) {
117+
if (size_t(x) >= rr_node_indices_[type].dim_size(1)) {
145118
return nodes;
146119
}
147120

148-
if(node_y >= rr_node_indices_[type].dim_size(2)){
121+
if (size_t(y) >= rr_node_indices_[type].dim_size(2)){
149122
return nodes;
150123
}
151124

@@ -155,14 +128,14 @@ std::vector<RRNodeId> RRSpatialLookup::find_nodes(int layer,
155128

156129
/* Reserve space to avoid memory fragmentation */
157130
size_t num_nodes = 0;
158-
for (const auto& node : rr_node_indices_[type][layer][node_x][node_y][side]) {
131+
for (RRNodeId node : rr_node_indices_[type][layer][x][y][side]) {
159132
if (node.is_valid()) {
160133
num_nodes++;
161134
}
162135
}
163136

164137
nodes.reserve(num_nodes);
165-
for (const auto& node : rr_node_indices_[type][layer][node_x][node_y][side]) {
138+
for (RRNodeId node : rr_node_indices_[type][layer][x][y][side]) {
166139
if (node.is_valid()) {
167140
nodes.emplace_back(node);
168141
}
@@ -339,7 +312,7 @@ void RRSpatialLookup::resize_nodes(int layer,
339312
|| (x >= int(rr_node_indices_[type].dim_size(1)))
340313
|| (y >= int(rr_node_indices_[type].dim_size(2)))
341314
|| (size_t(side) >= rr_node_indices_[type].dim_size(3))) {
342-
rr_node_indices_[type].resize({std::max(rr_node_indices_[type].dim_size(0),size_t(layer)+1),
315+
rr_node_indices_[type].resize({std::max(rr_node_indices_[type].dim_size(0), size_t(layer)+1),
343316
std::max(rr_node_indices_[type].dim_size(1), size_t(x) + 1),
344317
std::max(rr_node_indices_[type].dim_size(2), size_t(y) + 1),
345318
std::max(rr_node_indices_[type].dim_size(3), size_t(side) + 1)});
@@ -353,7 +326,7 @@ void RRSpatialLookup::reorder(const vtr::vector<RRNodeId, RRNodeId>& dest_order)
353326
for (size_t x = 0; x < grid.dim_size(1); x++) {
354327
for (size_t y = 0; y < grid.dim_size(2); y++) {
355328
for (size_t s = 0; s < grid.dim_size(3); s++) {
356-
for (auto &node: grid[l][x][y][s]) {
329+
for (RRNodeId &node: grid[l][x][y][s]) {
357330
if (node.is_valid()) {
358331
node = dest_order[node];
359332
}

libs/librrgraph/src/base/rr_spatial_lookup.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef RR_SPATIAL_LOOKUP_H
2-
#define RR_SPATIAL_LOOKUP_H
1+
#pragma once
32

43
/**
54
* @file
@@ -25,7 +24,7 @@ class RRSpatialLookup {
2524
/* -- Constructors -- */
2625
public:
2726
/* Explicitly define the only way to create an object */
28-
explicit RRSpatialLookup();
27+
explicit RRSpatialLookup() = default;
2928

3029
/* Disable copy constructors and copy assignment operator
3130
* This is to avoid accidental copy because it could be an expensive operation considering that the
@@ -293,5 +292,3 @@ class RRSpatialLookup {
293292
/* Fast look-up: TODO: Should rework the data type. Currently it is based on a 3-dimensional array mater where some dimensions must always be accessed with a specific index. Such limitation should be overcome */
294293
t_rr_node_indices rr_node_indices_;
295294
};
296-
297-
#endif

libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,19 +1857,14 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
18571857

18581858
/* Alloc the lookup table */
18591859
for (e_rr_type rr_type : RR_TYPES) {
1860-
if (rr_type == e_rr_type::CHANX) {
1861-
rr_graph_builder.node_lookup().resize_nodes(grid_.get_num_layers(), grid_.height(), grid_.width(), rr_type, NUM_2D_SIDES);
1862-
} else {
1863-
rr_graph_builder.node_lookup().resize_nodes(grid_.get_num_layers(), grid_.width(), grid_.height(), rr_type, NUM_2D_SIDES);
1864-
}
1860+
rr_graph_builder.node_lookup().resize_nodes(grid_.get_num_layers(), grid_.width(), grid_.height(), rr_type, NUM_2D_SIDES);
18651861
}
18661862

18671863
/* Add the correct node into the vector */
1868-
for (size_t inode = 0; inode < rr_nodes_->size(); inode++) {
1869-
auto node = (*rr_nodes_)[inode];
1864+
for (const t_rr_node& node : *rr_nodes_) {
18701865
/* Set track numbers as a node may have multiple ptc */
18711866
if (rr_graph_builder.node_contain_multiple_ptc(node.id())) {
1872-
if (CHANX == rr_graph_->node_type(node.id()) || CHANY == rr_graph_->node_type(node.id())) {
1867+
if (rr_graph_->node_type(node.id()) == e_rr_type::CHANX || rr_graph_->node_type(node.id()) == e_rr_type::CHANY) {
18731868
rr_graph_builder.add_track_node_to_lookup(node.id());
18741869
}
18751870
} else {

0 commit comments

Comments
 (0)