-
Notifications
You must be signed in to change notification settings - Fork 551
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
drt: genPatterns_commit refactoring #5872
base: master
Are you sure you want to change the base?
drt: genPatterns_commit refactoring #5872
Conversation
clang-tidy review says "All clean, LGTM! 👍" |
2ebcfdb
to
91a9156
Compare
clang-tidy review says "All clean, LGTM! 👍" |
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.
clang-tidy made some suggestions
b050b9b
to
63dc4f8
Compare
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.
clang-tidy made some suggestions
clang-tidy review says "All clean, LGTM! 👍" |
60ed9ab
to
cc3f2a2
Compare
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
…nction Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
cc3f2a2
to
f7b2789
Compare
clang-tidy review says "All clean, LGTM! 👍" |
leftAP = ap; | ||
leftPt = tmpPt.x(); | ||
} | ||
if (tmpPt.x() > rightPt) { |
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.
Should this be else if
?
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.
nope. Consider the first iteration. we need to set both; leftPt and rightPt, to tmpPt
} | ||
} | ||
if (n_no_ap_pins == inst_term->getTerm()->getPins().size()) { | ||
logger_->error(DRT, 91, "Pin does not have valid ap."); |
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.
Capitalize AP. Also, can you add the term name to the print?
const int drain_node_idx = getFlatIdx(pins.size(), 0, max_access_point_size); | ||
auto drain_node = &(nodes[drain_node_idx]); | ||
int curr_node_idx = drain_node->getPrevNodeIdx(); |
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.
Does "drain" have a special meeting here? I the opposite of source is usually "sink" in these contexts
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 guess sink is the correct word in this context.
@@ -568,6 +568,25 @@ class FlexPA | |||
int curr_unique_inst_idx, | |||
int max_access_point_size); | |||
|
|||
/** | |||
* @brief Extracts the access patterns given the graph nodes composing the | |||
* access points relatioship |
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.
* access points relatioship | |
* access points relationship |
* access points relatioship | ||
* | ||
* @param nodes {pin,access_point} nodes of the access pattern graph | ||
* @param pins vector os pins of the unique instance |
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.
vector of pins?
* @param max_access_point_size number of acc points the instance with most | ||
* acc points has |
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.
* @param max_access_point_size number of acc points the instance with most | |
* acc points has | |
* @param max_access_point_size the maximum number of access points across | |
* all instances |
if (owners.find(inst_term->getNet()) != owners.end()) { | ||
viol_access_points.insert(std::make_pair(idx_1, idx_2)); // idx ; | ||
} | ||
} | ||
if (n_no_ap_pins == inst_term->getTerm()->getPins().size()) { | ||
logger_->error(DRT, 91, "Pin does not have valid ap."); | ||
} | ||
} | ||
pin_access_pattern->setBoundaryAP(true, left_access_point); | ||
pin_access_pattern->setBoundaryAP(false, right_access_point); | ||
|
||
std::set<frBlockObject*> owners; | ||
if (target_obj != nullptr | ||
&& genPatterns_gc({target_obj}, objs, Commit, &owners)) { | ||
pin_access_pattern->updateCost(); | ||
unique_inst_patterns_[curr_unique_inst_idx].push_back( | ||
std::move(pin_access_pattern)); | ||
// genPatterns_print(nodes, pins, max_access_point_size); | ||
is_valid = true; | ||
} else { | ||
for (int idx_1 = 0; idx_1 < (int) pins.size(); idx_1++) { | ||
auto idx_2 = access_pattern[idx_1]; | ||
auto& [pin, inst_term] = pins[idx_1]; | ||
if (inst_term->hasNet()) { | ||
if (owners.find(inst_term->getNet()) != owners.end()) { | ||
viol_access_points.insert(std::make_pair(idx_1, idx_2)); // idx ; | ||
} | ||
} else { | ||
if (owners.find(inst_term) != owners.end()) { | ||
viol_access_points.insert(std::make_pair(idx_1, idx_2)); // idx ; | ||
} | ||
} else { | ||
if (owners.find(inst_term) != owners.end()) { |
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 wonder if there's a more efficient way to do this because this will traverse owners
twice. It might not matter if the else
is rarely exercised or if owners
is small.
|
||
const int source_node_idx = getFlatIdx(-1, 0, max_access_point_size); | ||
const int drain_node_idx = getFlatIdx(pins.size(), 0, max_access_point_size); | ||
auto drain_node = &(nodes[drain_node_idx]); |
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.
auto drain_node = &(nodes[drain_node_idx]); | |
const auto& drain_node = nodes[drain_node_idx]; |
use const reference to the object instead of pointer.
const int drain_node_idx = getFlatIdx(pins.size(), 0, max_access_point_size); | ||
auto drain_node = &(nodes[drain_node_idx]); | ||
int curr_node_idx = drain_node->getPrevNodeIdx(); |
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 guess sink is the correct word in this context.
logger_->error(DRT, 90, "Valid access pattern not found."); | ||
} | ||
|
||
auto curr_node = &(nodes[curr_node_idx]); |
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.
ditto
frAccessPoint* leftAP = nullptr; | ||
frAccessPoint* rightAP = nullptr; | ||
frCoord leftPt = std::numeric_limits<frCoord>::max(); | ||
frCoord rightPt = std::numeric_limits<frCoord>::min(); |
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.
why the renaming? this is not the followed style.
leftAP = ap; | ||
leftPt = tmpPt.x(); | ||
} | ||
if (tmpPt.x() > rightPt) { |
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.
nope. Consider the first iteration. we need to set both; leftPt and rightPt, to tmpPt
Some refactoring on
genPatterns_commit
is being done to improve readability and reduce code.Access Patterns Graph Backwards Path Function and Readability
The first part of
genPatterns_commit
is a loop that traces a path through access points of an instance that represent a chosen access pattern.Right now the loop is a little over complicated for what it does, so I refactored it a bit to make more obvious.
Added the variables
source_node_idx
anddrain_node_idx
to make the start and end points of the path search more clear, instead decreasingpin_cnt
.This was transformed in a function called
extractAccessPatternFromNodes
as it has a pretty distinct role and function.Used Pattern Guard
The later part of the had an if statement to check is the generated pattern was unused, if true it did more checks, later it essentially had an else with
return false
. This as transformed into a guard.No further changes on this function will be done in this PR as the git diff shows everything past the guard as changed due to the indentation level change. Further changes will be at a separate PR.