From 6d30d9458a80e8f5b9823ede4f711a3e66b2430e Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan Date: Thu, 5 Oct 2023 14:31:39 +0000 Subject: [PATCH] [Flang][OpenMP] NFC: Port three tests with minimal changes to HLFIR flow These are modified versions of tests from flang/test/Lower/OpenMP/FIR. --- .../OpenMP/omp-declare-target-program-var.f90 | 13 ++++++++++ flang/test/Lower/OpenMP/ordered-threads.f90 | 25 +++++++++++++++++++ flang/test/Lower/OpenMP/taskgroup.f90 | 20 +++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 flang/test/Lower/OpenMP/omp-declare-target-program-var.f90 create mode 100644 flang/test/Lower/OpenMP/ordered-threads.f90 create mode 100644 flang/test/Lower/OpenMP/taskgroup.f90 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 0000000000000..20538ff34871f --- /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) -> (!fir.ref, !fir.ref) + REAL :: I + ! ALL-DAG: fir.global internal @_QFEi {omp.declare_target = #omp.declaretarget} : 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 0000000000000..a3f99129eba7e --- /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 0000000000000..85dc253b59d65 --- /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) -> (!fir.ref, !fir.ref) +!CHECK: %[[C1:.*]] = arith.constant 1 : i32 + +!CHECK: omp.taskgroup allocate(%[[C1]] : i32 -> %[[ALLOC_X_DECL]]#1 : !fir.ref) +!$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