[flang-commits] [flang] d338acf - [Flang][OpenMP] NFC: Version of a few tests with HLFIR
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Wed Sep 27 05:01:18 PDT 2023
Author: Kiran Chandramohan
Date: 2023-09-27T12:00:53Z
New Revision: d338acf36edd9718845c3e079d2d2fc1f4c62d36
URL: https://github.com/llvm/llvm-project/commit/d338acf36edd9718845c3e079d2d2fc1f4c62d36
DIFF: https://github.com/llvm/llvm-project/commit/d338acf36edd9718845c3e079d2d2fc1f4c62d36.diff
LOG: [Flang][OpenMP] NFC: Version of a few tests with HLFIR
These are versions of tests from flang/test/Lower/OpenMP/FIR.
Added:
flang/test/Lower/OpenMP/lastprivate-commonblock.f90
flang/test/Lower/OpenMP/location.f90
flang/test/Lower/OpenMP/loop-combined.f90
Modified:
Removed:
################################################################################
diff --git a/flang/test/Lower/OpenMP/lastprivate-commonblock.f90 b/flang/test/Lower/OpenMP/lastprivate-commonblock.f90
new file mode 100644
index 000000000000000..15b76bb7bc4eebd
--- /dev/null
+++ b/flang/test/Lower/OpenMP/lastprivate-commonblock.f90
@@ -0,0 +1,35 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
+
+!CHECK: fir.global common @[[CB_C:.*]](dense<0> : vector<8xi8>) : !fir.array<8xi8>
+!CHECK-LABEL: func.func @_QPlastprivate_common
+!CHECK: %[[CB_C_REF:.*]] = fir.address_of(@[[CB_C]]) : !fir.ref<!fir.array<8xi8>>
+!CHECK: %[[CB_C_REF_CVT:.*]] = fir.convert %[[CB_C_REF]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
+!CHECK: %[[CB_C_X_COOR:.*]] = fir.coordinate_of %[[CB_C_REF_CVT]], %{{.*}} : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
+!CHECK: %[[CB_C_X_ADDR:.*]] = fir.convert %[[CB_C_X_COOR]] : (!fir.ref<i8>) -> !fir.ref<f32>
+!CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[CB_C_X_ADDR]] {uniq_name = "_QFlastprivate_commonEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+!CHECK: %[[CB_C_REF_CVT:.*]] = fir.convert %[[CB_C_REF]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
+!CHECK: %[[CB_C_Y_COOR:.*]] = fir.coordinate_of %[[CB_C_REF_CVT]], %{{.*}} : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
+!CHECK: %[[CB_C_Y_ADDR:.*]] = fir.convert %[[CB_C_Y_COOR]] : (!fir.ref<i8>) -> !fir.ref<f32>
+!CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %[[CB_C_Y_ADDR]] {uniq_name = "_QFlastprivate_commonEy"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+!CHECK: %[[PRIVATE_X_REF:.*]] = fir.alloca f32 {bindc_name = "x", pinned, uniq_name = "_QFlastprivate_commonEx"}
+!CHECK: %[[PRIVATE_X_DECL:.*]]:2 = hlfir.declare %[[PRIVATE_X_REF]] {uniq_name = "_QFlastprivate_commonEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+!CHECK: %[[PRIVATE_Y_REF:.*]] = fir.alloca f32 {bindc_name = "y", pinned, uniq_name = "_QFlastprivate_commonEy"}
+!CHECK: %[[PRIVATE_Y_DECL:.*]]:2 = hlfir.declare %[[PRIVATE_Y_REF]] {uniq_name = "_QFlastprivate_commonEy"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+!CHECK: omp.wsloop for (%[[I:.*]]) : i32 = (%{{.*}}) to (%{{.*}}) inclusive step (%{{.*}}) {
+!CHECK: %[[LAST_ITER:.*]] = arith.cmpi eq, %[[I]], %{{.*}} : i32
+!CHECK: fir.if %[[LAST_ITER]] {
+!CHECK: %[[PRIVATE_X_VAL:.*]] = fir.load %[[PRIVATE_X_DECL]]#1 : !fir.ref<f32>
+!CHECK: fir.store %[[PRIVATE_X_VAL]] to %[[X_DECL]]#1 : !fir.ref<f32>
+!CHECK: %[[PRIVATE_Y_VAL:.*]] = fir.load %[[PRIVATE_Y_DECL]]#1 : !fir.ref<f32>
+!CHECK: fir.store %[[PRIVATE_Y_VAL]] to %[[Y_DECL]]#1 : !fir.ref<f32>
+!CHECK: }
+!CHECK: omp.yield
+!CHECK: }
+subroutine lastprivate_common
+ common /c/ x, y
+ real x, y
+ !$omp do lastprivate(/c/)
+ do i=1,100
+ end do
+ !$omp end do
+end subroutine
diff --git a/flang/test/Lower/OpenMP/location.f90 b/flang/test/Lower/OpenMP/location.f90
new file mode 100644
index 000000000000000..c87bf038e967215
--- /dev/null
+++ b/flang/test/Lower/OpenMP/location.f90
@@ -0,0 +1,68 @@
+! This test checks location of OpenMP constructs and clauses
+
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --mlir-print-debuginfo %s -o - | FileCheck %s
+
+!CHECK-LABEL: sub_parallel
+subroutine sub_parallel()
+ print *, x
+!CHECK: omp.parallel {
+ !$omp parallel
+ print *, x
+!CHECK: omp.terminator loc(#[[PAR_LOC:.*]])
+!CHECK: } loc(#[[PAR_LOC]])
+ !$omp end parallel
+ print *, x
+end
+
+!CHECK-LABEL: sub_target
+subroutine sub_target()
+ print *, x
+!CHECK: omp.target {
+ !$omp target
+ print *, x
+!CHECK: omp.terminator loc(#[[TAR_LOC:.*]])
+!CHECK: } loc(#[[TAR_LOC]])
+ !$omp end target
+ print *, x
+end
+
+!CHECK-LABEL: sub_loop
+subroutine sub_loop()
+!CHECK: omp.wsloop {{.*}} {
+ !$omp do
+ do i=1,10
+ print *, i
+!CHECK: omp.yield loc(#[[LOOP_LOC:.*]])
+!CHECK: } loc(#[[LOOP_LOC]])
+ end do
+ !$omp end do
+end
+
+!CHECK-LABEL: sub_standalone
+subroutine sub_standalone()
+ !CHECK: omp.barrier loc(#[[BAR_LOC:.*]])
+ !$omp barrier
+ !CHECK: omp.taskwait loc(#[[TW_LOC:.*]])
+ !$omp taskwait
+ !CHECK: omp.taskyield loc(#[[TY_LOC:.*]])
+ !$omp taskyield
+end
+
+subroutine sub_if(c)
+ logical(kind=4) :: c
+ !CHECK: %[[CVT:.*]] = fir.convert %{{.*}} : (!fir.logical<4>) -> i1 loc(#[[IF_LOC:.*]])
+ !CHECK: omp.task if(%[[CVT]])
+ !$omp task if(c)
+ print *, "Task"
+ !$omp end task
+ !CHECK: } loc(#[[TASK_LOC:.*]])
+end subroutine
+
+!CHECK: #[[PAR_LOC]] = loc("{{.*}}location.f90":9:9)
+!CHECK: #[[TAR_LOC]] = loc("{{.*}}location.f90":21:9)
+!CHECK: #[[LOOP_LOC]] = loc("{{.*}}location.f90":32:9)
+!CHECK: #[[BAR_LOC]] = loc("{{.*}}location.f90":44:9)
+!CHECK: #[[TW_LOC]] = loc("{{.*}}location.f90":46:9)
+!CHECK: #[[TY_LOC]] = loc("{{.*}}location.f90":48:9)
+!CHECK: #[[IF_LOC]] = loc("{{.*}}location.f90":55:14)
+!CHECK: #[[TASK_LOC]] = loc("{{.*}}location.f90":55:9)
diff --git a/flang/test/Lower/OpenMP/loop-combined.f90 b/flang/test/Lower/OpenMP/loop-combined.f90
new file mode 100644
index 000000000000000..960e9518127d756
--- /dev/null
+++ b/flang/test/Lower/OpenMP/loop-combined.f90
@@ -0,0 +1,83 @@
+! This test checks lowering of OpenMP combined loop constructs.
+
+! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s
+
+program main
+ integer :: i
+
+ ! TODO When DISTRIBUTE, TASKLOOP and TEAMS are supported add:
+ ! - DISTRIBUTE PARALLEL DO SIMD
+ ! - DISTRIBUTE PARALLEL DO
+ ! - DISTRIBUTE SIMD
+ ! - TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! - TARGET TEAMS DISTRIBUTE PARALLEL DO
+ ! - TARGET TEAMS DISTRIBUTE SIMD
+ ! - TARGET TEAMS DISTRIBUTE
+ ! - TASKLOOP SIMD
+ ! - TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! - TEAMS DISTRIBUTE PARALLEL DO
+ ! - TEAMS DISTRIBUTE SIMD
+ ! - TEAMS DISTRIBUTE
+
+ ! ----------------------------------------------------------------------------
+ ! DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.simdloop
+ !$omp do simd
+ do i = 1, 10
+ end do
+ !$omp end do simd
+
+ ! ----------------------------------------------------------------------------
+ ! PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.parallel
+ ! CHECK: omp.simdloop
+ !$omp parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.parallel
+ ! CHECK: omp.wsloop
+ !$omp parallel do
+ do i = 1, 10
+ end do
+ !$omp end parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK: omp.parallel
+ ! CHECK: omp.simdloop
+ !$omp target parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end target parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK: omp.parallel
+ ! CHECK: omp.wsloop
+ !$omp target parallel do
+ do i = 1, 10
+ end do
+ !$omp end target parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK: omp.simdloop
+ !$omp target simd
+ do i = 1, 10
+ end do
+ !$omp end target simd
+end program main
More information about the flang-commits
mailing list