[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_teams_generic_loop_ast_print.cpp
blobc4e292ace921e2185f7db2fda321e82d139253e5
1 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
2 // RUN: -fsyntax-only -verify %s
4 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
5 // RUN: -ast-print %s | FileCheck %s
7 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
8 // RUN: -emit-pch -o %t %s
10 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
11 // RUN: -include-pch %t -ast-print %s | FileCheck %s
13 // expected-no-diagnostics
15 #ifndef HEADER
16 #define HEADER
18 typedef void **omp_allocator_handle_t;
19 extern const omp_allocator_handle_t omp_null_allocator;
20 extern const omp_allocator_handle_t omp_default_mem_alloc;
21 extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
22 extern const omp_allocator_handle_t omp_const_mem_alloc;
23 extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
24 extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
25 extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
26 extern const omp_allocator_handle_t omp_pteam_mem_alloc;
27 extern const omp_allocator_handle_t omp_thread_mem_alloc;
29 //CHECK: template <typename T, int C, int D> void templ_foo(T t) {
30 //CHECK: T j, z;
31 //CHECK: #pragma omp target teams loop device(D) collapse(C) reduction(+: z) lastprivate(j) bind(thread) num_teams(C + 2)
32 //CHECK: for (T i = 0; i < t; ++i)
33 //CHECK: for (j = 0; j < t; ++j)
34 //CHECK: z += i + j;
35 //CHECK: }
37 //CHECK: template<> void templ_foo<int, 2, 0>(int t) {
38 //CHECK: int j, z;
39 //CHECK: #pragma omp target teams loop device(0) collapse(2) reduction(+: z) lastprivate(j) bind(thread) num_teams(2 + 2)
40 //CHECK: for (int i = 0; i < t; ++i)
41 //CHECK: for (j = 0; j < t; ++j)
42 //CHECK: z += i + j;
43 //CHECK: }
44 template <typename T, int C, int D>
45 void templ_foo(T t) {
47 T j,z;
48 #pragma omp target teams loop device(D) collapse(C) reduction(+:z) lastprivate(j) bind(thread) num_teams(C+2)
49 for (T i = 0; i<t; ++i)
50 for (j = 0; j<t; ++j)
51 z += i+j;
55 //CHECK: void test() {
56 void test() {
57 constexpr int N = 100;
58 float MTX[N][N];
59 int aaa[1000];
61 //CHECK: #pragma omp target teams loop map(tofrom: MTX)
62 #pragma omp target teams loop map(MTX)
63 for (auto j = 0; j < N; ++j) {
64 MTX[0][j] = 0;
67 int j, z, z1;
68 //CHECK: #pragma omp target teams loop collapse(2) private(z) lastprivate(j) order(concurrent) reduction(+: z1) bind(parallel)
69 #pragma omp target teams loop collapse(2) private(z) lastprivate(j) \
70 order(concurrent) reduction(+:z1) bind(parallel)
71 for (auto i = 0; i < N; ++i) {
72 for (j = 0; j < N; ++j) {
73 z = i+j;
74 MTX[i][j] = z;
75 z1 += z;
79 //CHECK: #pragma omp target teams loop bind(teams) num_teams(16) thread_limit(8) default(none)
80 #pragma omp target teams loop bind(teams) num_teams(16) thread_limit(8) default(none)
81 for (auto i = 0; i < N; ++i) { }
83 int pr;
84 int zzz;
85 //CHECK: #pragma omp target teams loop private(zzz) uses_allocators(omp_default_mem_alloc) allocate(omp_default_mem_alloc: zzz) if(1) device(0) map(tofrom: pr)
86 #pragma omp target teams loop private(zzz) uses_allocators(omp_default_mem_alloc) allocate(omp_default_mem_alloc:zzz) if(1) device(0) map(tofrom:pr)
87 for (int i=0; i<1000; ++i) {
88 zzz = i + 1;
89 pr = 33;
92 int fpr = 10;
93 int k;
94 int s = 20;
95 //CHECK: #pragma omp target teams loop bind(teams) private(pr) firstprivate(fpr) shared(s) allocate(k) reduction(+: k)
96 #pragma omp target teams loop bind(teams) private(pr) firstprivate(fpr) \
97 shared(s) allocate(k) reduction(+:k)
98 for (auto i = 0; i < N; ++i) {
99 pr = i + fpr + s;
102 short y = 3;
103 //CHECK: #pragma omp target teams loop map(tofrom: y) depend(out : y)
104 #pragma omp target teams loop map(tofrom:y) depend(out:y)
105 for (int i=0; i<10; ++i) {
106 y = 3+i;
110 //CHECK: void nobindingfunc() {
111 void nobindingfunc()
113 //CHECK: #pragma omp target teams loop
114 #pragma omp target teams loop
115 for (int i=0; i<10; ++i) { }
118 void bar()
120 templ_foo<int,2,0>(8);
123 #endif // HEADER