Skip to content

Commit a20bf07

Browse files
authored
Merge branch 'master' into minus_operator
2 parents 83208e1 + 283e6a6 commit a20bf07

33 files changed

+502
-18135
lines changed

ODIN_II/regression_test/benchmark/suite/light_suite/task_list.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ regression_test/benchmark/task/syntax
99
regression_test/benchmark/task/FIR
1010
regression_test/benchmark/task/micro
1111
regression_test/benchmark/suite/complex_synthesis_suite
12+
regression_test/benchmark/suite/vtr_multiclock_suite
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vtr::vtr_reg_multiclock

ODIN_II/verify_odin.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ FILTERED_VTR_TASK_PATH="${NEW_RUN_DIR}/vtr/task_list.txt"
12551255
function run_vtr_reg() {
12561256
pushd "${VTR_DIR}" &> /dev/null
12571257
RELATIVE_PATH_TO_TEST=$(realapath_from "${FILTERED_VTR_TASK_PATH}" "${VTR_REG_DIR}")
1258-
/usr/bin/env perl run_reg_test.py -j "${_NUMBER_OF_PROCESS}" "${RELATIVE_PATH_TO_TEST}"
1258+
/usr/bin/env perl run_reg_test.py -j "${_NUMBER_OF_PROCESS}" $(dirname ${RELATIVE_PATH_TO_TEST})
12591259
popd &> /dev/null
12601260
}
12611261

