@@ -259,10 +259,10 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
259
259
bool read_edge_metadata,
260
260
t_chan_width* chan_width,
261
261
t_rr_graph_storage* rr_nodes,
262
+ RRGraphBuilder* rr_graph_builder,
262
263
RRGraphView* rr_graph,
263
264
std::vector<t_rr_switch_inf>* rr_switch_inf,
264
265
std::vector<t_rr_indexed_data>* rr_indexed_data,
265
- t_rr_node_indices* rr_node_indices,
266
266
const size_t num_arch_switches,
267
267
const t_arch_switch_inf* arch_switch_inf,
268
268
const std::vector<t_segment_inf>& segment_inf,
@@ -274,10 +274,10 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
274
274
: wire_to_rr_ipin_switch_(wire_to_rr_ipin_switch)
275
275
, chan_width_(chan_width)
276
276
, rr_nodes_(rr_nodes)
277
+ , rr_graph_builder_(rr_graph_builder)
277
278
, rr_graph_(rr_graph)
278
279
, rr_switch_inf_(rr_switch_inf)
279
280
, rr_indexed_data_(rr_indexed_data)
280
- , rr_node_indices_(rr_node_indices)
281
281
, read_rr_graph_filename_(read_rr_graph_filename)
282
282
, graph_type_(graph_type)
283
283
, base_cost_type_(base_cost_type)
@@ -1566,148 +1566,21 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
1566
1566
/* Allocates and load the rr_node look up table. SINK and SOURCE, IPIN and OPIN
1567
1567
*share the same look up table. CHANX and CHANY have individual look ups */
1568
1568
void process_rr_node_indices () {
1569
- const auto & rr_graph = (*rr_graph_);
1570
- /* Alloc the lookup table */
1571
- auto & indices = *rr_node_indices_;
1572
-
1573
- typedef struct max_ptc {
1574
- short chanx_max_ptc = 0 ;
1575
- short chany_max_ptc = 0 ;
1576
- } t_max_ptc;
1577
-
1578
- /*
1579
- * Local multi-dimensional vector to hold max_ptc for every coordinate.
1580
- * It has same height and width as CHANY and CHANX are inverted
1581
- */
1582
- vtr::Matrix<t_max_ptc> coordinates_max_ptc; /* [x][y] */
1583
- size_t max_coord_size = std::max (grid_.width (), grid_.height ());
1584
- coordinates_max_ptc.resize ({max_coord_size, max_coord_size}, t_max_ptc ());
1569
+ auto & rr_graph_builder = (*rr_graph_builder_);
1585
1570
1586
1571
/* Alloc the lookup table */
1587
1572
for (t_rr_type rr_type : RR_TYPES) {
1588
1573
if (rr_type == CHANX) {
1589
- indices[rr_type]. resize ({ grid_.height (), grid_.width (), NUM_SIDES} );
1574
+ rr_graph_builder. node_lookup (). resize_nodes ( grid_.height (), grid_.width (), rr_type, NUM_SIDES);
1590
1575
} else {
1591
- indices[rr_type]. resize ({ grid_.width (), grid_.height (), NUM_SIDES} );
1576
+ rr_graph_builder. node_lookup (). resize_nodes ( grid_.width (), grid_.height (), rr_type, NUM_SIDES);
1592
1577
}
1593
1578
}
1594
1579
1595
- /*
1596
- * Add the correct node into the vector
1597
- * For CHANX and CHANY no node is added yet, but the maximum ptc is counted for each
1598
- * x/y location. This is needed later to add the correct node corresponding to CHANX
1599
- * and CHANY.
1600
- *
1601
- * Note that CHANX and CHANY 's x and y are swapped due to the chan and seg convention.
1602
- */
1580
+ /* Add the correct node into the vector */
1603
1581
for (size_t inode = 0 ; inode < rr_nodes_->size (); inode++) {
1604
1582
auto node = (*rr_nodes_)[inode];
1605
- if (rr_graph.node_type (node.id ()) == SOURCE || rr_graph.node_type (node.id ()) == SINK) {
1606
- for (int ix = node.xlow (); ix <= node.xhigh (); ix++) {
1607
- for (int iy = node.ylow (); iy <= node.yhigh (); iy++) {
1608
- if (node.ptc_num () >= (int )indices[SOURCE][ix][iy][0 ].size ()) {
1609
- indices[SOURCE][ix][iy][0 ].resize (node.ptc_num () + 1 , OPEN);
1610
- }
1611
- if (node.ptc_num () >= (int )indices[SINK][ix][iy][0 ].size ()) {
1612
- indices[SINK][ix][iy][0 ].resize (node.ptc_num () + 1 , OPEN);
1613
- }
1614
- indices[rr_graph.node_type (node.id ())][ix][iy][0 ][node.ptc_num ()] = inode;
1615
- }
1616
- }
1617
- } else if (rr_graph.node_type (node.id ()) == IPIN || rr_graph.node_type (node.id ()) == OPIN) {
1618
- for (int ix = node.xlow (); ix <= node.xhigh (); ix++) {
1619
- for (int iy = node.ylow (); iy <= node.yhigh (); iy++) {
1620
- for (const e_side& side : SIDES) {
1621
- if (!node.is_node_on_specific_side (side)) {
1622
- continue ;
1623
- }
1624
- if (node.ptc_num () >= (int )indices[OPIN][ix][iy][side].size ()) {
1625
- indices[OPIN][ix][iy][side].resize (node.ptc_num () + 1 , OPEN);
1626
- }
1627
- if (node.ptc_num () >= (int )indices[IPIN][ix][iy][side].size ()) {
1628
- indices[IPIN][ix][iy][side].resize (node.ptc_num () + 1 , OPEN);
1629
- }
1630
- indices[rr_graph.node_type (node.id ())][ix][iy][side][node.ptc_num ()] = inode;
1631
- }
1632
- }
1633
- }
1634
- } else if (rr_graph.node_type (node.id ()) == CHANX) {
1635
- for (int ix = node.xlow (); ix <= node.xhigh (); ix++) {
1636
- for (int iy = node.ylow (); iy <= node.yhigh (); iy++) {
1637
- coordinates_max_ptc[iy][ix].chanx_max_ptc = std::max (coordinates_max_ptc[iy][ix].chanx_max_ptc , node.ptc_num ());
1638
- }
1639
- }
1640
- } else if (rr_graph.node_type (node.id ()) == CHANY) {
1641
- for (int ix = node.xlow (); ix <= node.xhigh (); ix++) {
1642
- for (int iy = node.ylow (); iy <= node.yhigh (); iy++) {
1643
- coordinates_max_ptc[ix][iy].chany_max_ptc = std::max (coordinates_max_ptc[ix][iy].chany_max_ptc , node.ptc_num ());
1644
- }
1645
- }
1646
- }
1647
- }
1648
-
1649
- /* Alloc the lookup table */
1650
- for (t_rr_type rr_type : RR_TYPES) {
1651
- if (rr_type == CHANX) {
1652
- for (size_t y = 0 ; y < grid_.height (); ++y) {
1653
- for (size_t x = 0 ; x < grid_.width (); ++x) {
1654
- indices[CHANX][y][x][0 ].resize (coordinates_max_ptc[y][x].chanx_max_ptc + 1 , OPEN);
1655
- }
1656
- }
1657
- } else if (rr_type == CHANY) {
1658
- for (size_t x = 0 ; x < grid_.width (); ++x) {
1659
- for (size_t y = 0 ; y < grid_.height (); ++y) {
1660
- indices[CHANY][x][y][0 ].resize (coordinates_max_ptc[x][y].chany_max_ptc + 1 , OPEN);
1661
- }
1662
- }
1663
- }
1664
- }
1665
-
1666
- int count;
1667
- /* CHANX and CHANY need to reevaluated with its ptc num as the correct index*/
1668
- for (size_t inode = 0 ; inode < rr_nodes_->size (); inode++) {
1669
- auto node = (*rr_nodes_)[inode];
1670
- if (rr_graph.node_type (node.id ()) == CHANX) {
1671
- for (int iy = node.ylow (); iy <= node.yhigh (); iy++) {
1672
- for (int ix = node.xlow (); ix <= node.xhigh (); ix++) {
1673
- count = node.ptc_num ();
1674
- if (count >= int (indices[CHANX][iy][ix][0 ].size ())) {
1675
- report_error (
1676
- " Ptc index %d for CHANX (%d, %d) is out of bounds, size = %zu" ,
1677
- count, ix, iy, indices[CHANX][iy][ix][0 ].size ());
1678
- }
1679
- indices[CHANX][iy][ix][0 ][count] = inode;
1680
- }
1681
- }
1682
- } else if (rr_graph.node_type (node.id ()) == CHANY) {
1683
- for (int ix = node.xlow (); ix <= node.xhigh (); ix++) {
1684
- for (int iy = node.ylow (); iy <= node.yhigh (); iy++) {
1685
- count = node.ptc_num ();
1686
- if (count >= int (indices[CHANY][ix][iy][0 ].size ())) {
1687
- report_error (
1688
- " Ptc index %d for CHANY (%d, %d) is out of bounds, size = %zu" ,
1689
- count, ix, iy, indices[CHANY][ix][iy][0 ].size ());
1690
- }
1691
- indices[CHANY][ix][iy][0 ][count] = inode;
1692
- }
1693
- }
1694
- }
1695
- }
1696
-
1697
- // Copy the SOURCE/SINK nodes to all offset positions for blocks with width > 1 and/or height > 1
1698
- // This ensures that look-ups on non-root locations will still find the correct SOURCE/SINK
1699
- for (size_t x = 0 ; x < grid_.width (); x++) {
1700
- for (size_t y = 0 ; y < grid_.height (); y++) {
1701
- int width_offset = grid_[x][y].width_offset ;
1702
- int height_offset = grid_[x][y].height_offset ;
1703
- if (width_offset != 0 || height_offset != 0 ) {
1704
- int root_x = x - width_offset;
1705
- int root_y = y - height_offset;
1706
-
1707
- indices[SOURCE][x][y][0 ] = indices[SOURCE][root_x][root_y][0 ];
1708
- indices[SINK][x][y][0 ] = indices[SINK][root_x][root_y][0 ];
1709
- }
1710
- }
1583
+ rr_graph_builder.add_node_to_all_locs (node.id ());
1711
1584
}
1712
1585
}
1713
1586
@@ -1976,6 +1849,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
1976
1849
int * wire_to_rr_ipin_switch_;
1977
1850
t_chan_width* chan_width_;
1978
1851
t_rr_graph_storage* rr_nodes_;
1852
+ RRGraphBuilder* rr_graph_builder_;
1979
1853
RRGraphView* rr_graph_;
1980
1854
std::vector<t_rr_switch_inf>* rr_switch_inf_;
1981
1855
std::vector<t_rr_indexed_data>* rr_indexed_data_;
0 commit comments