-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override edge attributes in RR graph #2930
base: master
Are you sure you want to change the base?
Conversation
…and pass the correct argument to load_rr_file
@petergrossmann21 I'd apprecite any feedback on this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks good to me. I’ve added several small comments, mainly related to adding comments. :)
One more thing—I think it would be good to add a test for this PR. As we discussed, testing this requires additional functionality beyond what the current infrastructure provides. I suggest creating an issue to track it, and we can implement it in a separate PR.
@@ -264,6 +264,10 @@ class RRGraphBuilder { | |||
node_storage_.alloc_and_load_edges(rr_edges_to_create); | |||
} | |||
|
|||
inline void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To maintain consistency with other functions, I think it would be better to add a Doxygen comment. (just add a brief description)
@@ -731,6 +730,8 @@ class t_rr_graph_storage { | |||
*/ | |||
void partition_edges(const vtr::vector<RRSwitchId, t_rr_switch_inf>& rr_switches); | |||
|
|||
void override_edge_switch(RREdgeId edge_id, RRSwitchId switch_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DoxyGen comment (@brief only) similar to other functions
@@ -413,6 +413,10 @@ class RRGraphView { | |||
return node_storage_.edge_switch(id, iedge); | |||
} | |||
|
|||
inline short edge_switch(RREdgeId id) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DoxyGen
} | ||
} | ||
|
||
if (!edge_id.is_valid()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it more concise, I suggest using VTR_LOGV_ERROR(expr, ...).
bool read_edge_metadata, | ||
bool do_check_rr_graph, | ||
bool echo_enabled, | ||
const char* echo_file_name, | ||
bool is_flat); | ||
|
||
void load_rr_edge_overrides(std::string_view filename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doxygen comment
RRGraphBuilder& rr_graph_builder, | ||
const RRGraphView& rr_graph) { | ||
std::ifstream file(filename.data()); | ||
if (!file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VTR_LOGV_ERROR
return edge_id; | ||
} | ||
|
||
struct t_rr_switch_inf_hash { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better way to implement a hash function for t_rr_switch_inf
is to define the hash function within the struct itself. This ensures that if someone adds a new field to the data structure, they can update the hash function directly in the same place.
Additionally, you can add the following specialization in the same file:
namespace std {
template <>
struct hash<t_rr_switch_inf> {
size_t operator()(const t_rr_switch_inf& s) const {
return s.hash();
}
};
}
An added benefit of this approach is that you wouldn't need to explicitly pass the hash function when using data structures like std::unordered_map
or std::unordered_set
, as it will be automatically recognized.
} | ||
}; | ||
|
||
struct t_rr_switch_inf_equal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure that any additional fields added to this data structure are properly handled, I suggest overloading the operator within the struct itself.
VTR_LOG_ERROR("Failed to open the RR edge override file: %s\n", filename.data()); | ||
} | ||
|
||
std::unordered_map<t_rr_switch_inf, RRSwitchId, t_rr_switch_inf_hash, t_rr_switch_inf_equal> unique_switch_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also needed to do something similar when creating edges while collapsing RR Node chains in the flat router. If you could create an issue to remind me to implement a function for this, that would be helpful.
RRSwitchId new_switch_id; | ||
auto it = unique_switch_info.find(switch_override_info); | ||
if (it == unique_switch_info.end()) { | ||
new_switch_id = rr_graph_builder.add_rr_switch(switch_override_info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I think about it, I'm pretty sure I wrote a function that retrieves switch info, searches the RR Node switches for one with similar characteristics, and, if none is found, creates a new one and returns the corresponding RR switch ID (I think the name was something like get_or_create_rr_switch_id). In the issue I mentioned, if you could reference this function, I'll update this part of the code myself.
@soheilshahrouz Some initial thoughts:
I think the file size analysis above is sufficient to motivate implementing some method of shorthand in the file format so that the architect can express when multiple edges have the same delay parameter. My first instinct is that some kind of relationship between the physical tile definitions and the graph edges can help with this. Currently, the way that I do that is by relating switches in the An aside: Note that in automatic place and route flows for ASICs, the R and C values are either not generated at all (because the wire delay is lumped with the "intrinsic" delay of the logic gates and so the VPR model will set all the RC values to 0) OR the intrinsic delay is captured independently of the RC values and thus it's convenient to annotate them separately anyway. |
@soheilshahrouz one additional thought: if the delay annotation is to be performed as a standalone step, having a dedicated executable utility to run it will be helpful--this will avoid having to call vpr for this step and having to pass in an arbitrary blif file. |
Adds a new command line option to override attributes of specific edges in the RR graph.
Description
The user can pass a text file using --read_rr_edge_override, which modifies delay and electrical characteristics of selected edges. The expected file format:
The first line must start with
#
and is always ignored by the parser.Each following line must include an RR edge ID and delay (Tdel). Other attributes (resistance, capacitances) are optional. Edges can also be specified using source/sink node pairs.
How Has This Been Tested?
By manual inspection of generated RR graph files to see if the edge attributes are overridden correctly.
Types of changes
Checklist: