Upstreams the next part of do concurrent to OpenMP mapping pass (from AMD's ROCm implementation). See https://github.com/llvm/llvm-project/pull/126026 for more context. This PR add loop nest detection logic. This enables us to discover muli-range do concurrent loops and then map them as "collapsed" loop nests to OpenMP. This is a follow up for https://github.com/llvm/llvm-project/pull/126026, only the latest commit is relevant. This is a replacement for https://github.com/llvm/llvm-project/pull/127478 using a `/user/<username>/<branchname>` branch. PR stack: - https://github.com/llvm/llvm-project/pull/126026 - https://github.com/llvm/llvm-project/pull/127595 (this PR) - https://github.com/llvm/llvm-project/pull/127633 - https://github.com/llvm/llvm-project/pull/127634 - https://github.com/llvm/llvm-project/pull/127635
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 %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
|