Skip to content

Commit 09b30f4

Browse files
[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.
1 parent 8232ab7 commit 09b30f4

File tree

11 files changed

+774
-0
lines changed

11 files changed

+774
-0
lines changed

flang/test/Lower/OpenMP/if-clause.f90

Lines changed: 505 additions & 0 deletions
Large diffs are not rendered by default.

flang/test/Lower/OpenMP/is-device.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
2+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefix=HOST
3+
!RUN: %flang_fc1 -emit-hlfir -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE-FLAG-ONLY
4+
!RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir -o - %s | FileCheck %s --check-prefix=DEVICE
5+
!RUN: bbc -fopenmp -emit-hlfir -o - %s | FileCheck %s --check-prefix=HOST
6+
!RUN: bbc -fopenmp-is-target-device -emit-hlfir -o - %s | FileCheck %s --check-prefix=DEVICE-FLAG-ONLY
7+
8+
!DEVICE: module attributes {{{.*}}, omp.is_target_device = true{{.*}}}
9+
!HOST: module attributes {{{.*}}, omp.is_target_device = false{{.*}}}
10+
!DEVICE-FLAG-ONLY: module attributes {{{.*}}"
11+
!DEVICE-FLAG-ONLY-NOT: , omp.is_target_device = {{.*}}
12+
!DEVICE-FLAG-ONLY-SAME: }
13+
subroutine omp_subroutine()
14+
end subroutine omp_subroutine
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!REQUIRES: amdgpu-registered-target
2+
3+
!RUN: %flang_fc1 -triple amdgcn-amd-amdhsa -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
4+
!RUN: bbc -fopenmp -fopenmp-is-target-device -fopenmp-is-gpu -emit-hlfir -o - %s | FileCheck %s
5+
6+
!RUN: not %flang_fc1 -triple amdgcn-amd-amdhsa -emit-hlfir -fopenmp %s -o - 2>&1 | FileCheck %s --check-prefix=FLANG-ERROR
7+
!RUN: not bbc -fopenmp -fopenmp-is-gpu -emit-hlfir %s -o - 2>&1 | FileCheck %s --check-prefix=BBC-ERROR
8+
9+
!CHECK: module attributes {{{.*}}omp.is_gpu = true
10+
subroutine omp_subroutine()
11+
end subroutine omp_subroutine
12+
13+
!FLANG-ERROR: error: OpenMP AMDGPU/NVPTX is only prepared to deal with device code.
14+
!BBC-ERROR: FATAL: -fopenmp-is-gpu can only be set if -fopenmp-is-target-device is also set
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
3+
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
4+
! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck %s
5+
6+
! This test checks the lowering of requires into MLIR
7+
8+
!CHECK: module attributes {
9+
!CHECK-SAME: omp.requires = #omp<clause_requires unified_shared_memory>
10+
block data init
11+
!$omp requires unified_shared_memory
12+
integer :: x
13+
common /block/ x
14+
data x / 10 /
15+
end
16+
17+
subroutine f
18+
!$omp declare target
19+
end subroutine f
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
3+
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
4+
! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck %s
5+
6+
! This test checks that requires lowering into MLIR skips creating the
7+
! omp.requires attribute with target-related clauses if there are no device
8+
! functions in the compilation unit
9+
10+
!CHECK: module attributes {
11+
!CHECK-NOT: omp.requires
12+
program requires
13+
!$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
14+
end program requires

flang/test/Lower/OpenMP/requires.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
3+
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
4+
! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck %s
5+
6+
! This test checks the lowering of requires into MLIR
7+
8+
!CHECK: module attributes {
9+
!CHECK-SAME: omp.requires = #omp<clause_requires reverse_offload|unified_shared_memory>
10+
program requires
11+
!$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
12+
!$omp target
13+
!$omp end target
14+
end program requires

flang/test/Lower/OpenMP/rtl-flags.f90

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR
2+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - | FileCheck %s --check-prefix=DEFAULT-HOST-FIR
3+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device -fopenmp-version=45 %s -o - | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR-VERSION
4+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - | FileCheck %s --check-prefix=DEFAULT-HOST-FIR-VERSION
5+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-target-debug -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DBG-DEVICE-FIR
6+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-target-debug=111 -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DBG-EQ-DEVICE-FIR
7+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-assume-teams-oversubscription -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=TEAMS-OSUB-DEVICE-FIR
8+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-assume-threads-oversubscription -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=THREAD-OSUB-DEVICE-FIR
9+
!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
10+
!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
11+
!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
12+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR
13+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device -fopenmp-version=45 -o - %s | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR-VERSION
14+
!RUN: bbc -emit-hlfir -fopenmp -o - %s | FileCheck %s --check-prefix=DEFAULT-HOST-FIR
15+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=45 -o - %s | FileCheck %s --check-prefix=DEFAULT-HOST-FIR-VERSION
16+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-target-debug=111 -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=DBG-EQ-DEVICE-FIR
17+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-teams-oversubscription -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=TEAMS-OSUB-DEVICE-FIR
18+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-threads-oversubscription -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=THREAD-OSUB-DEVICE-FIR
19+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-no-thread-state -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=THREAD-STATE-DEVICE-FIR
20+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-assume-no-nested-parallelism -fopenmp-is-target-device -o - %s | FileCheck %s --check-prefix=NEST-PAR-DEVICE-FIR
21+
!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
22+
23+
!DEFAULT-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<openmp_device_version = 11>
24+
!DEFAULT-DEVICE-FIR-SAME: omp.is_target_device = true
25+
!DEFAULT-DEVICE-FIR-VERSION: module attributes {{{.*}}omp.flags = #omp.flags<openmp_device_version = 45>
26+
!DEFAULT-DEVICE-FIR-VERSION-SAME: omp.is_target_device = true
27+
!DEFAULT-DEVICE-FIR-VERSION-SAME: omp.version = #omp.version<version = 45>
28+
!DEFAULT-HOST-FIR: module attributes {{{.*}}omp.is_target_device = false{{.*}}
29+
!DEFAULT-HOST-FIR-VERSION: module attributes {{{.*}}omp.is_target_device = false
30+
!DEFAULT-HOST-FIR-VERSION-SAME: omp.version = #omp.version<version = 45>
31+
!DBG-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 1, openmp_device_version = 11>
32+
!DBG-EQ-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<debug_kind = 111, openmp_device_version = 11>
33+
!TEAMS-OSUB-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<assume_teams_oversubscription = true, openmp_device_version = 11>
34+
!THREAD-OSUB-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<assume_threads_oversubscription = true, openmp_device_version = 11>
35+
!THREAD-STATE-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<assume_no_thread_state = true, openmp_device_version = 11>
36+
!NEST-PAR-DEVICE-FIR: module attributes {{{.*}}omp.flags = #omp.flags<assume_no_nested_parallelism = true, openmp_device_version = 11>
37+
!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>
38+
subroutine omp_subroutine()
39+
end subroutine omp_subroutine
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
!REQUIRES: amdgpu-registered-target
2+
!RUN: %flang_fc1 -emit-hlfir -triple amdgcn-amd-amdhsa -target-cpu gfx908 -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
3+
4+
!===============================================================================
5+
! Target_Enter Simple
6+
!===============================================================================
7+
8+
!CHECK: omp.target = #omp.target<target_cpu = "gfx908",
9+
!CHECK-SAME: target_features = "+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,
10+
!CHECK-SAME: +dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,
11+
!CHECK-SAME: +gfx8-insts,+gfx9-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,
12+
!CHECK-SAME: +wavefrontsize64">
13+
!CHECK-LABEL: func.func @_QPomp_target_simple()
14+
subroutine omp_target_simple
15+
! Directive needed to prevent subroutine from being filtered out when
16+
! compiling for the device.
17+
!$omp declare target
18+
end subroutine omp_target_simple
19+

flang/test/Lower/OpenMP/taskwait.f90

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
3+
!CHECK-LABEL: @_QPomp_taskwait
4+
subroutine omp_taskwait
5+
!CHECK: omp.taskwait
6+
!$omp taskwait
7+
!CHECK: fir.call @_QPfoo() {{.*}}: () -> ()
8+
call foo()
9+
!CHECK: omp.taskwait
10+
!$omp taskwait
11+
end subroutine omp_taskwait

flang/test/Lower/OpenMP/taskyield.f90

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
3+
!CHECK-LABEL: @_QPomp_taskyield
4+
subroutine omp_taskyield
5+
!CHECK: omp.taskyield
6+
!$omp taskyield
7+
!CHECK: fir.call @_QPfoo() {{.*}}: () -> ()
8+
call foo()
9+
!CHECK: omp.taskyield
10+
!$omp taskyield
11+
end subroutine omp_taskyield

flang/test/Lower/OpenMP/teams.f90

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
3+
! CHECK-LABEL: func @_QPteams_simple
4+
subroutine teams_simple()
5+
! CHECK: omp.teams
6+
!$omp teams
7+
! CHECK: fir.call
8+
call f1()
9+
! CHECK: omp.terminator
10+
!$omp end teams
11+
end subroutine teams_simple
12+
13+
!===============================================================================
14+
! `num_teams` clause
15+
!===============================================================================
16+
17+
! CHECK-LABEL: func @_QPteams_numteams
18+
subroutine teams_numteams(num_teams)
19+
integer, intent(inout) :: num_teams
20+
21+
! CHECK: omp.teams
22+
! CHECK-SAME: num_teams( to %{{.*}}: i32)
23+
!$omp teams num_teams(4)
24+
! CHECK: fir.call
25+
call f1()
26+
! CHECK: omp.terminator
27+
!$omp end teams
28+
29+
! CHECK: omp.teams
30+
! CHECK-SAME: num_teams( to %{{.*}}: i32)
31+
!$omp teams num_teams(num_teams)
32+
! CHECK: fir.call
33+
call f2()
34+
! CHECK: omp.terminator
35+
!$omp end teams
36+
37+
end subroutine teams_numteams
38+
39+
!===============================================================================
40+
! `if` clause
41+
!===============================================================================
42+
43+
! CHECK-LABEL: func @_QPteams_if
44+
subroutine teams_if(alpha)
45+
integer, intent(in) :: alpha
46+
logical :: condition
47+
48+
! CHECK: omp.teams
49+
! CHECK-SAME: if(%{{.*}})
50+
!$omp teams if(.false.)
51+
! CHECK: fir.call
52+
call f1()
53+
! CHECK: omp.terminator
54+
!$omp end teams
55+
56+
! CHECK: omp.teams
57+
! CHECK-SAME: if(%{{.*}})
58+
!$omp teams if(alpha .le. 0)
59+
! CHECK: fir.call
60+
call f2()
61+
! CHECK: omp.terminator
62+
!$omp end teams
63+
64+
! CHECK: omp.teams
65+
! CHECK-SAME: if(%{{.*}})
66+
!$omp teams if(condition)
67+
! CHECK: fir.call
68+
call f3()
69+
! CHECK: omp.terminator
70+
!$omp end teams
71+
end subroutine teams_if
72+
73+
!===============================================================================
74+
! `thread_limit` clause
75+
!===============================================================================
76+
77+
! CHECK-LABEL: func @_QPteams_threadlimit
78+
subroutine teams_threadlimit(thread_limit)
79+
integer, intent(inout) :: thread_limit
80+
81+
! CHECK: omp.teams
82+
! CHECK-SAME: thread_limit(%{{.*}}: i32)
83+
!$omp teams thread_limit(4)
84+
! CHECK: fir.call
85+
call f1()
86+
! CHECK: omp.terminator
87+
!$omp end teams
88+
89+
! CHECK: omp.teams
90+
! CHECK-SAME: thread_limit(%{{.*}}: i32)
91+
!$omp teams thread_limit(thread_limit)
92+
! CHECK: fir.call
93+
call f2()
94+
! CHECK: omp.terminator
95+
!$omp end teams
96+
97+
end subroutine teams_threadlimit
98+
99+
!===============================================================================
100+
! `allocate` clause
101+
!===============================================================================
102+
103+
! CHECK-LABEL: func @_QPteams_allocate
104+
subroutine teams_allocate()
105+
use omp_lib
106+
integer :: x
107+
! CHECK: omp.teams
108+
! CHECK-SAME: allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>)
109+
!$omp teams allocate(omp_high_bw_mem_alloc: x) private(x)
110+
! CHECK: arith.addi
111+
x = x + 12
112+
! CHECK: omp.terminator
113+
!$omp end teams
114+
end subroutine teams_allocate

0 commit comments

Comments
 (0)