brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.6 KiB · b361724 Raw
168 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \2// RUN:   -fsyntax-only -verify %s3 4// expected-no-diagnostics5 6// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \7// RUN:   -ast-print %s | FileCheck %s --check-prefix=PRINT8 9// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \10// RUN:   -ast-dump  %s | FileCheck %s --check-prefix=DUMP11 12// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \13// RUN:   -emit-pch -o %t %s14 15// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \16// RUN:   -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP17 18// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \19// RUN:   -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT20 21#ifndef HEADER22#define HEADER23 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) bind(thread)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_foo32//DUMP: TemplateTypeParmDecl{{.*}}T33//DUMP: NonTypeTemplateParmDecl{{.*}}C34//DUMP: OMPGenericLoopDirective35//DUMP: OMPCollapseClause36//DUMP: DeclRefExpr{{.*}}'C' 'int'37//DUMP: OMPReductionClause38//DUMP: DeclRefExpr{{.*}}'z' 'T'39//DUMP: OMPLastprivateClause40//DUMP: DeclRefExpr{{.*}}'j' 'T'41//DUMP: OMPBindClause42//DUMP: ForStmt43//DUMP: ForStmt44 45//PRINT: template<> void templ_foo<int, 2>(int t) {46//PRINT:     int j, z;47//PRINT:     #pragma omp loop collapse(2) reduction(+: z) lastprivate(j) bind(thread)48//PRINT:         for (int i = 0; i < t; ++i)49//PRINT:             for (j = 0; j < t; ++j)50//PRINT:                 z += i + j;51//PRINT: }52//DUMP: FunctionDecl{{.*}}templ_foo 'void (int)'53//DUMP: TemplateArgument type 'int'54//DUMP: TemplateArgument integral '2'55//DUMP: ParmVarDecl{{.*}}'int'56//DUMP: OMPGenericLoopDirective57//DUMP: OMPCollapseClause58//DUMP: ConstantExpr{{.*}}'int'59//DUMP: value: Int 260//DUMP: OMPReductionClause61//DUMP: DeclRefExpr{{.*}}'z' 'int'62//DUMP: OMPLastprivateClause63//DUMP: DeclRefExpr{{.*}}'j' 'int'64//DUMP: OMPBindClause65//DUMP: ForStmt66template <typename T, int C>67void templ_foo(T t) {68 69  T j,z;70  #pragma omp loop collapse(C) reduction(+:z) lastprivate(j) bind(thread)71  for (T i = 0; i<t; ++i)72    for (j = 0; j<t; ++j)73      z += i+j;74}75 76 77//PRINT: void test() {78//DUMP: FunctionDecl {{.*}}test 'void ()'79void test() {80  constexpr int N = 100;81  float MTX[N][N];82  int aaa[1000];83 84  //PRINT: #pragma omp target teams distribute parallel for map(tofrom: MTX)85  //PRINT: #pragma omp loop86  //DUMP: OMPTargetTeamsDistributeParallelForDirective87  //DUMP: CapturedStmt88  //DUMP: ForStmt89  //DUMP: CompoundStmt90  //DUMP: OMPGenericLoopDirective91  #pragma omp target teams distribute parallel for map(MTX)92  for (auto i = 0; i < N; ++i) {93    #pragma omp loop94    for (auto j = 0; j < N; ++j) {95      MTX[i][j] = 0;96    }97  }98 99  //PRINT: #pragma omp target teams100  //PRINT: #pragma omp loop101  //DUMP: OMPTargetTeamsDirective102  //DUMP: CapturedStmt103  //DUMP: ForStmt104  //DUMP: OMPGenericLoopDirective105  #pragma omp target teams106  for (int i=0; i<1000; ++i) {107    #pragma omp loop108    for (int j=0; j<100; j++) {109      aaa[i] += i + j;110    }111  }112 113  int j, z, z1;114  //PRINT: #pragma omp loop collapse(2) private(z) lastprivate(j) order(concurrent) reduction(+: z1) bind(parallel)115  //DUMP: OMPGenericLoopDirective116  //DUMP: OMPCollapseClause117  //DUMP: IntegerLiteral{{.*}}2118  //DUMP: OMPPrivateClause119  //DUMP-NEXT: DeclRefExpr{{.*}}'z'120  //DUMP: OMPLastprivateClause121  //DUMP-NEXT: DeclRefExpr{{.*}}'j'122  //DUMP: OMPOrderClause123  //DUMP: OMPReductionClause124  //DUMP-NEXT: DeclRefExpr{{.*}}'z1'125  //DUMP: OMPBindClause126  //DUMP: ForStmt127  //DUMP: ForStmt128  #pragma omp loop collapse(2) private(z) lastprivate(j) order(concurrent) \129                   reduction(+:z1) bind(parallel)130  for (auto i = 0; i < N; ++i) {131    for (j = 0; j < N; ++j) {132      z = i+j;133      MTX[i][j] = z;134      z1 += z;135    }136  }137 138  //PRINT: #pragma omp target teams139  //PRINT: #pragma omp loop bind(teams)140  //DUMP: OMPTargetTeamsDirective141  //DUMP: OMPGenericLoopDirective142  //DUMP: OMPBindClause143  //DUMP: ForStmt144  #pragma omp target teams145  #pragma omp loop bind(teams)146  for (auto i = 0; i < N; ++i) { }147 148  //PRINT: #pragma omp target149  //PRINT: #pragma omp teams150  //PRINT: #pragma omp loop bind(teams)151  //DUMP: OMPTargetDirective152  //DUMP: OMPTeamsDirective153  //DUMP: OMPGenericLoopDirective154  //DUMP: OMPBindClause155  //DUMP: ForStmt156  #pragma omp target157  #pragma omp teams158  #pragma omp loop bind(teams)159  for (auto i = 0; i < N; ++i) { }160}161 162void bar()163{164  templ_foo<int,2>(8);165}166 167#endif // HEADER168