@@ -1277,7 +1277,7 @@ function filter_vtr_test() {
12771277
pushd "${VTR_REG_DIR}" &> /dev/null
12781278
for test in $(cat "${VTR_TASK_PATH}")
12791279
do
1280-
if grep -E "circuit_list_add=.*\.v" "${test/regression_tests\//}/config/config.txt" &> "/dev/null"
1280+
if grep -E "circuit_list_add=.*\.v" "${VTR_REG_DIR/regression_tests}${test}/config/config.txt" &> "/dev/null"
12811281
then
12821282
echo $test >> "${FILTERED_VTR_TASK_PATH}";
12831283
fi

vpr/src/base/vpr_context.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#include "vtr_vector.h"
1010
#include "atom_netlist.h"
1111
#include "clustered_netlist.h"
12+
#include "rr_graph_view.h"
1213
#include "rr_graph_storage.h"
14+
#include "rr_graph_builder.h"
1315
#include "rr_node.h"
1416
#include "rr_rc_data.h"
1517
#include "tatum/TimingGraph.hpp"
@@ -145,7 +147,6 @@ struct DeviceContext : public Context {
145147
/*
146148
* Structures to define the routing architecture of the FPGA.
147149
*/
148-
149150
t_rr_graph_storage rr_nodes; // autogenerated in build_rr_graph
150151

151152
std::vector<t_rr_indexed_data> rr_indexed_data; // [0 .. num_rr_indexed_data-1]
@@ -162,6 +163,24 @@ struct DeviceContext : public Context {
162163
///@brief The indicies of rr nodes of a given type at a specific x,y grid location
163164
t_rr_node_indices rr_node_indices; // [0..NUM_RR_TYPES-1][0..grid.width()-1][0..grid.width()-1][0..size-1]
164165

166+
/* TODO: remove this interface from device_context once the code refactoring is completed
167+
* because it should be part of the rr_graph view
168+
* TODO: Currently, we use reference pointers to ensure that the rr_spatial_lookup is always
169+
* synchronized with the rr_node_indices but this causes a lot of confusion for developers
170+
* The temporary fix should be patched as soon as possible.
171+
*/
172+
RRSpatialLookup rr_spatial_lookup{rr_node_indices};
173+
174+
/* A read-only view of routing resource graph to be the ONLY database
175+
* for client functions: GUI, placer, router, timing analyzer etc.
176+
*/
177+
RRGraphView rr_graph{rr_nodes, rr_spatial_lookup};
178+
179+
/* A writeable view of routing resource graph to be the ONLY database
180+
* for routing resource graph builder functions.
181+
*/
182+
RRGraphBuilder rr_graph_builder{&rr_nodes, &rr_spatial_lookup};
183+
165184
///@brief Autogenerated in build_rr_graph based on switch fan-in. [0..(num_rr_switches-1)]
166185
std::vector<t_rr_switch_inf> rr_switch_inf;
167186

vpr/src/device/rr_graph_builder.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "rr_graph_builder.h"
2+
3+
RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage,
4+
RRSpatialLookup* node_lookup)
5+
: node_storage_(*node_storage)
6+
, node_lookup_(*node_lookup) {
7+
}
8+
9+
t_rr_graph_storage& RRGraphBuilder::node_storage() {
10+
return node_storage_;
11+
}
12+
13+
RRSpatialLookup& RRGraphBuilder::node_lookup() {
14+
return node_lookup_;
15+
}

vpr/src/device/rr_graph_builder.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#ifndef RR_GRAPH_BUILDER_H
2+
#define RR_GRAPH_BUILDER_H
3+
4+
#include "rr_graph_storage.h"
5+
#include "rr_spatial_lookup.h"
6+
7+
/* A data structure allows data modification on a routing resource graph
8+
*
9+
* Note that the builder does not own the storage
10+
* It serves a virtual protocol for
11+
* - node_storage: store the node list
12+
* - node_lookup: store a fast look-up for the nodes
13+
*
14+
* Note:
15+
* - This is the only data structre allowed to modify a routing resource graph
16+
*
17+
*/
18+
class RRGraphBuilder {
19+
/* -- Constructors -- */
20+
public:
21+
/* See detailed comments about the data structures in the internal data storage section of this file */
22+
RRGraphBuilder(t_rr_graph_storage* node_storage,
23+
RRSpatialLookup* node_lookup);
24+
25+
/* Disable copy constructors and copy assignment operator
26+
* This is to avoid accidental copy because it could be an expensive operation considering that the
27+
* memory footprint of the data structure could ~ Gb
28+
* Using the following syntax, we prohibit accidental 'pass-by-value' which can be immediately caught
29+
* by compiler
30+
*/
31+
RRGraphBuilder(const RRGraphBuilder&) = delete;
32+
void operator=(const RRGraphBuilder&) = delete;
33+
34+
/* -- Mutators -- */
35+
public:
36+
/* Return a writable object for rr_nodes */
37+
t_rr_graph_storage& node_storage();
38+
/* Return a writable object for update the fast look-up of rr_node */
39+
RRSpatialLookup& node_lookup();
40+
41+
/* -- Internal data storage -- */
42+
private:
43+
/* TODO: When the refactoring effort finishes,
44+
* the builder data structure will be the owner of the data storages.
45+
* That is why the reference to storage/lookup is used here.
46+
* It can avoid a lot of code changes once the refactoring is finished
47+
* (there is no function get data directly through the node_storage in DeviceContext).
48+
* If pointers are used, it may cause many codes in client functions
49+
* or inside the data structures to be changed later.
50+
* That explains why the reference is used here temporarily
51+
*/
52+
/* node-level storage including edge storages */
53+
t_rr_graph_storage& node_storage_;
54+
/* Fast look-up for rr nodes */
55+
RRSpatialLookup& node_lookup_;
56+
};
57+
58+
#endif

vpr/src/device/rr_graph_view.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "rr_graph_view.h"
2+
3+
RRGraphView::RRGraphView(const t_rr_graph_storage& node_storage,
4+
const RRSpatialLookup& node_lookup)
5+
: node_storage_(node_storage)
6+
, node_lookup_(node_lookup) {
7+
}
8+
9+
t_rr_type RRGraphView::node_type(RRNodeId node) const {
10+
return node_storage_.node_type(node);
11+
}
12+
13+
const RRSpatialLookup& RRGraphView::node_lookup() const {
14+
return node_lookup_;
15+
}

vpr/src/device/rr_graph_view.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#ifndef RR_GRAPH_VIEW_H
2+
#define RR_GRAPH_VIEW_H
3+
4+
#include "rr_graph_storage.h"
5+
#include "rr_spatial_lookup.h"
6+
7+
/* An read-only routing resource graph
8+
* which is an unified object including pointors to
9+
* - node storage
10+
* - TODO: edge_storage
11+
* - TODO: node_ptc_storage
12+
* - TODO: node_fan_in_storage
13+
* - rr_node_indices
14+
*
15+
* Note that the RRGraphView does not own the storage
16+
* It serves a virtual read-only protocol for
17+
* - placer
18+
* - router
19+
* - timing analyzer
20+
* - GUI
21+
*
22+
* Note that each client of rr_graph may get a frame view of the object
23+
* The RRGraphView is the complete frame view of the routing resource graph
24+
* - This helps to reduce the memory footprint for each client
25+
* - This avoids massive changes for each client on using the APIs
26+
* as each frame view provides adhoc APIs for each client
27+
*
28+
* TODO: more compact frame views will be created, e.g.,
29+
* - a mini frame view: contains only node and edges, representing the connectivity of the graph
30+
* - a geometry frame view: an extended mini frame view with node-level attributes,
31+
* in particular geometry information (type, x, y etc).
32+
*
33+
*/
34+
class RRGraphView {
35+
/* -- Constructors -- */
36+
public:
37+
/* See detailed comments about the data structures in the internal data storage section of this file */
38+
RRGraphView(const t_rr_graph_storage& node_storage,
39+
const RRSpatialLookup& node_lookup);
40+
41+
/* Disable copy constructors and copy assignment operator
42+
* This is to avoid accidental copy because it could be an expensive operation considering that the
43+
* memory footprint of the data structure could ~ Gb
44+
* Using the following syntax, we prohibit accidental 'pass-by-value' which can be immediately caught
45+
* by compiler
46+
*/
47+
RRGraphView(const RRGraphView&) = delete;
48+
void operator=(const RRGraphView&) = delete;
49+
50+
/* -- Accessors -- */
51+
/* TODO: The accessors may be turned into private later if they are replacable by 'questionin'
52+
* kind of accessors
53+
*/
54+
public:
55+
/* Get the type of a routing resource node */
56+
t_rr_type node_type(RRNodeId node) const;
57+
58+
/* Return the fast look-up data structure for queries from client functions */
59+
const RRSpatialLookup& node_lookup() const;
60+
61+
/* -- Internal data storage -- */
62+
/* Note: only read-only object or data structures are allowed!!! */
63+
private:
64+
/* node-level storage including edge storages */
65+
const t_rr_graph_storage& node_storage_;
66+
/* Fast look-up for rr nodes */
67+
const RRSpatialLookup& node_lookup_;
68+
};
69+
70+
#endif

vpr/src/device/rr_spatial_lookup.cpp

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#include "vtr_assert.h"
2+
#include "rr_spatial_lookup.h"
3+
4+
RRSpatialLookup::RRSpatialLookup(t_rr_node_indices& rr_node_indices)
5+
: rr_node_indices_(rr_node_indices) {
6+
}
7+
8+
RRNodeId RRSpatialLookup::find_node(int x,
9+
int y,
10+
t_rr_type type,
11+
int ptc,
12+
e_side side) const {
13+
/* Find actual side to be used
14+
* - For the node which are input/outputs of a grid, there must be a specific side for them.
15+
* Because they should have a specific pin location on the perimeter of a grid.
16+
* - For other types of nodes, there is no need to define a side. However, a default value
17+
* is needed when store the node in the fast look-up data structure.
18+
* Here we just arbitrary use the first side of the SIDE vector as the default value.
19+
* We may consider to use NUM_SIDES as the default value but it will cause an increase
20+
* in the dimension of the fast look-up data structure.
21+
* Please note that in the add_node function, we should keep the SAME convention!
22+
*/
23+
e_side node_side = side;
24+
if (type == IPIN || type == OPIN) {
25+
VTR_ASSERT_MSG(side != NUM_SIDES, "IPIN/OPIN must specify desired side (can not be default NUM_SIDES)");
26+
} else {
27+
VTR_ASSERT_SAFE(type != IPIN && type != OPIN);
28+
node_side = SIDES[0];
29+
}
30+
31+
/* Pre-check: the x, y, side and ptc should be non negative numbers! Otherwise, return an invalid id */
32+
if ((0 > x) || (0 > y) || (NUM_SIDES == node_side) || (0 > ptc)) {
33+
return RRNodeId::INVALID();
34+
}
35+
36+
/* Currently need to swap x and y for CHANX because of chan, seg convention
37+
* This is due to that the fast look-up builders uses (y, x) coordinate when
38+
* registering a CHANX node in the look-up
39+
* TODO: Once the builders is reworked for use consistent (x, y) convention,
40+
* the following swapping can be removed
41+
*/
42+
size_t node_x = x;
43+
size_t node_y = y;
44+
if (CHANX == type) {
45+
std::swap(node_x, node_y);
46+
}
47+
48+
VTR_ASSERT_SAFE(3 == rr_node_indices_[type].ndims());
49+
50+
/* Sanity check to ensure the x, y, side and ptc are in range
51+
* - Return an valid id by searching in look-up when all the parameters are in range
52+
* - Return an invalid id if any out-of-range is detected
53+
*/
54+
if (size_t(type) >= rr_node_indices_.size()) {
55+
return RRNodeId::INVALID();
56+
}
57+
58+
if (node_x >= rr_node_indices_[type].dim_size(0)) {
59+
return RRNodeId::INVALID();
60+
}
61+
62+
if (node_y >= rr_node_indices_[type].dim_size(1)) {
63+
return RRNodeId::INVALID();
64+
}
65+
66+
if (node_side >= rr_node_indices_[type].dim_size(2)) {
67+
return RRNodeId::INVALID();
68+
}
69+
70+
if (size_t(ptc) >= rr_node_indices_[type][node_x][node_y][node_side].size()) {
71+
return RRNodeId::INVALID();
72+
}
73+
74+
return RRNodeId(rr_node_indices_[type][node_x][node_y][node_side][ptc]);
75+
}
76+
77+
void RRSpatialLookup::add_node(RRNodeId node,
78+
int x,
79+
int y,
80+
t_rr_type type,
81+
int ptc,
82+
e_side side) {
83+
VTR_ASSERT_SAFE(3 == rr_node_indices_[type].ndims());
84+
85+
/* Expand the fast look-up if the new node is out-of-range
86+
* This may seldom happen because the rr_graph building function
87+
* should ensure the fast look-up well organized
88+
*/
89+
VTR_ASSERT(type < rr_node_indices_.size());
90+
VTR_ASSERT(0 <= x);
91+
VTR_ASSERT(0 <= y);
92+
93+
if ((x >= int(rr_node_indices_[type].dim_size(0)))
94+
|| (y >= int(rr_node_indices_[type].dim_size(1)))
95+
|| (size_t(side) >= rr_node_indices_[type].dim_size(2))) {
96+
rr_node_indices_[type].resize({std::max(rr_node_indices_[type].dim_size(0), size_t(x) + 1),
97+
std::max(rr_node_indices_[type].dim_size(1), size_t(y) + 1),
98+
std::max(rr_node_indices_[type].dim_size(2), size_t(side) + 1)});
99+
}
100+
101+
if (size_t(ptc) >= rr_node_indices_[type][x][y][side].size()) {
102+
rr_node_indices_[type][x][y][side].resize(ptc + 1);
103+
}
104+
105+
/* Resize on demand finished; Register the node */
106+
rr_node_indices_[type][x][y][side][ptc] = int(size_t(node));
107+
}

0 commit comments

Comments
 (0)