xref: /llvm-project/clang/test/SemaOpenMP/hip-omp-mix.cpp (revision 55916de2d37742fe334c0726ccf9e584bdaed09f)
1 // REQUIRES: x86-registered-target
2 // REQUIRES: amdgpu-registered-target
3 
4 // RUN: %clang_cc1 %s -x c++ -fopenmp -fsyntax-only -verify=host
5 // host-no-diagnostics
6 
7 // RUN: %clang_cc1 %s -x hip -fopenmp -fsyntax-only -verify=device
8 // device-error@#01 {{HIP does not support OpenMP target directives}}
9 // device-error@#02 {{HIP does not support OpenMP target directives}}
10 // device-error@#03 {{HIP does not support OpenMP target directives}}
11 // device-error@#04 {{HIP does not support OpenMP target directives}}
12 // device-error@#05 {{HIP does not support OpenMP target directives}}
13 // device-error@#06 {{HIP does not support OpenMP target directives}}
14 // device-error@#07 {{HIP does not support OpenMP target directives}}
15 // device-error@#08 {{HIP does not support OpenMP target directives}}
16 // device-error@#09 {{HIP does not support OpenMP target directives}}
17 // device-error@#10 {{HIP does not support OpenMP target directives}}
18 // device-error@#11 {{HIP does not support OpenMP target directives}}
19 // device-error@#12 {{HIP does not support OpenMP target directives}}
20 // device-error@#13 {{HIP does not support OpenMP target directives}}
21 // device-error@#14 {{HIP does not support OpenMP target directives}}
22 // device-error@#15 {{HIP does not support OpenMP target directives}}
23 // device-error@#16 {{HIP does not support OpenMP target directives}}
24 // device-error@#17 {{HIP does not support OpenMP target directives}}
25 // device-error@#18 {{HIP does not support OpenMP target directives}}
26 // device-error@#19 {{HIP does not support OpenMP target directives}}
27 // device-error@#20 {{HIP does not support OpenMP target directives}}
28 // device-error@#21 {{HIP does not support OpenMP target directives}}
29 // device-error@#22 {{HIP does not support OpenMP target directives}}
30 // device-error@#23 {{HIP does not support OpenMP target directives}}
31 // device-error@#24 {{HIP does not support OpenMP target directives}}
32 
test01()33 void test01() {
34 #pragma omp target // #01
35   ;
36 }
37 
38 
test02()39 void test02() {
40 #pragma omp target parallel // #02
41   ;
42 }
43 
test03()44 void test03() {
45 #pragma omp target parallel for // #03
46   for (int i = 0; i < 1; ++i);
47 }
48 
test04(int x)49 void test04(int x) {
50 #pragma omp target data map(x) // #04
51   ;
52 }
53 
test05(int * x,int n)54 void test05(int * x, int n) {
55 #pragma omp target enter data map(to:x[:n]) // #05
56 }
57 
test06(int * x,int n)58 void test06(int * x, int n) {
59 #pragma omp target exit data map(from:x[:n]) // #06
60 }
61 
test07(int * x,int n)62 void test07(int * x, int n) {
63 #pragma omp target update to(x[:n]) // #07
64 }
65 
66 #pragma omp declare target (test07) // #08
test08()67 void test08() {
68 
69 }
70 
71 #pragma omp begin declare target // #09
test09_1()72 void test09_1() {
73 
74 }
75 
test09_2()76 void test09_2() {
77 
78 }
79 #pragma omp end declare target
80 
test10(int n)81 void test10(int n) {
82   #pragma omp target parallel // #10
83   for (int i = 0; i < n; ++i)
84     ;
85 }
86 
test11(int n)87 void test11(int n) {
88   #pragma omp target parallel for // #11
89   for (int i = 0; i < n; ++i)
90     ;
91 }
92 
test12(int n)93 void test12(int n) {
94   #pragma omp target parallel for simd // #12
95   for (int i = 0; i < n; ++i)
96     ;
97 }
98 
test13(int n)99 void test13(int n) {
100   #pragma omp target parallel loop // #13
101   for (int i = 0; i < n; ++i)
102     ;
103 }
104 
test14(int n)105 void test14(int n) {
106   #pragma omp target simd // #14
107   for (int i = 0; i < n; ++i)
108     ;
109 }
110 
test15(int n)111 void test15(int n) {
112   #pragma omp target teams // #15
113   for (int i = 0; i < n; ++i)
114     ;
115 }
116 
test16(int n)117 void test16(int n) {
118   #pragma omp target teams distribute // #16
119   for (int i = 0; i < n; ++i)
120     ;
121 }
122 
test17(int n)123 void test17(int n) {
124   #pragma omp target teams distribute simd // #17
125   for (int i = 0; i < n; ++i)
126     ;
127 }
128 
test18(int n)129 void test18(int n) {
130   #pragma omp target teams loop // #18
131   for (int i = 0; i < n; ++i)
132     ;
133 }
134 
test19(int n)135 void test19(int n) {
136   #pragma omp target teams distribute parallel for // #19
137   for (int i = 0; i < n; ++i)
138     ;
139 }
140 
test20(int n)141 void test20(int n) {
142   #pragma omp target teams distribute parallel for simd // #20
143   for (int i = 0; i < n; ++i)
144     ;
145 }
146 
test21()147 void test21() {
148 #pragma omp target // #21
149   {
150 #pragma omp teams // #22
151     {}
152   }
153 }
154 
test22()155 void test22() {
156 #pragma omp target // #23
157 #pragma omp teams // #24
158   {}
159 }
160 
test23()161 void test23() {
162 // host code
163 #pragma omp teams
164   {}
165 }
166