1 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \ 2 // RUN: -fsyntax-only -verify %s 3 4 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \ 5 // RUN: -ast-print %s | FileCheck %s 6 7 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \ 8 // RUN: -emit-pch -o %t %s 9 10 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \ 11 // RUN: -include-pch %t -ast-print %s | FileCheck %s 12 13 // expected-no-diagnostics 14 15 #ifndef HEADER 16 #define HEADER 17 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: } 25 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> templ_foo(T t)34void templ_foo(T t) { 35 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; 41 } 42 43 44 //CHECK: void test() { test()45void test() { 46 constexpr int N = 100; 47 float MTX[N][N]; 48 int aaa[1000]; 49 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; 56 } 57 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; 67 } 68 } 69 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) { } 75 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; 87 } 88 } 89 90 //CHECK: void nobindingfunc() { nobindingfunc()91void nobindingfunc() 92 { 93 //CHECK: #pragma omp teams loop 94 #pragma omp teams loop 95 for (int i=0; i<10; ++i) { } 96 } 97 bar()98void bar() 99 { 100 templ_foo<int,2>(8); 101 } 102 103 #endif // HEADER 104