Skip to content

[SYCL-MLIR][DetectReduction] Version loop to check for non-overlapping accessors #9221

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

Conversation

whitneywhtsang
Copy link
Contributor

@whitneywhtsang whitneywhtsang commented Apr 26, 2023

There can be other operations in a loop that may alias with the detect reduction candidate.
In order to perform detect reduction safely in those situation, loop versioning is required.

Original loop:

for(size_t i = 0; i < 8; ++i)
  A[0] += B[i];

Optimized loop:

if (&A[A.get_range()] <= &B[0] || &A[0] >= &B[B.get_range()]) {
  a = A[0];
  for(size_t i = 0; i < 8; i++) 
    a += B[i];
  A[0] = a;
} else 
  for(size_t i = 0; i < 8; i++) 
    A[0] += B[i];

The design used for DetectReduction in this PR is very similar to LICM, will work on a better design for both loop versioning in a different PR.

@whitneywhtsang whitneywhtsang added the sycl-mlir Pull requests or issues for sycl-mlir branch label Apr 26, 2023
@whitneywhtsang whitneywhtsang self-assigned this Apr 26, 2023
@whitneywhtsang whitneywhtsang force-pushed the detectreduction_loopversioning branch 3 times, most recently from 8bc2135 to 5d75e33 Compare April 26, 2023 19:15
@whitneywhtsang whitneywhtsang force-pushed the detectreduction_loopversioning branch 7 times, most recently from 5be4428 to b4a1509 Compare April 28, 2023 02:24
@whitneywhtsang whitneywhtsang marked this pull request as ready for review April 28, 2023 02:33
@whitneywhtsang whitneywhtsang force-pushed the detectreduction_loopversioning branch from 463dc16 to ed99093 Compare April 28, 2023 13:09
@whitneywhtsang whitneywhtsang force-pushed the detectreduction_loopversioning branch from ed99093 to 14fed70 Compare April 28, 2023 13:25
…sors

Signed-off-by: Tsang, Whitney <whitney.tsang@intel.com>
Signed-off-by: Tsang, Whitney <whitney.tsang@intel.com>
@whitneywhtsang whitneywhtsang force-pushed the detectreduction_loopversioning branch from 14fed70 to ec18136 Compare April 28, 2023 15:16
@whitneywhtsang whitneywhtsang merged commit 50c5bd0 into intel:sycl-mlir Apr 28, 2023
@whitneywhtsang whitneywhtsang deleted the detectreduction_loopversioning branch April 28, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sycl-mlir Pull requests or issues for sycl-mlir branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants