[flang-commits] [flang] 6d30d94 - [Flang][OpenMP] NFC: Port three tests with minimal changes to HLFIR flow

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Thu Oct 5 09:19:00 PDT 2023


Author: Kiran Chandramohan
Date: 2023-10-05T16:18:21Z
New Revision: 6d30d9458a80e8f5b9823ede4f711a3e66b2430e

URL: https://github.com/llvm/llvm-project/commit/6d30d9458a80e8f5b9823ede4f711a3e66b2430e
DIFF: https://github.com/llvm/llvm-project/commit/6d30d9458a80e8f5b9823ede4f711a3e66b2430e.diff

LOG: [Flang][OpenMP] NFC: Port three tests with minimal changes to HLFIR flow

These are modified versions of tests from flang/test/Lower/OpenMP/FIR.

Added: 
    flang/test/Lower/OpenMP/omp-declare-target-program-var.f90
    flang/test/Lower/OpenMP/ordered-threads.f90
    flang/test/Lower/OpenMP/taskgroup.f90

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/flang/test/Lower/OpenMP/omp-declare-target-program-var.f90 b/flang/test/Lower/OpenMP/omp-declare-target-program-var.f90
new file mode 100644
index 000000000000000..20538ff34871f56
--- /dev/null
+++ b/flang/test/Lower/OpenMP/omp-declare-target-program-var.f90
@@ -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

diff  --git a/flang/test/Lower/OpenMP/ordered-threads.f90 b/flang/test/Lower/OpenMP/ordered-threads.f90
new file mode 100644
index 000000000000000..a3f99129eba7ee1
--- /dev/null
+++ b/flang/test/Lower/OpenMP/ordered-threads.f90
@@ -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

diff  --git a/flang/test/Lower/OpenMP/taskgroup.f90 b/flang/test/Lower/OpenMP/taskgroup.f90
new file mode 100644
index 000000000000000..85dc253b59d6593
--- /dev/null
+++ b/flang/test/Lower/OpenMP/taskgroup.f90
@@ -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


        


More information about the flang-commits mailing list