Files
clang-p2996/flang/test/Transforms/DoConcurrent/not_perfectly_nested.f90
Kareem Ergawy 3f8bfc9f7f [flang][OpenMP] Map simple do concurrent loops to OpenMP host constructs (#127633)
Upstreams one more part of the ROCm `do concurrent` to OpenMP mapping
pass. This PR add support for converting simple loops to the equivalent
OpenMP constructs on the host: `omp parallel do`. Towards that end, we
have to collect more information about loop nests for which we add new
utils in the `looputils` name space.

PR stack:
- https://github.com/llvm/llvm-project/pull/126026
- https://github.com/llvm/llvm-project/pull/127595
- https://github.com/llvm/llvm-project/pull/127633 (this PR)
- https://github.com/llvm/llvm-project/pull/127634
- https://github.com/llvm/llvm-project/pull/127635
2025-04-02 11:26:58 +02:00

46 lines
1.3 KiB
Fortran

! Tests that if `do concurrent` is not perfectly nested in its parent loop, that
! we skip converting the not-perfectly nested `do concurrent` loop.
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=host %s -o - \
! RUN: | FileCheck %s
program main
integer, parameter :: n = 10
integer, parameter :: m = 20
integer, parameter :: l = 30
integer x;
integer :: a(n, m, l)
do concurrent(i=1:n)
x = 10
do concurrent(j=1:m, k=1:l)
a(i,j,k) = i * j + k
end do
end do
end
! CHECK: %[[ORIG_K_ALLOC:.*]] = fir.alloca i32 {bindc_name = "k"}
! CHECK: %[[ORIG_K_DECL:.*]]:2 = hlfir.declare %[[ORIG_K_ALLOC]]
! CHECK: %[[ORIG_J_ALLOC:.*]] = fir.alloca i32 {bindc_name = "j"}
! CHECK: %[[ORIG_J_DECL:.*]]:2 = hlfir.declare %[[ORIG_J_ALLOC]]
! CHECK: omp.parallel {
! CHECK: omp.wsloop {
! CHECK: omp.loop_nest ({{[^[:space:]]+}}) {{.*}} {
! CHECK: fir.do_loop %[[J_IV:.*]] = {{.*}} {
! CHECK: %[[J_IV_CONV:.*]] = fir.convert %[[J_IV]] : (index) -> i32
! CHECK: fir.store %[[J_IV_CONV]] to %[[ORIG_J_DECL]]#0
! CHECK: fir.do_loop %[[K_IV:.*]] = {{.*}} {
! CHECK: %[[K_IV_CONV:.*]] = fir.convert %[[K_IV]] : (index) -> i32
! CHECK: fir.store %[[K_IV_CONV]] to %[[ORIG_K_DECL]]#0
! CHECK: }
! CHECK: }
! CHECK: omp.yield
! CHECK: }
! CHECK: }
! CHECK: omp.terminator
! CHECK: }