-
Notifications
You must be signed in to change notification settings - Fork 277
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
[DependenceAnalysis] Check memref dependencies on each loop nest #5287
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.
Just some quick questions, but this general approach makes sense to me. Do you mind adding a test case that exhibits the problem and passes with this patch?
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 a few more minor nits but this looks good to me after those are addressed and/or comments added.
The test I added is a copy loop. We see that the store and load on
|
Is this because now it's only calling checkMemrefAccessDependence for the memory ops within a single loop? I guess maybe it needs to check across loops, but at the proper depth? Maybe we should revisit how this utility is used upstream and double check we are doing the right thing. For example, some of the Affine analyses use it: https://github.com/llvm/llvm-project/blob/0442d08fdb173d89b0779d32eb929957a344f5e6/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp#L186 |
I think I get something closer to the correct solution when I in addition collect all the Ops across loop nests together and This adds the missing dependence on
Calling I don't get why the code can find the distance of 3, if its checking a depth of 0. So my naive attempt at just checking across loops did not work completely.
Is the proper depth for a src and dst in different nestings ever greater than 0? Maybe the |
What if I revert all the changes to // Look for inter-iteration dependences on the same memory location.
MemRefAccess src(source);
MemRefAccess dst(destination);
FlatAffineValueConstraints dependenceConstraints;
SmallVector<DependenceComponent, 2> depComps;
// matth2k: Request depth might not be valid (i.e. they only share a partial loop nesting together)
if (depth >
getInnermostCommonLoopDepth(SmallVector({source, destination})))
continue;
DependenceResult result = checkMemrefAccessDependence(
src, dst, depth, &dependenceConstraints, &depComps, true);
results[destination].emplace_back(source, result.value, depComps); Doing this gives the following result:
It also passes all the previous tests. |
I think this sounds reasonable as well. I've been out on vacation and I still need to take a look at how the upstream tools are expected to work, but I think this makes sense. |
Alright, I made those changes. If you think they make sense, I can merge them in. |
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.
Awesome, I like this solution. Thanks for digging into the tools and understanding them enough to propose this.
This my attempt at fixing #5284 and #4814.