Files
TheRock/compiler/amd-llvm/flang/test/Lower/OpenMP/target-scope.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

136 lines
4.9 KiB
Fortran

! This test checks the lowering of OpenMP scope construct inside a target region.
! XFAIL: *
! RUN: bbc -fopenmp -fopenmp-version=52 -emit-hlfir %s -o - | FileCheck %s
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
! Module-level declarations emitted before any function body.
! CHECK: omp.private {type = private} @_QFtarget_scope_allocateEi_private_i32 : i32
! CHECK-LABEL: omp.private {type = firstprivate} @_QFtarget_scope_firstprivateEi_firstprivate_i32 : i32 copy {
! CHECK: fir.load %{{.*}} : !fir.ref<i32>
! CHECK: hlfir.assign %{{.*}} to %{{.*}} : i32, !fir.ref<i32>
! CHECK: omp.yield
! CHECK-LABEL: omp.declare_reduction @add_reduction_i32 : i32 init {
! CHECK: arith.constant 0 : i32
! CHECK: omp.yield
! CHECK-LABEL: } combiner {
! CHECK: arith.addi
! CHECK: omp.yield
! CHECK: omp.private {type = private} @_QFtarget_scope_privateEi_private_i32 : i32
! CHECK-LABEL: func @_QPtarget_scope_basic
subroutine target_scope_basic()
integer :: x
x = 10
!$omp target
! CHECK: omp.map.info var_ptr(%{{.*}} : !fir.ref<i32>, i32)
! CHECK: omp.target map_entries(%{{.*}} -> %[[XARG:.*]] : !fir.ref<i32>) {
! CHECK: hlfir.declare %[[XARG]] {uniq_name = "_QFtarget_scope_basicEx"}
! CHECK: omp.scope {
!$omp scope
x = x + 1
! CHECK: omp.terminator
! CHECK: }
!$omp end scope
!$omp end target
end subroutine
! CHECK-LABEL: func @_QPtarget_scope_nowait
subroutine target_scope_nowait()
integer :: x
x = 10
!$omp target
! CHECK: omp.target map_entries(%{{.*}} -> %[[XARG:.*]] : !fir.ref<i32>) {
! CHECK: hlfir.declare %[[XARG]] {uniq_name = "_QFtarget_scope_nowaitEx"}
! CHECK: omp.scope nowait {
!$omp scope
x = x + 1
! CHECK: omp.terminator
! CHECK: }
!$omp end scope nowait
!$omp end target
end subroutine
! CHECK-LABEL: func @_QPtarget_scope_private
subroutine target_scope_private()
integer :: i
i = 0
!$omp target
! CHECK: omp.target map_entries(%{{.*}} -> %[[IARG:.*]] : !fir.ref<i32>) {
! CHECK: hlfir.declare %[[IARG]] {uniq_name = "_QFtarget_scope_privateEi"}
! CHECK: omp.scope private(@_QFtarget_scope_privateEi_private_i32 %{{.*}}#0 -> %[[PRIV:.*]] : !fir.ref<i32>) {
! CHECK: %[[PDECL:.*]]:2 = hlfir.declare %[[PRIV]] {uniq_name = "_QFtarget_scope_privateEi"}
!$omp scope private(i)
! CHECK: hlfir.assign %{{.*}} to %[[PDECL]]#0 : i32, !fir.ref<i32>
i = 42
! CHECK: omp.terminator
! CHECK: }
!$omp end scope
!$omp end target
end subroutine
! CHECK-LABEL: func @_QPtarget_scope_reduction
subroutine target_scope_reduction()
integer :: sum
sum = 0
!$omp target
! CHECK: omp.target map_entries(%{{.*}} -> %[[SARG:.*]] : !fir.ref<i32>) {
! CHECK: hlfir.declare %[[SARG]] {uniq_name = "_QFtarget_scope_reductionEsum"}
! CHECK: omp.scope reduction(@add_reduction_i32 %{{.*}}#0 -> %[[REDUC:.*]] : !fir.ref<i32>) {
! CHECK: %[[RDECL:.*]]:2 = hlfir.declare %[[REDUC]] {uniq_name = "_QFtarget_scope_reductionEsum"}
!$omp scope reduction(+:sum)
! CHECK: fir.load %[[RDECL]]#0 : !fir.ref<i32>
! CHECK: hlfir.assign %{{.*}} to %[[RDECL]]#0 : i32, !fir.ref<i32>
sum = sum + 1
! CHECK: omp.terminator
! CHECK: }
!$omp end scope
!$omp end target
end subroutine
! CHECK-LABEL: func @_QPtarget_scope_firstprivate
subroutine target_scope_firstprivate()
integer :: i
i = 42
!$omp target
! CHECK: omp.target map_entries(%{{.*}} -> %[[IARG:.*]] : !fir.ref<i32>) {
! CHECK: hlfir.declare %[[IARG]] {uniq_name = "_QFtarget_scope_firstprivateEi"}
! CHECK: omp.scope private(@_QFtarget_scope_firstprivateEi_firstprivate_i32 %{{.*}}#0 -> %[[FP:.*]] : !fir.ref<i32>) {
! CHECK: %[[FPDECL:.*]]:2 = hlfir.declare %[[FP]] {uniq_name = "_QFtarget_scope_firstprivateEi"}
!$omp scope firstprivate(i)
! CHECK: fir.load %[[FPDECL]]#0 : !fir.ref<i32>
! CHECK: hlfir.assign %{{.*}} to %[[FPDECL]]#0 : i32, !fir.ref<i32>
i = i + 1
! CHECK: omp.terminator
! CHECK: }
!$omp end scope
!$omp end target
end subroutine
! CHECK-LABEL: func @_QPtarget_scope_allocate
subroutine target_scope_allocate()
integer :: i
i = 0
!$omp target
! CHECK: omp.target map_entries(%{{.*}} -> %[[IARG:.*]] : !fir.ref<i32>) {
! CHECK: hlfir.declare %[[IARG]] {uniq_name = "_QFtarget_scope_allocateEi"}
! CHECK: omp.scope allocate(%{{.*}} : i32 -> %{{.*}}#0 : !fir.ref<i32>) private(@_QFtarget_scope_allocateEi_private_i32 %{{.*}}#0 -> %[[APRIV:.*]] : !fir.ref<i32>) {
! CHECK: %[[ADECL:.*]]:2 = hlfir.declare %[[APRIV]] {uniq_name = "_QFtarget_scope_allocateEi"}
!$omp scope private(i) allocate(i)
! CHECK: hlfir.assign %{{.*}} to %[[ADECL]]#0 : i32, !fir.ref<i32>
i = 1
! CHECK: omp.terminator
! CHECK: }
!$omp end scope
!$omp end target
end subroutine