[flang-commits] [flang] 09b30f4 - [Flang][OpenMP] NFC: Copy a few tests that do not change with HLFIR lowering
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Tue Oct 3 08:33:34 PDT 2023
Author: Kiran Chandramohan
Date: 2023-10-03T15:29:05Z
New Revision: 09b30f409069d296dad467433c60e7c8d431626b
URL: https://github.com/llvm/llvm-project/commit/09b30f409069d296dad467433c60e7c8d431626b
DIFF: https://github.com/llvm/llvm-project/commit/09b30f409069d296dad467433c60e7c8d431626b.diff
LOG: [Flang][OpenMP] NFC: Copy a few tests that do not change with HLFIR lowering
These are version of tests with the same name in flang/test/Lower/OpenMP/FIR.
Added:
flang/test/Lower/OpenMP/if-clause.f90
flang/test/Lower/OpenMP/is-device.f90
flang/test/Lower/OpenMP/omp-is-gpu.f90
flang/test/Lower/OpenMP/requires-common.f90
flang/test/Lower/OpenMP/requires-notarget.f90
flang/test/Lower/OpenMP/requires.f90
flang/test/Lower/OpenMP/rtl-flags.f90
flang/test/Lower/OpenMP/target_cpu_features.f90
flang/test/Lower/OpenMP/taskwait.f90
flang/test/Lower/OpenMP/taskyield.f90
flang/test/Lower/OpenMP/teams.f90
Modified:
Removed:
################################################################################
diff --git a/flang/test/Lower/OpenMP/if-clause.f90 b/flang/test/Lower/OpenMP/if-clause.f90
new file mode 100644
index 000000000000000..032009add31535f
--- /dev/null
+++ b/flang/test/Lower/OpenMP/if-clause.f90
@@ -0,0 +1,505 @@
+! This test checks lowering of OpenMP IF clauses.
+
+! 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 they are supported, add tests for:
+ ! - DISTRIBUTE PARALLEL DO
+ ! - DISTRIBUTE PARALLEL DO SIMD
+ ! - DISTRIBUTE SIMD
+ ! - PARALLEL SECTIONS
+ ! - PARALLEL WORKSHARE
+ ! - TARGET PARALLEL
+ ! - TARGET TEAMS DISTRIBUTE
+ ! - TARGET TEAMS DISTRIBUTE PARALLEL DO
+ ! - TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! - TARGET TEAMS DISTRIBUTE SIMD
+ ! - TARGET UPDATE
+ ! - TASKLOOP
+ ! - TASKLOOP SIMD
+ ! - TEAMS DISTRIBUTE
+ ! - TEAMS DISTRIBUTE PARALLEL DO
+ ! - TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! - TEAMS DISTRIBUTE SIMD
+
+ ! ----------------------------------------------------------------------------
+ ! DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp do simd
+ do i = 1, 10
+ end do
+ !$omp end do simd
+
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end do simd
+
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp do simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end do simd
+
+ ! ----------------------------------------------------------------------------
+ ! PARALLEL
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp parallel
+ i = 10
+ !$omp end parallel
+
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp parallel if(.true.)
+ i = 10
+ !$omp end parallel
+
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp parallel if(parallel: .true.)
+ i = 10
+ !$omp end parallel
+
+ ! ----------------------------------------------------------------------------
+ ! PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp parallel do
+ do i = 1, 10
+ end do
+ !$omp end parallel do
+
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp parallel do if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end parallel do
+
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp parallel do if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end parallel do simd
+
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp parallel do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end parallel do simd
+
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp parallel do simd if(parallel: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end parallel do simd
+
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp parallel do simd if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end parallel do simd
+
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp parallel do simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp simd
+ do i = 1, 10
+ end do
+ !$omp end simd
+
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end simd
+
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target
+ !$omp end target
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ !$omp target if(.true.)
+ !$omp end target
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ !$omp target if(target: .true.)
+ !$omp end target
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET DATA
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target_data
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target data map(tofrom: i)
+ !$omp end target data
+
+ ! CHECK: omp.target_data
+ ! CHECK-SAME: if({{.*}})
+ !$omp target data map(tofrom: i) if(.true.)
+ !$omp end target data
+
+ ! CHECK: omp.target_data
+ ! CHECK-SAME: if({{.*}})
+ !$omp target data map(tofrom: i) if(target data: .true.)
+ !$omp end target data
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET ENTER DATA
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target_enter_data
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: map
+ !$omp target enter data map(to: i)
+
+ ! CHECK: omp.target_enter_data
+ ! CHECK-SAME: if({{.*}})
+ !$omp target enter data map(to: i) if(.true.)
+
+ ! CHECK: omp.target_enter_data
+ ! CHECK-SAME: if({{.*}})
+ !$omp target enter data map(to: i) if(target enter data: .true.)
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET EXIT DATA
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target_exit_data
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: map
+ !$omp target exit data map(from: i)
+
+ ! CHECK: omp.target_exit_data
+ ! CHECK-SAME: if({{.*}})
+ !$omp target exit data map(from: i) if(.true.)
+
+ ! CHECK: omp.target_exit_data
+ ! CHECK-SAME: if({{.*}})
+ !$omp target exit data map(from: i) if(target exit data: .true.)
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target parallel do
+ do i = 1, 10
+ end do
+ !$omp end target parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel do if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel do if(target: .true.) if(parallel: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target parallel do if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target parallel do
+
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel do if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end target parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel do simd if(target: .true.) if(parallel: .false.) &
+ !$omp& if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target parallel do simd if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel do simd if(parallel: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target simd
+ do i = 1, 10
+ end do
+ !$omp end target simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target simd if(target: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target simd if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(.true.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(target: .true.) if(teams: .false.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams if(target: .true.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(teams: .true.)
+ i = 1
+ !$omp end target teams
+
+ ! ----------------------------------------------------------------------------
+ ! TASK
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.task
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp task
+ !$omp end task
+
+ ! CHECK: omp.task
+ ! CHECK-SAME: if({{.*}})
+ !$omp task if(.true.)
+ !$omp end task
+
+ ! CHECK: omp.task
+ ! CHECK-SAME: if({{.*}})
+ !$omp task if(task: .true.)
+ !$omp end task
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams
+ i = 1
+ !$omp end teams
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams if(.true.)
+ i = 1
+ !$omp end teams
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams if(teams: .true.)
+ i = 1
+ !$omp end teams
+end program main
diff --git a/flang/test/Lower/OpenMP/is-device.f90 b/flang/test/Lower/OpenMP/is-device.f90
new file mode 100644
index 000000000000000..9df02d66d064936
--- /dev/null
+++ b/flang/test/Lower/OpenMP/is-device.f90
@@ -0,0 +1,14 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefix=HOST
+!RUN: %flang_fc1 -emit-hlfir -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE-FLAG-ONLY
+!RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir -o - %s | FileCheck %s --check-prefix=DEVICE
+!RUN: bbc -fopenmp -emit-hlfir -o - %s | FileCheck %s --check-prefix=HOST
+!RUN: bbc -fopenmp-is-target-device -emit-hlfir -o - %s | FileCheck %s --check-prefix=DEVICE-FLAG-ONLY
+
+!DEVICE: module attributes {{{.*}}, omp.is_target_device = true{{.*}}}
+!HOST: module attributes {{{.*}}, omp.is_target_device = false{{.*}}}
+!DEVICE-FLAG-ONLY: module attributes {{{.*}}"
+!DEVICE-FLAG-ONLY-NOT: , omp.is_target_device = {{.*}}
+!DEVICE-FLAG-ONLY-SAME: }
+subroutine omp_subroutine()
+end subroutine omp_subroutine
diff --git a/flang/test/Lower/OpenMP/omp-is-gpu.f90 b/flang/test/Lower/OpenMP/omp-is-gpu.f90
new file mode 100644
index 000000000000000..12d0e4e869fba5a
--- /dev/null
+++ b/flang/test/Lower/OpenMP/omp-is-gpu.f90
@@ -0,0 +1,14 @@
+!REQUIRES: amdgpu-registered-target
+
+!RUN: %flang_fc1 -triple amdgcn-amd-amdhsa -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+!RUN: bbc -fopenmp -fopenmp-is-target-device -fopenmp-is-gpu -emit-hlfir -o - %s | FileCheck %s
+
+!RUN: not %flang_fc1 -triple amdgcn-amd-amdhsa -emit-hlfir -fopenmp %s -o - 2>&1 | FileCheck %s --check-prefix=FLANG-ERROR
+!RUN: not bbc -fopenmp -fopenmp-is-gpu -emit-hlfir %s -o - 2>&1 | FileCheck %s --check-prefix=BBC-ERROR
+
+!CHECK: module attributes {{{.*}}omp.is_gpu = true
+subroutine omp_subroutine()
+end subroutine omp_subroutine
+
+!FLANG-ERROR: error: OpenMP AMDGPU/NVPTX is only prepared to deal with device code.
+!BBC-ERROR: FATAL: -fopenmp-is-gpu can only be set if -fopenmp-is-target-device is also set
diff --git a/flang/test/Lower/OpenMP/requires-common.f90 b/flang/test/Lower/OpenMP/requires-common.f90
new file mode 100644
index 000000000000000..b3801a834014f7a
--- /dev/null
+++ b/flang/test/Lower/OpenMP/requires-common.f90
@@ -0,0 +1,19 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck %s
+
+! This test checks the lowering of requires into MLIR
+
+!CHECK: module attributes {
+!CHECK-SAME: omp.requires = #omp<clause_requires unified_shared_memory>
+block data init
+ !$omp requires unified_shared_memory
+ integer :: x
+ common /block/ x
+ data x / 10 /
+end
+
+subroutine f
+ !$omp declare target
+end subroutine f
diff --git a/flang/test/Lower/OpenMP/requires-notarget.f90 b/flang/test/Lower/OpenMP/requires-notarget.f90
new file mode 100644
index 000000000000000..6f555a1782908a9
--- /dev/null
+++ b/flang/test/Lower/OpenMP/requires-notarget.f90
@@ -0,0 +1,14 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck %s
+
+! This test checks that requires lowering into MLIR skips creating the
+! omp.requires attribute with target-related clauses if there are no device
+! functions in the compilation unit
+
+!CHECK: module attributes {
+!CHECK-NOT: omp.requires
+program requires
+ !$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
+end program requires
diff --git a/flang/test/Lower/OpenMP/requires.f90 b/flang/test/Lower/OpenMP/requires.f90
new file mode 100644
index 000000000000000..cec836f11a3a035
--- /dev/null
+++ b/flang/test/Lower/OpenMP/requires.f90
@@ -0,0 +1,14 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck %s
+
+! This test checks the lowering of requires into MLIR
+
+!CHECK: module attributes {
+!CHECK-SAME: omp.requires = #omp<clause_requires reverse_offload|unified_shared_memory>
+program requires
+ !$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
+ !$omp target
+ !$omp end target
+end program requires
diff --git a/flang/test/Lower/OpenMP/rtl-flags.f90 b/flang/test/Lower/OpenMP/rtl-flags.f90
new file mode 100644
index 000000000000000..b38a6af0d7e3eb8
--- /dev/null
+++ b/flang/test/Lower/OpenMP/rtl-flags.f90
@@ -0,0 +1,39 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - | FileCheck %s --check-prefix=DEFAULT-HOST-FIR
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device -fopenmp-version=45 %s -o - | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR-VERSION
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - | FileCheck %s --check-prefix=DEFAULT-HOST-FIR-VERSION
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-target-debug -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DBG-DEVICE-FIR
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-target-debug=111 -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DBG-EQ-DEVICE-FIR
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-assume-teams-oversubscription -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=TEAMS-OSUB-DEVICE-FIR
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-assume-threads-oversubscription -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=THREAD-OSUB-DEVICE-FIR
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-assume-no-thread-state -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=THREAD-STATE-DEVICE-FIR
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-assume-no-nested-parallelism -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=NEST-PAR-DEVICE-FIR
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-target-debug -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism -fopenmp-assume-threads-oversubscription -fopenmp-assume-no-thread-state -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=ALL-DEVICE-FIR
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device -fopenmp-version=45 -o - %s | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR-VERSION
+!RUN: bbc -emit-hlfir -fopenmp -o - %s | FileCheck %s --check-prefix=DEFAULT-HOST-FIR
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=45 -o - %s | FileCheck %s --check-prefix=DEFAULT-HOST-FIR-VERSION
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-target-debug=111 -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=DBG-EQ-DEVICE-FIR
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-teams-oversubscription -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=TEAMS-OSUB-DEVICE-FIR
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-threads-oversubscription -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=THREAD-OSUB-DEVICE-FIR
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-no-thread-state -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=THREAD-STATE-DEVICE-FIR
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-no-nested-parallelism -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=NEST-PAR-DEVICE-FIR
+!RUN: bbc -emit-hlfir -fopenmp -fopenmp-target-debug=1 -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism -fopenmp-assume-threads-oversubscription -fopenmp-assume-no-thread-state -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=ALL-DEVICE-FIR
+
+!DEFAULT-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<openmp_device_version = 11>
+!DEFAULT-DEVICE-FIR-SAME: omp.is_target_device = true
+!DEFAULT-DEVICE-FIR-VERSION: module attributes {{{.*}}omp.flags = #omp.flags<openmp_device_version = 45>
+!DEFAULT-DEVICE-FIR-VERSION-SAME: omp.is_target_device = true
+!DEFAULT-DEVICE-FIR-VERSION-SAME: omp.version = #omp.version<version = 45>
+!DEFAULT-HOST-FIR: module attributes {{{.*}}omp.is_target_device = false{{.*}}
+!DEFAULT-HOST-FIR-VERSION: module attributes {{{.*}}omp.is_target_device = false
+!DEFAULT-HOST-FIR-VERSION-SAME: omp.version = #omp.version<version = 45>
+!DBG-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 1, openmp_device_version = 11>
+!DBG-EQ-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 111, openmp_device_version = 11>
+!TEAMS-OSUB-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<assume_teams_oversubscription = true, openmp_device_version = 11>
+!THREAD-OSUB-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<assume_threads_oversubscription = true, openmp_device_version = 11>
+!THREAD-STATE-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<assume_no_thread_state = true, openmp_device_version = 11>
+!NEST-PAR-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<assume_no_nested_parallelism = true, openmp_device_version = 11>
+!ALL-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 1, assume_teams_oversubscription = true, assume_threads_oversubscription = true, assume_no_thread_state = true, assume_no_nested_parallelism = true, openmp_device_version = 11>
+subroutine omp_subroutine()
+end subroutine omp_subroutine
diff --git a/flang/test/Lower/OpenMP/target_cpu_features.f90 b/flang/test/Lower/OpenMP/target_cpu_features.f90
new file mode 100644
index 000000000000000..46fb14efad5c03c
--- /dev/null
+++ b/flang/test/Lower/OpenMP/target_cpu_features.f90
@@ -0,0 +1,19 @@
+!REQUIRES: amdgpu-registered-target
+!RUN: %flang_fc1 -emit-hlfir -triple amdgcn-amd-amdhsa -target-cpu gfx908 -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+
+!===============================================================================
+! Target_Enter Simple
+!===============================================================================
+
+!CHECK: omp.target = #omp.target<target_cpu = "gfx908",
+!CHECK-SAME: target_features = "+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,
+!CHECK-SAME: +dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,
+!CHECK-SAME: +gfx8-insts,+gfx9-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,
+!CHECK-SAME: +wavefrontsize64">
+!CHECK-LABEL: func.func @_QPomp_target_simple()
+subroutine omp_target_simple
+ ! Directive needed to prevent subroutine from being filtered out when
+ ! compiling for the device.
+ !$omp declare target
+end subroutine omp_target_simple
+
diff --git a/flang/test/Lower/OpenMP/taskwait.f90 b/flang/test/Lower/OpenMP/taskwait.f90
new file mode 100644
index 000000000000000..b5c72aaab5943e4
--- /dev/null
+++ b/flang/test/Lower/OpenMP/taskwait.f90
@@ -0,0 +1,11 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+!CHECK-LABEL: @_QPomp_taskwait
+subroutine omp_taskwait
+ !CHECK: omp.taskwait
+ !$omp taskwait
+ !CHECK: fir.call @_QPfoo() {{.*}}: () -> ()
+ call foo()
+ !CHECK: omp.taskwait
+ !$omp taskwait
+end subroutine omp_taskwait
diff --git a/flang/test/Lower/OpenMP/taskyield.f90 b/flang/test/Lower/OpenMP/taskyield.f90
new file mode 100644
index 000000000000000..28c1d025f6dc8a1
--- /dev/null
+++ b/flang/test/Lower/OpenMP/taskyield.f90
@@ -0,0 +1,11 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+!CHECK-LABEL: @_QPomp_taskyield
+subroutine omp_taskyield
+ !CHECK: omp.taskyield
+ !$omp taskyield
+ !CHECK: fir.call @_QPfoo() {{.*}}: () -> ()
+ call foo()
+ !CHECK: omp.taskyield
+ !$omp taskyield
+end subroutine omp_taskyield
diff --git a/flang/test/Lower/OpenMP/teams.f90 b/flang/test/Lower/OpenMP/teams.f90
new file mode 100644
index 000000000000000..2620d7752a4ed3c
--- /dev/null
+++ b/flang/test/Lower/OpenMP/teams.f90
@@ -0,0 +1,114 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+! CHECK-LABEL: func @_QPteams_simple
+subroutine teams_simple()
+ ! CHECK: omp.teams
+ !$omp teams
+ ! CHECK: fir.call
+ call f1()
+ ! CHECK: omp.terminator
+ !$omp end teams
+end subroutine teams_simple
+
+!===============================================================================
+! `num_teams` clause
+!===============================================================================
+
+! CHECK-LABEL: func @_QPteams_numteams
+subroutine teams_numteams(num_teams)
+ integer, intent(inout) :: num_teams
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: num_teams( to %{{.*}}: i32)
+ !$omp teams num_teams(4)
+ ! CHECK: fir.call
+ call f1()
+ ! CHECK: omp.terminator
+ !$omp end teams
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: num_teams( to %{{.*}}: i32)
+ !$omp teams num_teams(num_teams)
+ ! CHECK: fir.call
+ call f2()
+ ! CHECK: omp.terminator
+ !$omp end teams
+
+end subroutine teams_numteams
+
+!===============================================================================
+! `if` clause
+!===============================================================================
+
+! CHECK-LABEL: func @_QPteams_if
+subroutine teams_if(alpha)
+ integer, intent(in) :: alpha
+ logical :: condition
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if(%{{.*}})
+ !$omp teams if(.false.)
+ ! CHECK: fir.call
+ call f1()
+ ! CHECK: omp.terminator
+ !$omp end teams
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if(%{{.*}})
+ !$omp teams if(alpha .le. 0)
+ ! CHECK: fir.call
+ call f2()
+ ! CHECK: omp.terminator
+ !$omp end teams
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if(%{{.*}})
+ !$omp teams if(condition)
+ ! CHECK: fir.call
+ call f3()
+ ! CHECK: omp.terminator
+ !$omp end teams
+end subroutine teams_if
+
+!===============================================================================
+! `thread_limit` clause
+!===============================================================================
+
+! CHECK-LABEL: func @_QPteams_threadlimit
+subroutine teams_threadlimit(thread_limit)
+ integer, intent(inout) :: thread_limit
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: thread_limit(%{{.*}}: i32)
+ !$omp teams thread_limit(4)
+ ! CHECK: fir.call
+ call f1()
+ ! CHECK: omp.terminator
+ !$omp end teams
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: thread_limit(%{{.*}}: i32)
+ !$omp teams thread_limit(thread_limit)
+ ! CHECK: fir.call
+ call f2()
+ ! CHECK: omp.terminator
+ !$omp end teams
+
+end subroutine teams_threadlimit
+
+!===============================================================================
+! `allocate` clause
+!===============================================================================
+
+! CHECK-LABEL: func @_QPteams_allocate
+subroutine teams_allocate()
+ use omp_lib
+ integer :: x
+ ! CHECK: omp.teams
+ ! CHECK-SAME: allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>)
+ !$omp teams allocate(omp_high_bw_mem_alloc: x) private(x)
+ ! CHECK: arith.addi
+ x = x + 12
+ ! CHECK: omp.terminator
+ !$omp end teams
+end subroutine teams_allocate
More information about the flang-commits
mailing list