Files
TheRock/compiler/amd-llvm/flang/test/Lower/OpenACC/acc-loop-collapse-force-non-tightly-nested.f90
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

113 lines
2.9 KiB
Fortran

! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
! Test 1: collapse(force:3) on non-tightly nested loops.
! The inner do k loop should be absorbed by the collapse.
! The prologue (tmp = ...) should be inside the collapsed acc.loop body.
subroutine collapse_force_non_tight(a, n)
implicit none
integer, intent(in) :: n
real, intent(inout) :: a(n, n, n)
integer :: i, j, k
real :: tmp
!$acc parallel loop collapse(force:3) copy(a)
do i = 1, n
do j = 1, n
tmp = real(i + j)
do k = 1, n
a(i, j, k) = tmp + real(k)
end do
end do
end do
!$acc end parallel loop
end subroutine
! CHECK-LABEL: func.func @_QPcollapse_force_non_tight
! CHECK: acc.parallel
! Only one acc.loop with 3 IVs
! CHECK: acc.loop combined(parallel)
! Prologue (tmp = i + j) inside the loop body
! CHECK: arith.addi
! Body assignment inside the loop body
! CHECK: hlfir.designate
! CHECK: hlfir.assign
! CHECK: collapse = [3]
! -----
! Test 2: collapse(force:2) with a non-collapsed inner !$acc loop.
! The do k loop has its own !$acc loop directive and should NOT be
! absorbed by the collapse — it must remain as a separate acc.loop.
subroutine collapse_force_with_inner_acc_loop(a, n)
implicit none
integer, intent(in) :: n
real, intent(inout) :: a(n, n, n)
integer :: i, j, k
!$acc parallel loop collapse(force:2) copy(a)
do i = 1, n
do j = 1, n
!$acc loop
do k = 1, n
a(i, j, k) = real(i + j + k)
end do
end do
end do
!$acc end parallel loop
end subroutine
! CHECK-LABEL: func.func @_QPcollapse_force_with_inner_acc_loop
! CHECK: acc.parallel
! Outer collapsed acc.loop
! CHECK: acc.loop combined(parallel)
! Inner acc.loop for k should remain (not absorbed by collapse)
! CHECK: acc.loop
! CHECK: acc.yield
! Outer has collapse = [2]
! CHECK: collapse = [2]
! -----
! Test 3: collapse(force:3) with statements before an inner !$acc loop.
! The do k loop is absorbed by the collapse (3 IVs), but do l with
! its own !$acc loop directive should remain as a separate acc.loop.
subroutine collapse_force3_with_inner_acc_loop(a, n)
implicit none
integer, intent(in) :: n
real, intent(inout) :: a(n, n, n, n)
integer :: i, j, k, l
real :: tmp
!$acc parallel loop collapse(force:3) copy(a)
do i = 1, n
do j = 1, n
tmp = real(i + j)
do k = 1, n
a(i, j, k, 1) = tmp
!$acc loop
do l = 1, n
a(i, j, k, l) = a(i, j, k, l) + real(l)
end do
end do
end do
end do
!$acc end parallel loop
end subroutine
! CHECK-LABEL: func.func @_QPcollapse_force3_with_inner_acc_loop
! CHECK: acc.parallel
! Outer collapsed acc.loop with 3 IVs
! CHECK: acc.loop combined(parallel)
! Prologue (tmp = i + j) inside the collapsed body
! CHECK: arith.addi
! Statement before inner acc loop (a(i,j,k,1) = tmp)
! CHECK: hlfir.assign
! Inner acc.loop for l should remain
! CHECK: acc.loop
! CHECK: acc.yield
! Outer has collapse = [3]
! CHECK: collapse = [3]