Skip to content

Commit 6d30d94

Browse files
[Flang][OpenMP] NFC: Port three tests with minimal changes to HLFIR flow
These are modified versions of tests from flang/test/Lower/OpenMP/FIR.
1 parent bd7ca98 commit 6d30d94

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes=HOST,ALL
2+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=ALL
3+
4+
PROGRAM main
5+
! HOST-DAG: %[[I_REF:.*]] = fir.alloca f32 {bindc_name = "i", uniq_name = "_QFEi"}
6+
! HOST-DAG: %[[I_DECL:.*]]:2 = hlfir.declare %[[I_REF]] {uniq_name = "_QFEi"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
7+
REAL :: I
8+
! ALL-DAG: fir.global internal @_QFEi {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : f32 {
9+
! ALL-DAG: %[[UNDEF:.*]] = fir.undefined f32
10+
! ALL-DAG: fir.has_value %[[UNDEF]] : f32
11+
! ALL-DAG: }
12+
!$omp declare target(I)
13+
END
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
! This test checks lowering of OpenMP ordered directive with threads Clause.
2+
! Without clause in ordered direcitve, it behaves as if threads clause is
3+
! specified.
4+
5+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
6+
7+
subroutine ordered
8+
integer :: i
9+
integer :: a(20)
10+
11+
!CHECK: omp.ordered_region {
12+
!$OMP ORDERED
13+
a(i) = a(i-1) + 1
14+
!CHECK: omp.terminator
15+
!CHECK-NEXT: }
16+
!$OMP END ORDERED
17+
18+
!CHECK: omp.ordered_region {
19+
!$OMP ORDERED THREADS
20+
a(i) = a(i-1) + 1
21+
!CHECK: omp.terminator
22+
!CHECK-NEXT: }
23+
!$OMP END ORDERED
24+
25+
end

flang/test/Lower/OpenMP/taskgroup.f90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
3+
!CHECK-LABEL: @_QPomp_taskgroup
4+
subroutine omp_taskgroup
5+
use omp_lib
6+
integer :: allocated_x
7+
!CHECK: %[[ALLOC_X_REF:.*]] = fir.alloca i32 {bindc_name = "allocated_x", uniq_name = "_QFomp_taskgroupEallocated_x"}
8+
!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>)
9+
!CHECK: %[[C1:.*]] = arith.constant 1 : i32
10+
11+
!CHECK: omp.taskgroup allocate(%[[C1]] : i32 -> %[[ALLOC_X_DECL]]#1 : !fir.ref<i32>)
12+
!$omp taskgroup allocate(omp_high_bw_mem_alloc: allocated_x)
13+
!$omp task
14+
!CHECK: fir.call @_QPwork() {{.*}}: () -> ()
15+
call work()
16+
!CHECK: omp.terminator
17+
!$omp end task
18+
!CHECK: omp.terminator
19+
!$omp end taskgroup
20+
end subroutine

0 commit comments

Comments
 (0)