Skip to content

Commit

Permalink
[Flang][OpenMP] NFC: Port three tests with minimal changes to HLFIR flow
Browse files Browse the repository at this point in the history
These are modified versions of tests from flang/test/Lower/OpenMP/FIR.
  • Loading branch information
kiranchandramohan committed Oct 5, 2023
1 parent bd7ca98 commit 6d30d94
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
13 changes: 13 additions & 0 deletions flang/test/Lower/OpenMP/omp-declare-target-program-var.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes=HOST,ALL
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=ALL

PROGRAM main
! HOST-DAG: %[[I_REF:.*]] = fir.alloca f32 {bindc_name = "i", uniq_name = "_QFEi"}
! HOST-DAG: %[[I_DECL:.*]]:2 = hlfir.declare %[[I_REF]] {uniq_name = "_QFEi"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
REAL :: I
! ALL-DAG: fir.global internal @_QFEi {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : f32 {
! ALL-DAG: %[[UNDEF:.*]] = fir.undefined f32
! ALL-DAG: fir.has_value %[[UNDEF]] : f32
! ALL-DAG: }
!$omp declare target(I)
END
25 changes: 25 additions & 0 deletions flang/test/Lower/OpenMP/ordered-threads.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
! This test checks lowering of OpenMP ordered directive with threads Clause.
! Without clause in ordered direcitve, it behaves as if threads clause is
! specified.

!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s

subroutine ordered
integer :: i
integer :: a(20)

!CHECK: omp.ordered_region {
!$OMP ORDERED
a(i) = a(i-1) + 1
!CHECK: omp.terminator
!CHECK-NEXT: }
!$OMP END ORDERED

!CHECK: omp.ordered_region {
!$OMP ORDERED THREADS
a(i) = a(i-1) + 1
!CHECK: omp.terminator
!CHECK-NEXT: }
!$OMP END ORDERED

end
20 changes: 20 additions & 0 deletions flang/test/Lower/OpenMP/taskgroup.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s

!CHECK-LABEL: @_QPomp_taskgroup
subroutine omp_taskgroup
use omp_lib
integer :: allocated_x
!CHECK: %[[ALLOC_X_REF:.*]] = fir.alloca i32 {bindc_name = "allocated_x", uniq_name = "_QFomp_taskgroupEallocated_x"}
!CHECK-NEXT: %[[ALLOC_X_DECL:.*]]:2 = hlfir.declare %[[ALLOC_X_REF]] {uniq_name = "_QFomp_taskgroupEallocated_x"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
!CHECK: %[[C1:.*]] = arith.constant 1 : i32

!CHECK: omp.taskgroup allocate(%[[C1]] : i32 -> %[[ALLOC_X_DECL]]#1 : !fir.ref<i32>)
!$omp taskgroup allocate(omp_high_bw_mem_alloc: allocated_x)
!$omp task
!CHECK: fir.call @_QPwork() {{.*}}: () -> ()
call work()
!CHECK: omp.terminator
!$omp end task
!CHECK: omp.terminator
!$omp end taskgroup
end subroutine

0 comments on commit 6d30d94

Please sign in to comment.