-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL-MLIR][DetectReduction] Disallow transformation when exists may alias operations in loop #9055
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
Merged
whitneywhtsang
merged 4 commits into
intel:sycl-mlir
from
whitneywhtsang:detectreduction_mayalias
Apr 28, 2023
Merged
[SYCL-MLIR][DetectReduction] Disallow transformation when exists may alias operations in loop #9055
whitneywhtsang
merged 4 commits into
intel:sycl-mlir
from
whitneywhtsang:detectreduction_mayalias
Apr 28, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
whitneywhtsang
commented
Apr 13, 2023
polygeist/test/polygeist-opt/sycl/matrix_multiply_reduction.mlir
Outdated
Show resolved
Hide resolved
8fc8a97
to
b8a1a3a
Compare
Plan to merge this PR after implementing a fix. But please still review it. |
sommerlukas
reviewed
Apr 13, 2023
etiotto
reviewed
Apr 13, 2023
polygeist/tools/cgeist/Test/polybench/linear-algebra/kernels/2mm/2mm.c
Outdated
Show resolved
Hide resolved
etiotto
reviewed
Apr 13, 2023
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 from commit 3f4755e looks fine to me.
439294f
to
6b9615b
Compare
sommerlukas
approved these changes
Apr 14, 2023
28fc12b
to
944b69f
Compare
944b69f
to
8c7f199
Compare
whitneywhtsang
added a commit
that referenced
this pull request
Apr 26, 2023
Verified that with this PR and `-D__SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING__`, SYCL-MLIR is able to perform scalar replacement on reduction loop on the SYCL-Bench workloads identified before, even with the fix in #9055. O3 | Previously measured gains | Only PR9187 | PR9187+PR9055 -- | -- | -- | -- 2mm | 12% | 12% | 12% 3mm | 13% | 12% | 11% covariance | 50% | 50% | 0% gemm | 12% | 12% | 11% gramschmidt | 14% + 18% (LICM versioning) | 33% | 33% syrk | 5% | 5% | 5% => No performance regressions with just this PR. => Lost `covariance` 50% gain after specializing the function, because 2 of the 3 accessors actually overlap! ``` auto data = data_buffer.get_access<access::mode::read>(cgh); auto symmat = symmat_buffer.get_access<access::mode::discard_write>(cgh); auto symmat2 = symmat_buffer.get_access<access::mode::discard_write>(cgh); ``` Not sure why it is written that way, with the simple source code change below (which remove `symmat2` and always use `symmat`), the 50% gain is recovered. ``` +++ b/polybench/covariance.cpp @@ -110,7 +110,6 @@ public: - auto symmat2 = symmat_buffer.get_access<access::mode::discard_write>(cgh); @@ -122,7 +121,7 @@ public: - symmat2[{j2, j1}] = symmat[{j1, j2}]; + symmat[{j2, j1}] = symmat[{j1, j2}]; ``` If we want to get the gain without source code change, then we need to version by only checking if `symmat` and `data` overlap, which we need the context, we may want to perform loop versioning in detect reduction pass. Notice the inner loop with the opportunity doesn't use `symmat2`: ``` for(size_t i = 1; i <= N_; i++) symmat[{j1, j2}] += data[{i, j1}] * data[{i, j2}]; ``` Note: A number of KernelFusion test cases are moved to xfail, as accessors cannot be internalize when they are used by a ptrtoint operation. (#9188) --------- Signed-off-by: Tsang, Whitney <whitney.tsang@intel.com>
24e2b6a
to
ce4242c
Compare
…e are may alias operations in loop Signed-off-by: Tsang, Whitney <whitney.tsang@intel.com>
Signed-off-by: Tsang, Whitney <whitney.tsang@intel.com>
Signed-off-by: Tsang, Whitney <whitney.tsang@intel.com>
ce4242c
to
b6bffe8
Compare
etiotto
approved these changes
Apr 27, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original loop:
Optimized loop:
This is incorrect if A and B may alias because
B[i]
may be different after updatingA[0]
.