"Fossies" - the Fresh Open Source Software Archive

Member "cfe-9.0.0.src/test/OpenMP/parallel_sections_ast_print.cpp" (27 Mar 2019, 5327 Bytes) of package /linux/misc/cfe-9.0.0.src.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "parallel_sections_ast_print.cpp": 8.0.1_vs_9.0.0.

    1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s
    2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
    3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
    4 
    5 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | FileCheck %s
    6 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
    7 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
    8 // expected-no-diagnostics
    9 
   10 #ifndef HEADER
   11 #define HEADER
   12 
   13 void foo() {}
   14 
   15 template <class T>
   16 struct S {
   17   operator T() { return T(); }
   18   static T TS;
   19 #pragma omp threadprivate(TS)
   20 };
   21 
   22 // CHECK:      template <class T> struct S {
   23 // CHECK:        static T TS;
   24 // CHECK-NEXT:   #pragma omp threadprivate(S::TS)
   25 // CHECK:      };
   26 // CHECK:      template<> struct S<int> {
   27 // CHECK:        static int TS;
   28 // CHECK-NEXT:   #pragma omp threadprivate(S<int>::TS)
   29 // CHECK-NEXT: }
   30 // CHECK:      template<> struct S<long> {
   31 // CHECK:        static long TS;
   32 // CHECK-NEXT:   #pragma omp threadprivate(S<long>::TS)
   33 // CHECK-NEXT: }
   34 
   35 template <typename T, int C>
   36 T tmain(T argc, T *argv) {
   37   T b = argc, c, d, e, f, g;
   38   static T a;
   39   S<T> s;
   40 #pragma omp parallel sections
   41   {
   42     a = 2;
   43   }
   44 #pragma omp parallel sections default(none), private(argc, b) firstprivate(argv) shared(d) if (parallel: argc > 0) num_threads(C) copyin(S < T > ::TS) proc_bind(master) reduction(+ : c) reduction(max : e) allocate(e)
   45   {
   46     foo();
   47   }
   48 #pragma omp parallel sections allocate(b) if (C) num_threads(s) proc_bind(close) reduction(^ : e, f) reduction(&& : g) lastprivate(b, c)
   49   {
   50     foo();
   51 #pragma omp section
   52     foo();
   53   }
   54   return 0;
   55 }
   56 
   57 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
   58 // CHECK-NEXT: T b = argc, c, d, e, f, g;
   59 // CHECK-NEXT: static T a;
   60 // CHECK-NEXT: S<T> s;
   61 // CHECK-NEXT: #pragma omp parallel sections{{$}}
   62 // CHECK-NEXT: {
   63 // CHECK-NEXT: a = 2;
   64 // CHECK-NEXT: }
   65 // CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+: c) reduction(max: e) allocate(e)
   66 // CHECK-NEXT: {
   67 // CHECK-NEXT: foo();
   68 // CHECK-NEXT: }
   69 // CHECK-NEXT: #pragma omp parallel sections allocate(b) if(C) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
   70 // CHECK-NEXT: {
   71 // CHECK-NEXT: foo();
   72 // CHECK-NEXT: #pragma omp section
   73 // CHECK-NEXT: foo();
   74 // CHECK-NEXT: }
   75 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
   76 // CHECK-NEXT: int b = argc, c, d, e, f, g;
   77 // CHECK-NEXT: static int a;
   78 // CHECK-NEXT: S<int> s;
   79 // CHECK-NEXT: #pragma omp parallel sections
   80 // CHECK-NEXT: {
   81 // CHECK-NEXT: a = 2;
   82 // CHECK-NEXT: }
   83 // CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) copyin(S<int>::TS) proc_bind(master) reduction(+: c) reduction(max: e) allocate(e)
   84 // CHECK-NEXT: {
   85 // CHECK-NEXT: foo();
   86 // CHECK-NEXT: }
   87 // CHECK-NEXT: #pragma omp parallel sections allocate(b) if(5) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
   88 // CHECK-NEXT: {
   89 // CHECK-NEXT: foo();
   90 // CHECK-NEXT: #pragma omp section
   91 // CHECK-NEXT: foo();
   92 // CHECK-NEXT: }
   93 // CHECK: template<> long tmain<long, 1>(long argc, long *argv) {
   94 // CHECK-NEXT: long b = argc, c, d, e, f, g;
   95 // CHECK-NEXT: static long a;
   96 // CHECK-NEXT: S<long> s;
   97 // CHECK-NEXT: #pragma omp parallel sections
   98 // CHECK-NEXT: {
   99 // CHECK-NEXT: a = 2;
  100 // CHECK-NEXT: }
  101 // CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) copyin(S<long>::TS) proc_bind(master) reduction(+: c) reduction(max: e) allocate(e)
  102 // CHECK-NEXT: {
  103 // CHECK-NEXT: foo();
  104 // CHECK-NEXT: }
  105 // CHECK-NEXT: #pragma omp parallel sections allocate(b) if(1) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
  106 // CHECK-NEXT: {
  107 // CHECK-NEXT: foo();
  108 // CHECK-NEXT: #pragma omp section
  109 // CHECK-NEXT: foo();
  110 // CHECK-NEXT: }
  111 
  112 enum Enum {};
  113 
  114 int main(int argc, char **argv) {
  115   long x;
  116   int b = argc, c, d, e, f, g;
  117   static int a;
  118 #pragma omp threadprivate(a)
  119   Enum ee;
  120 // CHECK: Enum ee;
  121 #pragma omp parallel sections
  122   // CHECK-NEXT: #pragma omp parallel sections
  123   {
  124     a = 2;
  125   }
  126 // CHECK-NEXT: {
  127 // CHECK-NEXT: a = 2;
  128 // CHECK-NEXT: }
  129 #pragma omp parallel sections default(none), private(argc, b) firstprivate(argv) if (argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(| : c, d) reduction(* : e) lastprivate(argv)
  130   // CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) if(argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(|: c,d) reduction(*: e) lastprivate(argv)
  131   {
  132     foo();
  133 #pragma omp section
  134     foo();
  135 #pragma omp section
  136     foo();
  137   }
  138   // CHECK-NEXT: {
  139   // CHECK-NEXT: foo();
  140   // CHECK-NEXT: #pragma omp section
  141   // CHECK-NEXT: foo();
  142   // CHECK-NEXT: #pragma omp section
  143   // CHECK-NEXT: foo();
  144   // CHECK-NEXT: }
  145   return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
  146 }
  147 
  148 template<typename T>
  149 T S<T>::TS = 0;
  150 
  151 #endif