Skip to content

Commit 417bf61

Browse files
create a t_rr_switch_offset_inf for each t_rr_switch_inf added to RR graph
1 parent c6d6a40 commit 417bf61

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,10 @@ struct t_rr_switch_offset_inf {
18791879
// float Cinternal = 0.;
18801880
float Tdel = 0.;
18811881

1882+
t_rr_switch_offset_inf() = default;
1883+
t_rr_switch_offset_inf(const t_rr_switch_inf& switch_inf)
1884+
: Tdel(switch_inf.Tdel) {}
1885+
18821886
auto operator<=>(const t_rr_switch_offset_inf&) const = default;
18831887
};
18841888

libs/librrgraph/src/base/rr_graph_builder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void RRGraphBuilder::clear() {
7979
rr_edge_metadata_.clear();
8080
rr_segments_.clear();
8181
rr_switch_inf_.clear();
82+
rr_switch_offset_inf_.clear();
8283
}
8384

8485
void RRGraphBuilder::reorder_nodes(e_rr_node_reorder_algorithm reorder_rr_graph_nodes_algorithm,

libs/librrgraph/src/base/rr_graph_builder.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,13 @@ class RRGraphBuilder {
102102
inline RRSwitchId add_rr_switch(const t_rr_switch_inf& switch_info) {
103103
//Allocate an ID
104104
RRSwitchId switch_id = RRSwitchId(rr_switch_inf_.size());
105-
106105
rr_switch_inf_.push_back(switch_info);
107106

107+
t_rr_switch_offset_inf switch_offset_info(switch_info);
108+
rr_switch_offset_inf_.push_back(switch_offset_info);
109+
110+
VTR_ASSERT_DEBUG(rr_switch_inf_.size() == rr_switch_offset_inf_.size());
111+
108112
return switch_id;
109113
}
110114
/**
@@ -119,6 +123,7 @@ class RRGraphBuilder {
119123
}
120124

121125
inline RRSwitchOffsetInfoId add_rr_switch_offset_info(const t_rr_switch_offset_inf& switch_offset_info) {
126+
VTR_ASSERT_DEBUG(rr_switch_inf_.size() <= rr_switch_offset_inf_.size());
122127
// Allocate an ID
123128
RRSwitchOffsetInfoId switch_offset_info_id = RRSwitchOffsetInfoId(rr_switch_offset_inf_.size());
124129
rr_switch_offset_inf_.push_back(switch_offset_info);

libs/librrgraph/src/base/rr_graph_storage.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void t_rr_graph_storage::init_fan_in() {
417417
node_fan_in_.resize(node_storage_.size(), 0);
418418
node_fan_in_.shrink_to_fit();
419419
//Walk the graph and increment fanin on all downstream nodes
420-
for(const auto& edge_id : edge_dest_node_.keys()) {
420+
for(const RREdgeId edge_id : edge_dest_node_.keys()) {
421421
node_fan_in_[edge_dest_node_[edge_id]] += 1;
422422
}
423423
}
@@ -504,6 +504,7 @@ void t_rr_graph_storage::remap_rr_node_switch_indices(const t_arch_switch_fanin&
504504
for (size_t i = 0; i < edge_src_node_.size(); ++i) {
505505
RREdgeId edge(i);
506506
if(edge_remapped_[edge]) {
507+
VTR_ASSERT(edge_switch_offset_inf_[edge].is_valid());
507508
continue;
508509
}
509510

@@ -521,6 +522,7 @@ void t_rr_graph_storage::remap_rr_node_switch_indices(const t_arch_switch_fanin&
521522
int rr_switch_index = itr->second;
522523

523524
edge_switch_[edge] = rr_switch_index;
525+
edge_switch_offset_inf_[edge] = (RRSwitchOffsetInfoId)rr_switch_index;
524526
edge_remapped_[edge] = true;
525527
}
526528
remapped_edges_ = true;
@@ -558,7 +560,7 @@ void t_rr_graph_storage::partition_edges(const vtr::vector<RRSwitchId, t_rr_swit
558560
void t_rr_graph_storage::set_edge_offset_id(RREdgeId edge_id, RRSwitchOffsetInfoId offset_id) {
559561
VTR_ASSERT_DEBUG(partitioned_);
560562
VTR_ASSERT_DEBUG(remapped_edges_);
561-
VTR_ASSERT_DEBUG(edge_switch_offset_inf_[edge_id] == RRSwitchOffsetInfoId::INVALID());
563+
VTR_ASSERT_DEBUG(edge_switch_offset_inf_[edge_id].is_valid());
562564

563565
edge_switch_offset_inf_[edge_id] = offset_id;
564566
}

libs/librrgraph/src/base/rr_graph_view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class RRGraphView {
422422
inline float edge_delay(RRNodeId id, t_edge_size iedge) const {
423423
RREdgeId edge_id = node_storage_.edge_id(id, iedge);
424424
RRSwitchOffsetInfoId switch_offset_inf_id = node_storage_.edge_switch_offset_inf(edge_id);
425-
return rr_switch_offset_inf_[switch_offset_inf_id].Tdel;;
425+
return rr_switch_offset_inf_[switch_offset_inf_id].Tdel;
426426
}
427427

428428
/** @brief Return the source node for the specified edge.

libs/librrgraph/src/io/rr_graph_reader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ void load_rr_edge_attribute_offset_file(RRGraphBuilder& rr_graph_builder,
158158

159159
RRSwitchOffsetInfoId rr_switch_offset_id;
160160
if (it == unique_edge_offsets.end()) {
161-
// if the detailed info is seen for the first time, add it to RR graph
161+
// if the detailed info is seen for the first time, add it to RR graph and record it in `unique_edge_offsets`
162162
rr_switch_offset_id = rr_graph_builder.add_rr_switch_offset_info(rr_switch_detailed_inf);
163+
unique_edge_offsets.insert({rr_switch_detailed_inf, rr_switch_offset_id});
163164
} else {
164165
// the detailed info has already been added to the RR graph
165166
rr_switch_offset_id = it->second;

0 commit comments

Comments
 (0)