[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / parallel_generic_loop_ast_print.cpp
blobd5ef316b7066c20e1adc3b3f2de355ab0c05bde3
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> void templ_foo(T t) {
30 //CHECK: T j, z;
31 //CHECK: #pragma omp parallel loop collapse(C) reduction(+: z) lastprivate(j) bind(thread)
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>(int t) {
38 //CHECK: int j, z;
39 //CHECK: #pragma omp parallel loop collapse(2) reduction(+: z) lastprivate(j) bind(thread)
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>
45 void templ_foo(T t) {
47 T j,z;
48 #pragma omp parallel loop collapse(C) reduction(+:z) lastprivate(j) bind(thread)
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 distribute parallel for map(tofrom: MTX)
62 //CHECK: #pragma omp parallel loop
63 #pragma omp target teams distribute parallel for map(MTX)
64 for (auto i = 0; i < N; ++i) {
65 #pragma omp parallel loop
66 for (auto j = 0; j < N; ++j) {
67 MTX[i][j] = 0;
71 //CHECK: #pragma omp target teams
72 //CHECK: #pragma omp parallel loop
73 #pragma omp target teams
74 for (int i=0; i<1000; ++i) {
75 #pragma omp parallel loop
76 for (int j=0; j<100; j++) {
77 aaa[i] += i + j;
81 int j, z, z1, z2 = 1, z3 = 2;
82 //CHECK: #pragma omp parallel loop collapse(2) private(z) lastprivate(j) order(concurrent) firstprivate(z2) num_threads(4) if(1) allocate(omp_default_mem_alloc: z2) shared(z3) reduction(+: z1) bind(parallel) proc_bind(primary)
83 #pragma omp parallel loop collapse(2) private(z) lastprivate(j) \
84 order(concurrent) firstprivate(z2) num_threads(4) if(1) \
85 allocate(omp_default_mem_alloc:z2) shared(z3) \
86 reduction(+:z1) bind(parallel) proc_bind(primary)
87 for (auto i = 0; i < N; ++i) {
88 for (j = 0; j < N; ++j) {
89 z = i+j;
90 MTX[i][j] = z;
91 z1 += z;
95 //CHECK: #pragma omp target teams
96 //CHECK: #pragma omp parallel loop bind(teams)
97 #pragma omp target teams
98 #pragma omp parallel loop bind(teams)
99 for (auto i = 0; i < N; ++i) { }
101 //CHECK: #pragma omp target
102 //CHECK: #pragma omp teams
103 //CHECK: #pragma omp parallel loop bind(teams)
104 #pragma omp target
105 #pragma omp teams
106 #pragma omp parallel loop bind(teams)
107 for (auto i = 0; i < N; ++i) { }
110 //CHECK: void nobindingfunc() {
111 void nobindingfunc()
113 //CHECK: #pragma omp parallel loop
114 #pragma omp parallel loop
115 for (int i=0; i<10; ++i) { }
118 void bar()
120 templ_foo<int,2>(8);
123 #endif // HEADER