@@ -325,6 +325,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
325
325
, is_flat_(is_flat) {
326
326
// Initialize internal data
327
327
init_side_map ();
328
+ init_segment_inf_x_y ();
328
329
}
329
330
330
331
/* A truth table to help understand the conversion from VPR side mask to uxsd side code
@@ -381,6 +382,40 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
381
382
side_map_[(1 << TOP) | (1 << RIGHT) | (1 << BOTTOM) | (1 << LEFT)] = uxsd::enum_loc_side::TOP_RIGHT_BOTTOM_LEFT;
382
383
}
383
384
385
+ void init_segment_inf_x_y (){
386
+ /* Create a temp copy to convert from vtr::vector to std::vector
387
+ * This is required because the ``alloc_and_load_rr_indexed_data()`` function supports only std::vector data
388
+ * type for ``rr_segments``
389
+ * Note that this is a dirty fix (to avoid massive code changes)
390
+ * TODO: The ``alloc_and_load_rr_indexed_data()`` function should embrace ``vtr::vector`` for ``rr_segments``
391
+ */
392
+ std::vector<t_segment_inf> rr_segs;
393
+ rr_segs.reserve (segment_inf_.size ());
394
+ for (auto & rr_seg : segment_inf_) {
395
+ rr_segs.push_back (rr_seg);
396
+ }
397
+
398
+ t_unified_to_parallel_seg_index seg_index_map;
399
+ segment_inf_x_ = get_parallel_segs (rr_segs, seg_index_map, X_AXIS);
400
+ segment_inf_y_ = get_parallel_segs (rr_segs, seg_index_map, Y_AXIS);
401
+
402
+ }
403
+
404
+ int find_segment_index_along_axis (int seg_index, e_parallel_axis axis) const {
405
+ const std::vector<t_segment_inf>* segment_inf_vec_ptr;
406
+
407
+ if (axis == X_AXIS)
408
+ segment_inf_vec_ptr = &segment_inf_x_;
409
+ else
410
+ segment_inf_vec_ptr = &segment_inf_y_;
411
+
412
+ for (std::vector<t_segment_inf>::size_type i=0 ; i < (*segment_inf_vec_ptr).size (); i++){
413
+ if ((*segment_inf_vec_ptr)[i].seg_index == seg_index)
414
+ return static_cast <int >(i);
415
+ }
416
+ return 0 ;
417
+ }
418
+
384
419
public:
385
420
void start_load (const std::function<void (const char *)>* report_error_in) final {
386
421
// report_error_in should be invoked if RrGraphSerializer encounters
@@ -748,10 +783,12 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
748
783
if (GRAPH_GLOBAL == graph_type_) {
749
784
rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (0 ));
750
785
} else if (rr_graph.node_type (node.id ()) == CHANX) {
751
- rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (CHANX_COST_INDEX_START + segment_id));
786
+ int seg_ind_x = find_segment_index_along_axis (segment_id, X_AXIS);
787
+ rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (CHANX_COST_INDEX_START + seg_ind_x));
752
788
seg_index_[rr_graph.node_cost_index (node.id ())] = segment_id;
753
789
} else if (rr_graph.node_type (node.id ()) == CHANY) {
754
- rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (CHANX_COST_INDEX_START + segment_inf_.size () + segment_id));
790
+ int seg_ind_y = find_segment_index_along_axis (segment_id, Y_AXIS);
791
+ rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (CHANX_COST_INDEX_START + segment_inf_x_.size () + seg_ind_y));
755
792
seg_index_[rr_graph.node_cost_index (node.id ())] = segment_id;
756
793
}
757
794
return inode;
@@ -884,7 +921,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
884
921
885
922
inline void * init_rr_graph_rr_nodes (void *& /* ctx*/ ) final {
886
923
rr_nodes_->clear ();
887
- seg_index_.resize (CHANX_COST_INDEX_START + 2 * segment_inf_ .size (), -1 );
924
+ seg_index_.resize (CHANX_COST_INDEX_START + segment_inf_x_. size () + segment_inf_y_ .size (), -1 );
888
925
return nullptr ;
889
926
}
890
927
inline void finish_rr_graph_rr_nodes (void *& /* ctx*/ ) final {
@@ -1612,22 +1649,13 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
1612
1649
process_rr_node_indices ();
1613
1650
1614
1651
rr_graph_builder_->init_fan_in ();
1615
- /* Create a temp copy to convert from vtr::vector to std::vector
1616
- * This is required because the ``alloc_and_load_rr_indexed_data()`` function supports only std::vector data
1617
- * type for ``rr_segments``
1618
- * Note that this is a dirty fix (to avoid massive code changes)
1619
- * TODO: The ``alloc_and_load_rr_indexed_data()`` function should embrace ``vtr::vector`` for ``rr_segments``
1620
- */
1652
+
1621
1653
std::vector<t_segment_inf> temp_rr_segs;
1622
1654
temp_rr_segs.reserve (segment_inf_.size ());
1623
1655
for (auto & rr_seg : segment_inf_) {
1624
1656
temp_rr_segs.push_back (rr_seg);
1625
1657
}
1626
1658
1627
- t_unified_to_parallel_seg_index seg_index_map;
1628
- auto segment_inf_x_ = get_parallel_segs (temp_rr_segs, seg_index_map, X_AXIS);
1629
- auto segment_inf_y_ = get_parallel_segs (temp_rr_segs, seg_index_map, Y_AXIS);
1630
-
1631
1659
alloc_and_load_rr_indexed_data (
1632
1660
*rr_graph_,
1633
1661
grid_,
@@ -1972,6 +2000,8 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
1972
2000
* the methods following routines:rr_graph_rr_nodes and init_node_segment according to the changes in
1973
2001
* rr_graph_indexed_data.cpp */
1974
2002
const vtr::vector<RRSegmentId, t_segment_inf>& segment_inf_;
2003
+ std::vector<t_segment_inf> segment_inf_x_;
2004
+ std::vector<t_segment_inf> segment_inf_y_;
1975
2005
const std::vector<t_physical_tile_type>& physical_tile_types_;
1976
2006
const DeviceGrid& grid_;
1977
2007
MetadataStorage<int >* rr_node_metadata_;
0 commit comments