Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / teams_generic_loop_ast_print.cpp
blob4553d9cfc8a9d543ecd5ba0a35e9e6ada2e07e45
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 //CHECK: template <typename T, int C> void templ_foo(T t) {
19 //CHECK: T j, z;
20 //CHECK: #pragma omp teams loop collapse(C) reduction(+: z) lastprivate(j) bind(thread) num_teams(C + 2)
21 //CHECK: for (T i = 0; i < t; ++i)
22 //CHECK: for (j = 0; j < t; ++j)
23 //CHECK: z += i + j;
24 //CHECK: }
26 //CHECK: template<> void templ_foo<int, 2>(int t) {
27 //CHECK: int j, z;
28 //CHECK: #pragma omp teams loop collapse(2) reduction(+: z) lastprivate(j) bind(thread) num_teams(2 + 2)
29 //CHECK: for (int i = 0; i < t; ++i)
30 //CHECK: for (j = 0; j < t; ++j)
31 //CHECK: z += i + j;
32 //CHECK: }
33 template <typename T, int C>
34 void templ_foo(T t) {
36 T j,z;
37 #pragma omp teams loop collapse(C) reduction(+:z) lastprivate(j) bind(thread) num_teams(C+2)
38 for (T i = 0; i<t; ++i)
39 for (j = 0; j<t; ++j)
40 z += i+j;
44 //CHECK: void test() {
45 void test() {
46 constexpr int N = 100;
47 float MTX[N][N];
48 int aaa[1000];
50 //CHECK: #pragma omp target map(tofrom: MTX)
51 //CHECK: #pragma omp teams loop
52 #pragma omp target map(MTX)
53 #pragma omp teams loop
54 for (auto j = 0; j < N; ++j) {
55 MTX[0][j] = 0;
58 int j, z, z1;
59 //CHECK: #pragma omp teams loop collapse(2) private(z) lastprivate(j) order(concurrent) reduction(+: z1) bind(parallel)
60 #pragma omp teams loop collapse(2) private(z) lastprivate(j) \
61 order(concurrent) reduction(+:z1) bind(parallel)
62 for (auto i = 0; i < N; ++i) {
63 for (j = 0; j < N; ++j) {
64 z = i+j;
65 MTX[i][j] = z;
66 z1 += z;
70 //CHECK: #pragma omp target
71 //CHECK: #pragma omp teams loop bind(teams) num_teams(16) thread_limit(8) default(none)
72 #pragma omp target
73 #pragma omp teams loop bind(teams) num_teams(16) thread_limit(8) default(none)
74 for (auto i = 0; i < N; ++i) { }
76 int pr;
77 int fpr = 10;
78 int k;
79 int s = 20;
80 //CHECK: #pragma omp target
81 //CHECK: #pragma omp teams loop bind(teams) private(pr) firstprivate(fpr) shared(s) allocate(k) reduction(+: k)
82 #pragma omp target
83 #pragma omp teams loop bind(teams) private(pr) firstprivate(fpr) \
84 shared(s) allocate(k) reduction(+:k)
85 for (auto i = 0; i < N; ++i) {
86 pr = i + fpr + s;
90 //CHECK: void nobindingfunc() {
91 void nobindingfunc()
93 //CHECK: #pragma omp teams loop
94 #pragma omp teams loop
95 for (int i=0; i<10; ++i) { }
98 void bar()
100 templ_foo<int,2>(8);
103 #endif // HEADER