-
Notifications
You must be signed in to change notification settings - Fork 414
Data structure rr_node_metadata/rr_edge_metadata owner change #1952
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
Conversation
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.
@Raza-jafari-RS Some comments to address. Thanks for the hard working. We are getting close. If you have any questions, feel free to reach out to me.
vpr/src/base/vpr_context.h
Outdated
@@ -149,6 +149,25 @@ struct DeviceContext : public Context { | |||
*/ | |||
t_rr_graph_storage rr_nodes; // autogenerated in build_rr_graph | |||
|
|||
/** |
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.
These comments are related to metadata. They should be moved to RRGraphBuilder
and RRGraphView
These dead codes should be removed once this PR is ready to merge.
vpr/src/device/rr_graph_builder.h
Outdated
inline void rr_node_metadata_clear() { | ||
rr_node_metadata_.clear(); | ||
} | ||
inline void rr_edge_metadata_clear() { |
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.
Our naming convention is clear_rr_edge_metadata()
vpr/src/device/rr_graph_builder.h
Outdated
return rr_node_metadata_.size(); | ||
} | ||
|
||
//rr_node_metadata_find |
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.
Templates should not be placed with regular APIs. My suggestion is to move to the head of a class definition.
See example:
vtr-verilog-to-routing/vpr/src/device/rr_graph_obj.h
Lines 213 to 224 in 36789e4
public: /* Types */ | |
/* Iterators used to create iterator-based loop for nodes/edges/switches/segments */ | |
typedef vtr::vector<RRNodeId, RRNodeId>::const_iterator node_iterator; | |
typedef vtr::vector<RREdgeId, RREdgeId>::const_iterator edge_iterator; | |
typedef vtr::vector<RRSwitchId, RRSwitchId>::const_iterator switch_iterator; | |
typedef vtr::vector<RRSegmentId, RRSegmentId>::const_iterator segment_iterator; | |
/* Ranges used to create range-based loop for nodes/edges/switches/segments */ | |
typedef vtr::Range<node_iterator> node_range; | |
typedef vtr::Range<edge_iterator> edge_range; | |
typedef vtr::Range<switch_iterator> switch_range; | |
typedef vtr::Range<segment_iterator> segment_range; |
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.
If I make the template as a class template over the RR_graph_builder.h as it is on the metadata_storage.h. Almost all the API's in the class become unknown to the locations where they have been used. Should I make the changes in all the API's or I am doing some thing wrong as I am not worked much with the templates.
vtr-verilog-to-routing/vpr/src/base/metadata_storage.h
Lines 18 to 19 in 36789e4
template<typename LookupKey> | |
class MetadataStorage { |
Please guide me how to resolve this issue.
vpr/src/route/rr_graph.cpp
Outdated
@@ -1367,9 +1367,9 @@ void free_rr_graph() { | |||
|
|||
device_ctx.switch_fanin_remap.clear(); | |||
|
|||
device_ctx.rr_node_metadata.clear(); | |||
device_ctx.rr_graph_builder.rr_node_metadata_clear(); |
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 suggest to
- Convert the
rr_node_metadata_clear()
andrr_edge_metadata_clear()
function to private. - Call these clear functions in the
clear()
API ofRRGraphBuilder
Then, here you just need to call device_ctx.rr_graph_builder.clear()
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 have called the rr_node_metadata_.clear() inside the RRGraphBuilder::clear. I have done this following the convention used for node_loopup_.clear()
https://github.com/RapidSilicon/vtr-verilog-to-routing/blob/05dd5c00e92c2cd0ff958f750be9318a05973a2c/vpr/src/device/rr_graph_builder.cpp#L62-L66
@@ -72,8 +72,8 @@ void load_rr_file(const t_graph_type graph_type, | |||
device_ctx.rr_segments, | |||
device_ctx.physical_tile_types, | |||
grid, | |||
&device_ctx.rr_node_metadata, | |||
&device_ctx.rr_edge_metadata, | |||
&device_ctx.rr_graph_builder.rr_node_metadata(), |
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.
If the two APIs rr_node_metadata()
and rr_edge_metadata()
already return reference, you may not need the &
here. Please double check.
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 tried to remove the & operator here and it starts throwing error of "no known conversion for arguments" we have to make changes to the locations where this function is used. So should I go for the changings or keep it in the way as it is?
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.
It is o.k. here. We may consider to change it later.
vpr/src/route/rr_metadata.cpp
Outdated
device_ctx.rr_node_metadata.add_metadata(src_node, | ||
key, | ||
value); | ||
device_ctx.rr_graph_builder.rr_node_metadata_add_metadata(src_node, |
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.
In principle, we should not reinvent the wheel. The ideal way is
device_ctx.rr_graph_builder.rr_node_metadata().add_metadata(..)
I remember you mentioned it caused some errors in compilation. If so, I am o.k. for now.
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.
The API rr_node_metadata_add_metadata has been removed and the add_metadata has been called as the prescribed method.
vpr/src/device/rr_graph_builder.h
Outdated
|
||
//rr_node_metadata_find | ||
template<typename LookupKey> | ||
inline typename vtr::flat_map<LookupKey, t_metadata_dict>::const_iterator rr_node_metadata_find(const LookupKey& lookup_key) 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.
I am reading the codes about rr_metadata
at
vtr-verilog-to-routing/vpr/src/route/rr_metadata.h
Lines 8 to 14 in 36789e4
const t_metadata_value* rr_node_metadata(int src_node, vtr::interned_string key); | |
void add_rr_node_metadata(int src_node, vtr::interned_string key, vtr::interned_string value); | |
void add_rr_node_metadata(int src_node, vtr::string_view key, vtr::string_view value); | |
const t_metadata_value* rr_edge_metadata(int src_node, int sink_node, short switch_id, vtr::interned_string key); | |
void add_rr_edge_metadata(int src_node, int sink_node, short switch_id, vtr::interned_string key, vtr::interned_string value); | |
void add_rr_edge_metadata(int src_node, int sink_node, short switch_id, vtr::string_view key, vtr::string_view value); |
It does not include templates, can you explain more details why you want to include templates?
In general, we try to avoid it because it may slow down the runtime.
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 have created API's for the functions in metadata_storage.h and there a class template has been used.
typename vtr::flat_map<LookupKey, t_metadata_dict>::const_iterator find(const LookupKey& lookup_key) const { |
Inorder to pass the values to the template I am using the function template.
|
||
MetadataStorage<int>& rr_node_metadata_; | ||
MetadataStorage<std::tuple<int, int, short>>& rr_edge_metadata_; | ||
/** |
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.
we should add a warning to the comments, in order to avoid any developers to merge the metadate into other internal data:
/** .. warning:: The Metadata should stay as an independent data structure than rest of the internal data, e.g., node_lookup! */
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.
@Raza-jafari-RS Thanks for the efforts. We are almost there.
vpr/src/device/rr_graph_builder.h
Outdated
@@ -40,6 +38,37 @@ class RRGraphBuilder { | |||
t_rr_graph_storage& node_storage(); | |||
/** @brief Return a writable object for update the fast look-up of rr_node */ | |||
RRSpatialLookup& node_lookup(); | |||
/** @brief Return a writable object for rr_node_metadata */ |
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.
Slight modification on the comments
/** @brief Return a writable object for the meta data on the nodes */
@@ -403,6 +405,14 @@ class RRGraphView { | |||
return node_lookup_; | |||
} | |||
|
|||
MetadataStorage<int> rr_node_metadata_data() 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.
Add code comments
@@ -72,8 +72,8 @@ void load_rr_file(const t_graph_type graph_type, | |||
device_ctx.rr_segments, | |||
device_ctx.physical_tile_types, | |||
grid, | |||
&device_ctx.rr_node_metadata, | |||
&device_ctx.rr_edge_metadata, | |||
&device_ctx.rr_graph_builder.rr_node_metadata(), |
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.
It is o.k. here. We may consider to change it later.
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.
Changes are clear. Please start QoR tests.
@Raza-jafari-RS I have merged #1951 Please resolve the merging conflicts here. This PR is almost there. I am waiting for the QoR test results. |
@tangxifan , |
O.K. No problem. |
@Raza-jafari-RS Waiting for QoR test results. Code changes are good. I expect CI to be green soon |
QoR tests are complete and quick summary is given below. QoR comparison files are also attached. vtr_reg_qor_chain_depop test: |
@Raza-jafari-RS Thanks for the input and great work @vaughnbetz I propose to merge this PR as the code changes are clean and QoR results should no degradation. |
Description
In this PR the owner of data structures rr_node_metadata/rr_edge_metadata has been changed from device_ctx to rr_graph_builder.
Related Issue
The metadata is an internal data structure used in rr_graph_builder so it should be part of this class
Motivation and Context
These changes are continuation of reorder_nodes function location change
How Has This Been Tested?
Types of changes
Checklist: