Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
      2 // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
      3 // RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
      4 // expected-no-diagnostics
      5 
      6 #ifndef HEADER
      7 #define HEADER
      8 
      9 void foo() {}
     10 
     11 template <class T, int N>
     12 T tmain(T argc) {
     13   T b = argc, c, d, e, f, h;
     14   static T a;
     15 // CHECK: static T a;
     16   static T g;
     17 #pragma omp threadprivate(g)
     18 #pragma omp parallel for schedule(dynamic) default(none) copyin(g)
     19   // CHECK: #pragma omp parallel for schedule(dynamic) default(none) copyin(g)
     20   for (int i = 0; i < 2; ++i)
     21     a = 2;
     22 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
     23 // CHECK-NEXT: a = 2;
     24 #pragma omp parallel for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered if (argc) num_threads(N) default(shared) shared(e) reduction(+ : h)
     25   for (int i = 0; i < 10; ++i)
     26     for (int j = 0; j < 10; ++j)
     27       for (int j = 0; j < 10; ++j)
     28         for (int j = 0; j < 10; ++j)
     29           for (int j = 0; j < 10; ++j)
     30             foo();
     31   // CHECK-NEXT: #pragma omp parallel for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered if(argc) num_threads(N) default(shared) shared(e) reduction(+: h)
     32   // CHECK-NEXT: for (int i = 0; i < 10; ++i)
     33   // CHECK-NEXT: for (int j = 0; j < 10; ++j)
     34   // CHECK-NEXT: for (int j = 0; j < 10; ++j)
     35   // CHECK-NEXT: for (int j = 0; j < 10; ++j)
     36   // CHECK-NEXT: for (int j = 0; j < 10; ++j)
     37   // CHECK-NEXT: foo();
     38   return T();
     39 }
     40 
     41 int main(int argc, char **argv) {
     42   int b = argc, c, d, e, f, h;
     43   static int a;
     44 // CHECK: static int a;
     45   static float g;
     46 #pragma omp threadprivate(g)
     47 #pragma omp parallel for schedule(guided, argc) default(none) copyin(g)
     48   // CHECK: #pragma omp parallel for schedule(guided, argc) default(none) copyin(g)
     49   for (int i = 0; i < 2; ++i)
     50     a = 2;
     51 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
     52 // CHECK-NEXT: a = 2;
     53 #pragma omp parallel for private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) schedule(auto) ordered if (argc) num_threads(a) default(shared) shared(e) reduction(+ : h)
     54   for (int i = 0; i < 10; ++i)
     55     for (int j = 0; j < 10; ++j)
     56       foo();
     57   // CHECK-NEXT: #pragma omp parallel for private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) schedule(auto) ordered if(argc) num_threads(a) default(shared) shared(e) reduction(+: h)
     58   // CHECK-NEXT: for (int i = 0; i < 10; ++i)
     59   // CHECK-NEXT: for (int j = 0; j < 10; ++j)
     60   // CHECK-NEXT: foo();
     61   return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
     62 }
     63 
     64 #endif
     65