Skip to content

Commit 6b1a381

Browse files
committed
resolved conflicts with place_3d branch
2 parents c4d00cc + 83dc3c4 commit 6b1a381

File tree

128 files changed

+4235
-2825
lines changed

Some content is hidden

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

128 files changed

+4235
-2825
lines changed

doc/src/vpr/command_line_usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ The following options are only valid when the router is in timing-driven mode (t
13411341
* ``classic``: The classic VPR lookahead
13421342
* ``map``: A more advanced lookahead which accounts for diverse wire types and their connectivity
13431343

1344-
**Default:** ``classic``
1344+
**Default:** ``map``
13451345

13461346
.. option:: --router_max_convergence_count <float>
13471347

libs/libarchfpga/src/device_grid.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class DeviceGrid {
5050
* @brief Return the number of instances of the specified tile type on the specified layer. If the layer_num is -1, return the total number of instances of the specified tile type on all layers.
5151
* @note This function should be used if count_instances() is called in the constructor.
5252
*/
53-
size_t num_instances(t_physical_tile_type_ptr type, int layer_num = 0) const;
53+
size_t num_instances(t_physical_tile_type_ptr type, int layer_num) const;
5454

5555
/**
5656
* @brief Returns the block types which limits the device size (may be empty if
@@ -59,23 +59,23 @@ class DeviceGrid {
5959
std::vector<t_logical_block_type_ptr> limiting_resources() const { return limiting_resources_; }
6060

6161
///@brief Return the t_physical_tile_type_ptr at the specified location
62-
inline t_physical_tile_type_ptr get_physical_type(size_t x, size_t y, int layer_num = 0) const {
63-
return grid_[layer_num][x][y].type;
62+
inline t_physical_tile_type_ptr get_physical_type(const t_physical_tile_loc& tile_loc) const {
63+
return grid_[tile_loc.layer_num][tile_loc.x][tile_loc.y].type;
6464
}
6565

6666
///@brief Return the width offset of the tile at the specified location. The root location of the tile is where width_offset and height_offset are 0.
67-
inline int get_width_offset(size_t x, size_t y, int layer_num = 0) const {
68-
return grid_[layer_num][x][y].width_offset;
67+
inline int get_width_offset(const t_physical_tile_loc& tile_loc) const {
68+
return grid_[tile_loc.layer_num][tile_loc.x][tile_loc.y].width_offset;
6969
}
7070

7171
///@brief Return the height offset of the tile at the specified location. The root location of the tile is where width_offset and height_offset are 0
72-
inline int get_height_offset(size_t x, size_t y, int layer_num = 0) const {
73-
return grid_[layer_num][x][y].height_offset;
72+
inline int get_height_offset(const t_physical_tile_loc& tile_loc) const {
73+
return grid_[tile_loc.layer_num][tile_loc.x][tile_loc.y].height_offset;
7474
}
7575

7676
///@brief Return the metadata of the tile at the specified location
77-
inline const t_metadata_dict* get_metadata(size_t x, size_t y, int layer_num = 0) const {
78-
return grid_[layer_num][x][y].meta;
77+
inline const t_metadata_dict* get_metadata(const t_physical_tile_loc& tile_loc) const {
78+
return grid_[tile_loc.layer_num][tile_loc.x][tile_loc.y].meta;
7979
}
8080

8181
///@brief Given t_grid_tile, return the x coordinate of the tile on the given layer - Used by serializer functions
@@ -94,6 +94,12 @@ class DeviceGrid {
9494
return diff % grid_.dim_size(2);
9595
}
9696

97+
///@brief Given t_grid_tile, return the layer number of the tile - Used by serializer functions
98+
inline int get_grid_loc_layer(const t_grid_tile*& grid_loc) const {
99+
int layer_num = std::floor(static_cast<int>(grid_loc - &grid_.get(0)) / (width() * height()));
100+
return layer_num;
101+
}
102+
97103
///@brief Return the nth t_grid_tile on the given layer of the flattened grid - Used by serializer functions
98104
inline const t_grid_tile* get_grid_locs_grid_loc(int n) const {
99105
return &grid_.get(n);

libs/libarchfpga/src/physical_types.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,31 @@ struct t_physical_pin {
814814
}
815815
};
816816

817+
/**
818+
* @brief Describes The location of a physical tile
819+
* @param layer_num The die number of the physical tile. If the FPGA only has one die, or the physical tile is located
820+
* on the base die, layer_num is equal to zero. If it is one the die above base die, it is one, etc.
821+
* @param x The x location of the physical tile on the given die
822+
* @param y The y location of the physical tile on the given die
823+
*/
824+
struct t_physical_tile_loc {
825+
int x = OPEN;
826+
int y = OPEN;
827+
int layer_num = OPEN;
828+
829+
t_physical_tile_loc() = default;
830+
831+
t_physical_tile_loc(int x_val, int y_val, int layer_num_val)
832+
: x(x_val)
833+
, y(y_val)
834+
, layer_num(layer_num_val) {}
835+
836+
// Returns true if this type location layer_num/x/y is not equal to OPEN
837+
operator bool() const {
838+
return !(x == OPEN || y == OPEN || layer_num == OPEN);
839+
}
840+
};
841+
817842
/** Describes I/O and clock ports of a physical tile type
818843
*
819844
* It corresponds to <port/> tags in the FPGA architecture description

libs/librrgraph/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ add_custom_target(
4848
COMMAND ${CMAKE_COMMAND} -E make_directory rr_graph_generate
4949
COMMAND ${CMAKE_COMMAND} -E chdir rr_graph_generate git clone https://github.com/duck2/uxsdcxx
5050
COMMAND python3 -mpip install --user -r rr_graph_generate/uxsdcxx/requirements.txt
51-
COMMAND ${CMAKE_COMMAND} -E chdir rr_graph_generate python3 uxsdcxx/uxsdcxx.py ${CMAKE_CURRENT_SOURCE_DIR}/src/base/rr_graph.xsd
52-
COMMAND ${CMAKE_COMMAND} -E chdir rr_graph_generate python3 uxsdcxx/uxsdcap.py ${CMAKE_CURRENT_SOURCE_DIR}/src/base/rr_graph.xsd
51+
COMMAND ${CMAKE_COMMAND} -E chdir rr_graph_generate python3 uxsdcxx/uxsdcxx.py ${CMAKE_CURRENT_SOURCE_DIR}/src/io/rr_graph.xsd
52+
COMMAND ${CMAKE_COMMAND} -E chdir rr_graph_generate python3 uxsdcxx/uxsdcap.py ${CMAKE_CURRENT_SOURCE_DIR}/src/io/rr_graph.xsd
5353
COMMAND ${CMAKE_COMMAND} -E copy
5454
rr_graph_generate/rr_graph_uxsdcxx.h
5555
rr_graph_generate/rr_graph_uxsdcxx_capnp.h
5656
rr_graph_generate/rr_graph_uxsdcxx_interface.h
57-
${CMAKE_CURRENT_SOURCE_DIR}/src/base/gen
57+
${CMAKE_CURRENT_SOURCE_DIR}/src/io/gen
5858
COMMAND ${CMAKE_COMMAND} -E copy rr_graph_generate/rr_graph_uxsdcxx.capnp ${CMAKE_CURRENT_SOURCE_DIR}/../libvtrcapnproto/gen
59-
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/base/rr_graph.xsd
59+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/io/rr_graph.xsd
6060
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
6161
)

libs/librrgraph/src/base/check_rr_graph.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ void check_rr_graph(const RRGraphView& rr_graph,
234234
size_t inode = (size_t)rr_node;
235235
t_rr_type rr_type = rr_graph.node_type(rr_node);
236236
int ptc_num = rr_graph.node_ptc_num(rr_node);
237+
int layer_num = rr_graph.node_layer(rr_node);
237238
int xlow = rr_graph.node_xlow(rr_node);
238239
int ylow = rr_graph.node_ylow(rr_node);
239-
t_physical_tile_type_ptr type = grid.get_physical_type(xlow, ylow);
240+
241+
t_physical_tile_type_ptr type = grid.get_physical_type({xlow, ylow, layer_num});
240242

241243
if (rr_type == IPIN || rr_type == OPIN) {
242244
// #TODO: No edges are added for internal pins. However, they need to be checked somehow!
@@ -273,7 +275,9 @@ void check_rr_graph(const RRGraphView& rr_graph,
273275
if (!is_chain && !is_fringe && !is_wire) {
274276
if (rr_graph.node_type(rr_node) == IPIN || rr_graph.node_type(rr_node) == OPIN) {
275277
if (has_adjacent_channel(rr_graph, grid, node)) {
276-
auto block_type = grid.get_physical_type(rr_graph.node_xlow(rr_node), rr_graph.node_ylow(rr_node));
278+
auto block_type = grid.get_physical_type({rr_graph.node_xlow(rr_node),
279+
rr_graph.node_ylow(rr_node),
280+
rr_graph.node_layer(rr_node)});
277281
std::string pin_name = block_type_pin_index_to_name(block_type, rr_graph.node_pin_num(rr_node), is_flat);
278282
/* Print error messages for all the sides that a node may appear */
279283
for (const e_side& node_side : SIDES) {
@@ -312,7 +316,9 @@ static bool rr_node_is_global_clb_ipin(const RRGraphView& rr_graph, const Device
312316
int ipin;
313317
t_physical_tile_type_ptr type;
314318

315-
type = grid.get_physical_type(rr_graph.node_xlow(inode), rr_graph.node_ylow(inode));
319+
type = grid.get_physical_type({rr_graph.node_xlow(inode),
320+
rr_graph.node_ylow(inode),
321+
rr_graph.node_layer(inode)});
316322

317323
if (rr_graph.node_type(inode) != IPIN)
318324
return (false);
@@ -335,7 +341,7 @@ void check_rr_node(const RRGraphView& rr_graph,
335341

336342
//Make sure over-flow doesn't happen
337343
VTR_ASSERT(inode >= 0);
338-
int xlow, ylow, xhigh, yhigh, ptc_num, capacity;
344+
int xlow, ylow, xhigh, yhigh, layer_num, ptc_num, capacity;
339345
t_rr_type rr_type;
340346
t_physical_tile_type_ptr type;
341347
int nodes_per_chan, tracks_per_node;
@@ -348,6 +354,7 @@ void check_rr_node(const RRGraphView& rr_graph,
348354
xhigh = rr_graph.node_xhigh(rr_node);
349355
ylow = rr_graph.node_ylow(rr_node);
350356
yhigh = rr_graph.node_yhigh(rr_node);
357+
layer_num = rr_graph.node_layer(rr_node);
351358
ptc_num = rr_graph.node_ptc_num(rr_node);
352359
capacity = rr_graph.node_capacity(rr_node);
353360
cost_index = rr_graph.node_cost_index(rr_node);
@@ -363,6 +370,11 @@ void check_rr_node(const RRGraphView& rr_graph,
363370
"in check_rr_node: rr endpoints (%d,%d) and (%d,%d) are out of range.\n", xlow, ylow, xhigh, yhigh);
364371
}
365372

373+
if (layer_num < 0 || layer_num > int(grid.get_num_layers()) - 1) {
374+
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
375+
"in check_rr_node: rr endpoints layer_num (%d) is out of range.\n", layer_num);
376+
}
377+
366378
if (ptc_num < 0) {
367379
VPR_ERROR(VPR_ERROR_ROUTE,
368380
"in check_rr_node: inode %d (type %d) had a ptc_num of %d.\n", inode, rr_type, ptc_num);
@@ -374,7 +386,7 @@ void check_rr_node(const RRGraphView& rr_graph,
374386
}
375387

376388
/* Check that the segment is within the array and such. */
377-
type = grid.get_physical_type(xlow, ylow);
389+
type = grid.get_physical_type({xlow, ylow, layer_num});
378390

379391
switch (rr_type) {
380392
case SOURCE:

libs/librrgraph/src/base/rr_graph_builder.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,27 @@ MetadataStorage<std::tuple<int, int, short>>& RRGraphBuilder::rr_edge_metadata()
2828
void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) {
2929
t_rr_type node_type = node_storage_.node_type(node);
3030
short node_ptc_num = node_storage_.node_ptc_num(node);
31+
short node_layer = node_storage_.node_layer(node);
3132
for (int ix = node_storage_.node_xlow(node); ix <= node_storage_.node_xhigh(node); ix++) {
3233
for (int iy = node_storage_.node_ylow(node); iy <= node_storage_.node_yhigh(node); iy++) {
3334
switch (node_type) {
3435
case SOURCE:
3536
case SINK:
3637
case CHANY:
37-
node_lookup_.add_node(node, ix, iy, node_type, node_ptc_num, SIDES[0]);
38+
node_lookup_.add_node(node,node_layer, ix, iy, node_type, node_ptc_num, SIDES[0]);
3839
break;
3940
case CHANX:
4041
/* Currently need to swap x and y for CHANX because of chan, seg convention
4142
* TODO: Once the builders is reworked for use consistent (x, y) convention,
4243
* the following swapping can be removed
4344
*/
44-
node_lookup_.add_node(node, iy, ix, node_type, node_ptc_num, SIDES[0]);
45+
node_lookup_.add_node(node,node_layer, iy, ix, node_type, node_ptc_num, SIDES[0]);
4546
break;
4647
case OPIN:
4748
case IPIN:
4849
for (const e_side& side : SIDES) {
4950
if (node_storage_.is_node_on_specific_side(node, side)) {
50-
node_lookup_.add_node(node, ix, iy, node_type, node_ptc_num, side);
51+
node_lookup_.add_node(node,node_layer, ix, iy, node_type, node_ptc_num, side);
5152
}
5253
}
5354
break;

libs/librrgraph/src/base/rr_graph_builder.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ class RRGraphBuilder {
165165
node_storage_.set_node_coordinates(id, x1, y1, x2, y2);
166166
}
167167

168+
/** @brief Set the node layer (specifies which die the node is located at) */
169+
inline void set_node_layer(RRNodeId id, short layer){
170+
node_storage_.set_node_layer(id,layer);
171+
}
172+
168173
/** @brief The ptc_num carries different meanings for different node types
169174
* (true in VPR RRG that is currently supported, may not be true in customized RRG)
170175
* CHANX or CHANY: the track id in routing channels
@@ -179,6 +184,11 @@ class RRGraphBuilder {
179184
node_storage_.set_node_ptc_num(id, new_ptc_num);
180185
}
181186

187+
/** @brief set the layer number at which RRNodeId is located at */
188+
inline void set_node_layer(RRNodeId id, int layer){
189+
node_storage_.set_node_layer(id, layer);
190+
}
191+
182192
/** @brief set_node_pin_num() is designed for logic blocks, which are IPIN and OPIN nodes */
183193
inline void set_node_pin_num(RRNodeId id, int new_pin_num) {
184194
node_storage_.set_node_pin_num(id, new_pin_num);

libs/librrgraph/src/base/rr_graph_storage.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,10 @@ const char* t_rr_graph_storage::node_side_string(RRNodeId id) const {
624624
return SIDE_STRING[NUM_SIDES];
625625
}
626626

627+
void t_rr_graph_storage::set_node_layer(RRNodeId id, short layer) {
628+
node_layer_[id] = layer;
629+
}
630+
627631
void t_rr_graph_storage::set_node_ptc_num(RRNodeId id, int new_ptc_num) {
628632
node_ptc_[id].ptc_.pin_num = new_ptc_num; //TODO: eventually remove
629633
}
@@ -777,6 +781,7 @@ int t_rr_graph_view::node_class_num(RRNodeId id) const {
777781
return get_node_class_num(node_storage_, node_ptc_, id);
778782
}
779783

784+
780785
t_rr_graph_view t_rr_graph_storage::view() const {
781786
VTR_ASSERT(partitioned_);
782787
VTR_ASSERT(node_storage_.size() == node_fan_in_.size());
@@ -785,6 +790,7 @@ t_rr_graph_view t_rr_graph_storage::view() const {
785790
vtr::make_const_array_view_id(node_ptc_),
786791
vtr::make_const_array_view_id(node_first_edge_),
787792
vtr::make_const_array_view_id(node_fan_in_),
793+
vtr::make_const_array_view_id(node_layer_),
788794
vtr::make_const_array_view_id(edge_src_node_),
789795
vtr::make_const_array_view_id(edge_dest_node_),
790796
vtr::make_const_array_view_id(edge_switch_));

libs/librrgraph/src/base/rr_graph_storage.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct alignas(16) t_rr_node_data {
7777
} dir_side_;
7878

7979
uint16_t capacity_ = 0;
80+
8081
};
8182

8283
// t_rr_node_data is a key data structure, so fail at compile time if the
@@ -226,6 +227,14 @@ class t_rr_graph_storage {
226227
return node_fan_in_[id];
227228
}
228229

230+
/* Find the layer number that RRNodeId is located at.
231+
* it is zero if the FPGA only has one die.
232+
* The layer number start from the base die (base die: 0, the die above it: 1, etc.)
233+
* */
234+
short node_layer(RRNodeId id) const{
235+
return node_layer_[id];
236+
}
237+
229238
// This prefetechs hot RR node data required for optimization.
230239
//
231240
// Note: This is optional, but may lower time spent on memory stalls in
@@ -393,6 +402,7 @@ class t_rr_graph_storage {
393402
make_room_in_vector(&node_storage_, size_t(elem_position));
394403
node_ptc_.reserve(node_storage_.capacity());
395404
node_ptc_.resize(node_storage_.size());
405+
node_layer_.resize(node_storage_.size());
396406
}
397407

398408
// Reserve storage for RR nodes.
@@ -401,6 +411,7 @@ class t_rr_graph_storage {
401411
VTR_ASSERT(!edges_read_);
402412
node_storage_.reserve(size);
403413
node_ptc_.reserve(size);
414+
node_layer_.reserve(size);
404415
}
405416

406417
// Resize node storage to accomidate size RR nodes.
@@ -409,6 +420,7 @@ class t_rr_graph_storage {
409420
VTR_ASSERT(!edges_read_);
410421
node_storage_.resize(size);
411422
node_ptc_.resize(size);
423+
node_layer_.resize(size);
412424
}
413425

414426
// Number of RR nodes that can be accessed.
@@ -429,6 +441,7 @@ class t_rr_graph_storage {
429441
node_ptc_.clear();
430442
node_first_edge_.clear();
431443
node_fan_in_.clear();
444+
node_layer_.clear();
432445
seen_edge_.clear();
433446
edge_src_node_.clear();
434447
edge_dest_node_.clear();
@@ -448,6 +461,7 @@ class t_rr_graph_storage {
448461
node_ptc_.shrink_to_fit();
449462
node_first_edge_.shrink_to_fit();
450463
node_fan_in_.shrink_to_fit();
464+
node_layer_.shrink_to_fit();
451465
seen_edge_.shrink_to_fit();
452466
edge_src_node_.shrink_to_fit();
453467
edge_dest_node_.shrink_to_fit();
@@ -461,6 +475,7 @@ class t_rr_graph_storage {
461475
VTR_ASSERT(!edges_read_);
462476
node_storage_.emplace_back();
463477
node_ptc_.emplace_back();
478+
node_layer_.emplace_back();
464479
}
465480

466481
// Given `order`, a vector mapping each RRNodeId to a new one (old -> new),
@@ -479,6 +494,7 @@ class t_rr_graph_storage {
479494

480495
void set_node_type(RRNodeId id, t_rr_type new_type);
481496
void set_node_coordinates(RRNodeId id, short x1, short y1, short x2, short y2);
497+
void set_node_layer(RRNodeId id, short layer);
482498
void set_node_cost_index(RRNodeId, RRIndexedDataId new_cost_index);
483499
void set_node_rc_index(RRNodeId, NodeRCIndex new_rc_index);
484500
void set_node_capacity(RRNodeId, short new_capacity);
@@ -670,6 +686,12 @@ class t_rr_graph_storage {
670686
// Fan in counts for each RR node.
671687
vtr::vector<RRNodeId, t_edge_size> node_fan_in_;
672688

689+
// Layer number that each RR node is located at
690+
// Layer number refers to the die that the node belongs to. The layer number of base die is zero and die above it one, etc.
691+
// This data is also considered as a hot data since it is used in inner loop of router, but since it didn't fit nicely into t_rr_node_data due to alignment issues, we had to store it
692+
// in a separate vector.
693+
vtr::vector<RRNodeId, short> node_layer_;
694+
673695
// Edge storage.
674696
vtr::vector<RREdgeId, RRNodeId> edge_src_node_;
675697
vtr::vector<RREdgeId, RRNodeId> edge_dest_node_;
@@ -721,13 +743,15 @@ class t_rr_graph_view {
721743
const vtr::array_view_id<RRNodeId, const t_rr_node_ptc_data> node_ptc,
722744
const vtr::array_view_id<RRNodeId, const RREdgeId> node_first_edge,
723745
const vtr::array_view_id<RRNodeId, const t_edge_size> node_fan_in,
746+
const vtr::array_view_id<RRNodeId, const short> node_layer,
724747
const vtr::array_view_id<RREdgeId, const RRNodeId> edge_src_node,
725748
const vtr::array_view_id<RREdgeId, const RRNodeId> edge_dest_node,
726749
const vtr::array_view_id<RREdgeId, const short> edge_switch)
727750
: node_storage_(node_storage)
728751
, node_ptc_(node_ptc)
729752
, node_first_edge_(node_first_edge)
730753
, node_fan_in_(node_fan_in)
754+
, node_layer_(node_layer)
731755
, edge_src_node_(edge_src_node)
732756
, edge_dest_node_(edge_dest_node)
733757
, edge_switch_(edge_switch) {}
@@ -784,6 +808,11 @@ class t_rr_graph_view {
784808
return node_fan_in_[id];
785809
}
786810

811+
/* Retrieve layer(die) number that RRNodeId is located at */
812+
short node_layer(RRNodeId id) const{
813+
return node_layer_[id];
814+
}
815+
787816
// This prefetechs hot RR node data required for optimization.
788817
//
789818
// Note: This is optional, but may lower time spent on memory stalls in
@@ -824,6 +853,7 @@ class t_rr_graph_view {
824853
vtr::array_view_id<RRNodeId, const t_rr_node_ptc_data> node_ptc_;
825854
vtr::array_view_id<RRNodeId, const RREdgeId> node_first_edge_;
826855
vtr::array_view_id<RRNodeId, const t_edge_size> node_fan_in_;
856+
vtr::array_view_id<RRNodeId, const short> node_layer_;
827857
vtr::array_view_id<RREdgeId, const RRNodeId> edge_src_node_;
828858
vtr::array_view_id<RREdgeId, const RRNodeId> edge_dest_node_;
829859
vtr::array_view_id<RREdgeId, const short> edge_switch_;

0 commit comments

Comments
 (0)