1 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 2 // RUN: -fsyntax-only -verify %s 3 4 // expected-no-diagnostics 5 6 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 7 // RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT 8 9 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 10 // RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP 11 12 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 13 // RUN: -emit-pch -o %t %s 14 15 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 16 // RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP 17 18 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 19 // RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT 20 21 #ifndef HEADER 22 #define HEADER 23 24 //PRINT: template <typename T, int C> void templ_foo(T t) { 25 //PRINT: T j, z; 26 //PRINT: #pragma omp loop collapse(C) reduction(+: z) lastprivate(j) 27 //PRINT: for (T i = 0; i < t; ++i) 28 //PRINT: for (j = 0; j < t; ++j) 29 //PRINT: z += i + j; 30 //PRINT: } 31 //DUMP: FunctionTemplateDecl{{.*}}templ_foo 32 //DUMP: TemplateTypeParmDecl{{.*}}T 33 //DUMP: NonTypeTemplateParmDecl{{.*}}C 34 //DUMP: OMPGenericLoopDirective 35 //DUMP: OMPCollapseClause 36 //DUMP: DeclRefExpr{{.*}}'C' 'int' 37 //DUMP: OMPReductionClause 38 //DUMP: DeclRefExpr{{.*}}'z' 'T' 39 //DUMP: OMPLastprivateClause 40 //DUMP: DeclRefExpr{{.*}}'j' 'T' 41 //DUMP: ForStmt 42 //DUMP: ForStmt 43 44 //PRINT: template<> void templ_foo<int, 2>(int t) { 45 //PRINT: int j, z; 46 //PRINT: #pragma omp loop collapse(2) reduction(+: z) lastprivate(j) 47 //PRINT: for (int i = 0; i < t; ++i) 48 //PRINT: for (j = 0; j < t; ++j) 49 //PRINT: z += i + j; 50 //PRINT: } 51 //DUMP: FunctionDecl{{.*}}templ_foo 'void (int)' 52 //DUMP: TemplateArgument type 'int' 53 //DUMP: TemplateArgument integral 2 54 //DUMP: ParmVarDecl{{.*}}'int':'int' 55 //DUMP: OMPGenericLoopDirective 56 //DUMP: OMPCollapseClause 57 //DUMP: ConstantExpr{{.*}}'int' 58 //DUMP: value: Int 2 59 //DUMP: OMPReductionClause 60 //DUMP: DeclRefExpr{{.*}}'z' 'int':'int' 61 //DUMP: OMPLastprivateClause 62 //DUMP: DeclRefExpr{{.*}}'j' 'int':'int' 63 //DUMP: ForStmt 64 template <typename T, int C> 65 void templ_foo(T t) { 66 67 T j,z; 68 #pragma omp loop collapse(C) reduction(+:z) lastprivate(j) 69 for (T i = 0; i<t; ++i) 70 for (j = 0; j<t; ++j) 71 z += i+j; 72 } 73 74 75 //PRINT: void test() { 76 //DUMP: FunctionDecl {{.*}}test 'void ()' 77 void test() { 78 constexpr int N = 100; 79 float MTX[N][N]; 80 int aaa[1000]; 81 82 //PRINT: #pragma omp target teams distribute parallel for map(tofrom: MTX) 83 //PRINT: #pragma omp loop 84 //DUMP: OMPTargetTeamsDistributeParallelForDirective 85 //DUMP: CapturedStmt 86 //DUMP: ForStmt 87 //DUMP: CompoundStmt 88 //DUMP: OMPGenericLoopDirective 89 #pragma omp target teams distribute parallel for map(MTX) 90 for (auto i = 0; i < N; ++i) { 91 #pragma omp loop 92 for (auto j = 0; j < N; ++j) { 93 MTX[i][j] = 0; 94 } 95 } 96 97 //PRINT: #pragma omp target teams 98 //PRINT: #pragma omp loop 99 //DUMP: OMPTargetTeamsDirective 100 //DUMP: CapturedStmt 101 //DUMP: ForStmt 102 //DUMP: OMPGenericLoopDirective 103 #pragma omp target teams 104 for (int i=0; i<1000; ++i) { 105 #pragma omp loop 106 for (int j=0; j<100; j++) { 107 aaa[i] += i + j; 108 } 109 } 110 111 int j, z, z1; 112 //PRINT: #pragma omp loop collapse(2) private(z) lastprivate(j) order(concurrent) reduction(+: z1) 113 //DUMP: OMPGenericLoopDirective 114 //DUMP: OMPCollapseClause 115 //DUMP: IntegerLiteral{{.*}}2 116 //DUMP: OMPPrivateClause 117 //DUMP-NEXT: DeclRefExpr{{.*}}'z' 118 //DUMP: OMPLastprivateClause 119 //DUMP-NEXT: DeclRefExpr{{.*}}'j' 120 //DUMP: OMPOrderClause 121 //DUMP: OMPReductionClause 122 //DUMP-NEXT: DeclRefExpr{{.*}}'z1' 123 //DUMP: ForStmt 124 //DUMP: ForStmt 125 #pragma omp loop collapse(2) private(z) lastprivate(j) order(concurrent) \ 126 reduction(+:z1) 127 for (auto i = 0; i < N; ++i) { 128 for (j = 0; j < N; ++j) { 129 z = i+j; 130 MTX[i][j] = z; 131 z1 += z; 132 } 133 } 134 } 135 136 void bar() 137 { 138 templ_foo<int,2>(8); 139 } 140 141 #endif // HEADER 142