-
Notifications
You must be signed in to change notification settings - Fork 562
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: nodes structure refactoring and elimination of getFlatIdx #5903
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
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]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: bernardo <[email protected]>
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.
I think it is cleaner to go with one of those 2 choices:
- use vector of unique pointers and reference the objects by their pointers.
- the current vector of object but reference by index or object reference.
int getEdgeCost(FlexDPNode* prev_node_idx, | ||
FlexDPNode* 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.
Not idx anymore. Also why not send the object by reference?
int getEdgeCost(FlexDPNode* prev_node_idx, | ||
FlexDPNode* 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
/*either {pin_idx, acc_point_idx} or {inst_idx, acc_pattern_idx} depending on | ||
* context*/ | ||
std::pair<int, int> idx_ = {-1, -1}; | ||
FlexDPNode* prev_node_ = nullptr; |
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.
store prev_node_idx_ instead of pointer to FlexDPNode. safer to avoid memory reallocation causing dangling pointers. (or use vector<vector<unique_ptr>>)
nodes[end_node_Idx].setNodeCost(0); | ||
const int source_node_idx = insts.size() + 1; | ||
nodes[source_node_idx] = std::vector<FlexDPNode>(1); | ||
auto source_node = &(nodes[source_node_idx][0]); |
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& source_node = nodes[source_node_idx][0]
use the object reference instead of pointer
for (int prev_acc_pattern_idx = 0; | ||
prev_acc_pattern_idx < nodes[prev_inst_idx].size(); | ||
prev_acc_pattern_idx++) { | ||
auto prev_node = &(nodes[prev_inst_idx][prev_acc_pattern_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
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.
actually const ref since prev_node is not being edited here.
for (int curr_acc_pattern_idx = 0; | ||
curr_acc_pattern_idx < nodes[curr_inst_idx].size(); | ||
curr_acc_pattern_idx++) { | ||
auto curr_node = &(nodes[curr_inst_idx][curr_acc_pattern_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
auto drain_node = &(nodes[insts.size()][0]); | ||
auto curr_node = drain_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.
ditto
This PR has a secure CI associated with it, is branched from #5901 and is waiting for it to merge.
Nodes structure change
The
nodes
vector has been refactored to be a vector of vectors index by the old "nested id". This allowed for the elimination of thegetFlatIdx()
function, as now the indexing for nodes is always done through both idx.This change impacts various parts of the code as the structure is present in most of the functions that work with Access Patterns.
getEdgeCost refactoring
This PR also contains some minor refactoring on getEdgeCost (both implementations).
The refactoring that does not have to do with the nodes restructuring are:
Do not try to look at changes, it currently has 4 PRs worth of contents, I just want to make it to organize myself and see the public CI.