This reverts commit 04b87e15e40f8857e29ade8321b8b67691545a50. The reasons for reverting is that the following: 1. I still need need to upstream some part of the do concurrent to OpenMP pass from our downstream implementation and taking this in downstream will make things more difficult. 2. I still need to work on a solution for modeling locality specifiers on `hlfir.do_concurrent` ops. I would prefer to do that and merge the entire stack together instead of having a partial solution. After merging the revert I will reopen the origianl PR and keep it updated against main until I finish the above.
90 lines
2.2 KiB
Fortran
90 lines
2.2 KiB
Fortran
! Tests loop-nest detection algorithm for do-concurrent mapping.
|
|
|
|
! REQUIRES: asserts
|
|
|
|
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=host \
|
|
! RUN: -mmlir -debug -mmlir -mlir-disable-threading %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
|
|
|
|
! Verify the (i,j) and (j,k) pairs of loops are detected as perfectly nested.
|
|
!
|
|
! CHECK: Loop pair starting at location
|
|
! CHECK: loc("{{.*}}":[[# @LINE + 3]]:{{.*}}) is perfectly nested
|
|
! 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
|