forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][OpenMP][DoConcurrent] Simplify loop-nest detection logic
With llvm#114020, do-concurrent loop-nests are more conforment to the spec and easier to detect. All we need to do is to check that the only operations inside `loop A` which perfectly wraps `loop B` are: * the operations needed to update `loop A`'s iteration variable and * `loop B` itself. This PR simlifies the pass a bit using the above logic and replaces ROCm#127.
- Loading branch information
Showing
3 changed files
with
183 additions
and
141 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
! Tests loop-nest detection algorithm for do-concurrent mapping. | ||
|
||
! REQUIRES: asserts | ||
|
||
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-parallel=host \ | ||
! RUN: -mmlir -debug %s -o - 2> %t.log || true | ||
|
||
! RUN: FileCheck %s < %t.log | ||
|
||
program main | ||
implicit none | ||
|
||
contains | ||
|
||
subroutine foo(n) | ||
implicit none | ||
integer :: n, m | ||
integer :: i, j, k | ||
integer :: x | ||
integer, dimension(n) :: a | ||
integer, dimension(n, n, n) :: b | ||
|
||
! CHECK: Loop pair starting at location | ||
! CHECK: loc("{{.*}}":[[# @LINE + 1]]:{{.*}}) is perfectly nested | ||
do concurrent(i=1:n, j=1:bar(n*m, n/m)) | ||
a(i) = n | ||
end do | ||
|
||
! CHECK: Loop pair starting at location | ||
! CHECK: loc("{{.*}}":[[# @LINE + 1]]:{{.*}}) is perfectly nested | ||
do concurrent(i=bar(n, x):n, j=1:bar(n*m, n/m)) | ||
a(i) = n | ||
end do | ||
|
||
! CHECK: Loop pair starting at location | ||
! CHECK: loc("{{.*}}":[[# @LINE + 1]]:{{.*}}) is not perfectly nested | ||
do concurrent(i=bar(n, x):n) | ||
do concurrent(j=1:bar(n*m, n/m)) | ||
a(i) = n | ||
end do | ||
end do | ||
|
||
! CHECK: Loop pair starting at location | ||
! CHECK: loc("{{.*}}":[[# @LINE + 1]]:{{.*}}) is not perfectly nested | ||
do concurrent(i=1:n) | ||
x = 10 | ||
do concurrent(j=1:m) | ||
b(i,j,k) = i * j + k | ||
end do | ||
end do | ||
|
||
! CHECK: Loop pair starting at location | ||
! CHECK: loc("{{.*}}":[[# @LINE + 1]]:{{.*}}) is not perfectly nested | ||
do concurrent(i=1:n) | ||
do concurrent(j=1:m) | ||
b(i,j,k) = i * j + k | ||
end do | ||
x = 10 | ||
end do | ||
|
||
! CHECK: Loop pair starting at location | ||
! CHECK: loc("{{.*}}":[[# @LINE + 1]]:{{.*}}) is not perfectly nested | ||
do concurrent(i=1:n) | ||
do concurrent(j=1:m) | ||
b(i,j,k) = i * j + k | ||
x = 10 | ||
end do | ||
end do | ||
|
||
! CHECK: Loop pair starting at location | ||
! CHECK: loc("{{.*}}":[[# @LINE + 1]]:{{.*}}) is perfectly nested | ||
do concurrent(i=bar(n, x):n, j=1:bar(n*m, n/m), k=1:bar(n*m, bar(n*m, n/m))) | ||
a(i) = n | ||
end do | ||
|
||
|
||
end subroutine | ||
|
||
pure function bar(n, m) | ||
implicit none | ||
integer, intent(in) :: n, m | ||
integer :: bar | ||
|
||
bar = n + m | ||
end function | ||
|
||
end program main |
Oops, something went wrong.