xref: /llvm-project/flang/test/Lower/OpenACC/acc-routine.f90 (revision b8967e003e202cba1b77412478a1990c9dcccdca)
1! This test checks lowering of OpenACC routine directive.
2
3! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
4
5! CHECK: acc.routine @acc_routine_17 func(@_QPacc_routine19) bind("_QPacc_routine17" [#acc.device_type<host>], "_QPacc_routine17" [#acc.device_type<default>], "_QPacc_routine16" [#acc.device_type<multicore>])
6! CHECK: acc.routine @acc_routine_16 func(@_QPacc_routine18) bind("_QPacc_routine17" [#acc.device_type<host>], "_QPacc_routine16" [#acc.device_type<multicore>])
7! CHECK: acc.routine @acc_routine_15 func(@_QPacc_routine17) worker ([#acc.device_type<host>]) vector ([#acc.device_type<multicore>])
8! CHECK: acc.routine @acc_routine_14 func(@_QPacc_routine16) gang([#acc.device_type<nvidia>]) seq ([#acc.device_type<host>])
9! CHECK: acc.routine @acc_routine_10 func(@_QPacc_routine11) seq
10! CHECK: acc.routine @acc_routine_9 func(@_QPacc_routine10) seq
11! CHECK: acc.routine @acc_routine_8 func(@_QPacc_routine9) bind("_QPacc_routine9a")
12! CHECK: acc.routine @acc_routine_7 func(@_QPacc_routine8) bind("routine8_")
13! CHECK: acc.routine @acc_routine_6 func(@_QPacc_routine7) gang(dim: 1 : i64)
14! CHECK: acc.routine @acc_routine_5 func(@_QPacc_routine6) nohost
15! CHECK: acc.routine @acc_routine_4 func(@_QPacc_routine5) worker
16! CHECK: acc.routine @acc_routine_3 func(@_QPacc_routine4) vector
17! CHECK: acc.routine @acc_routine_2 func(@_QPacc_routine3) gang
18! CHECK: acc.routine @acc_routine_1 func(@_QPacc_routine2) seq
19! CHECK: acc.routine @acc_routine_0 func(@_QPacc_routine1)
20
21subroutine acc_routine1()
22  !$acc routine
23end subroutine
24
25! CHECK-LABEL: func.func @_QPacc_routine1() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_0]>}
26
27subroutine acc_routine2()
28  !$acc routine seq
29end subroutine
30
31! CHECK-LABEL: func.func @_QPacc_routine2() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_1]>}
32
33subroutine acc_routine3()
34  !$acc routine gang
35end subroutine
36
37! CHECK-LABEL: func.func @_QPacc_routine3() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_2]>}
38
39subroutine acc_routine4()
40  !$acc routine vector
41end subroutine
42
43! CHECK-LABEL: func.func @_QPacc_routine4() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_3]>}
44
45subroutine acc_routine5()
46  !$acc routine worker
47end subroutine
48
49! CHECK-LABEL: func.func @_QPacc_routine5() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_4]>}
50
51subroutine acc_routine6()
52  !$acc routine nohost
53end subroutine
54
55! CHECK-LABEL: func.func @_QPacc_routine6() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_5]>}
56
57subroutine acc_routine7()
58  !$acc routine gang(dim:1)
59end subroutine
60
61! CHECK-LABEL: func.func @_QPacc_routine7() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_6]>}
62
63subroutine acc_routine8()
64  !$acc routine bind("routine8_")
65end subroutine
66
67! CHECK-LABEL: func.func @_QPacc_routine8() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_7]>}
68
69subroutine acc_routine9a()
70end subroutine
71
72subroutine acc_routine9()
73  !$acc routine bind(acc_routine9a)
74end subroutine
75
76! CHECK-LABEL: func.func @_QPacc_routine9() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_8]>}
77
78function acc_routine10()
79  !$acc routine(acc_routine10) seq
80end function
81
82! CHECK-LABEL: func.func @_QPacc_routine10() -> f32 attributes {acc.routine_info = #acc.routine_info<[@acc_routine_9]>}
83
84subroutine acc_routine11(a)
85  real :: a
86  !$acc routine(acc_routine11) seq
87end subroutine
88
89! CHECK-LABEL: func.func @_QPacc_routine11(%arg0: !fir.ref<f32> {fir.bindc_name = "a"}) attributes {acc.routine_info = #acc.routine_info<[@acc_routine_10]>}
90
91subroutine acc_routine12()
92
93  interface
94  subroutine acc_routine11(a)
95    real :: a
96    !$acc routine(acc_routine11) seq
97  end subroutine
98  end interface
99
100end subroutine
101
102subroutine acc_routine13()
103  !$acc routine bind(acc_routine14)
104end subroutine
105
106subroutine acc_routine14()
107end subroutine
108
109subroutine acc_routine15()
110  !$acc routine bind(acc_routine16)
111end subroutine
112
113subroutine acc_routine16()
114  !$acc routine device_type(host) seq dtype(nvidia) gang
115end subroutine
116
117subroutine acc_routine17()
118  !$acc routine device_type(host) worker dtype(multicore) vector
119end subroutine
120
121subroutine acc_routine18()
122  !$acc routine device_type(host) bind(acc_routine17) dtype(multicore) bind(acc_routine16)
123end subroutine
124
125subroutine acc_routine19()
126  !$acc routine device_type(host,default) bind(acc_routine17) dtype(multicore) bind(acc_routine16)
127end subroutine
128