brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.1 KiB · 5ee0e3d Raw
227 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP452// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s3// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP454// RUN: %clang_cc1 -verify -fopenmp -ast-print %s -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP505// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s -DOMP56// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP507// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ast-print %s -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP518// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP519// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5210// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=60 -ast-print %s -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5111// RUN: %clang_cc1 -fopenmp -fopenmp-version=60 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5112// RUN: %clang_cc1 -fopenmp -fopenmp-version=60 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5213// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -ast-print %s -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5214// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5215// RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5216 17// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP4518// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s19// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP4520// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5021// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -DOMP522// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -verify %s -ast-print -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5023// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ast-print %s -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5124// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5125// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5126// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=60 -ast-print %s -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5127// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=60 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5128// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=60 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5129// expected-no-diagnostics30// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -ast-print %s -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5231// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5232// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -std=c++11 -include-pch %t -verify %s -ast-print -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP5233// expected-no-diagnostics34 35#ifndef HEADER36#define HEADER37 38struct S1 {39  S1(): a(0) {}40  S1(int v) : a(v) {}41  int a;42  typedef int type;43};44 45template <typename T>46class S7 : public T {47protected:48  T a;49  S7() : a(0) {}50 51public:52  S7(typename T::type v) : a(v) {53#pragma omp for simd private(a) private(this->a) private(T::a)54    for (int k = 0; k < a.a; ++k)55      ++this->a.a;56  }57  S7 &operator=(S7 &s) {58#pragma omp for simd private(a) private(this->a)59    for (int k = 0; k < s.a.a; ++k)60      ++s.a.a;61    return *this;62  }63};64 65// CHECK: #pragma omp for simd private(this->a) private(this->a) private(T::a){{$}}66// CHECK: #pragma omp for simd private(this->a) private(this->a)67// CHECK: #pragma omp for simd private(this->a) private(this->a) private(this->S1::a)68 69class S8 : public S7<S1> {70  S8() {}71 72public:73  S8(int v) : S7<S1>(v){74#pragma omp for simd private(a) private(this->a) private(S7<S1>::a)75    for (int k = 0; k < a.a; ++k)76      ++this->a.a;77  }78  S8 &operator=(S8 &s) {79#pragma omp for simd private(a) private(this->a)80    for (int k = 0; k < s.a.a; ++k)81      ++s.a.a;82    return *this;83  }84};85 86// CHECK: #pragma omp for simd private(this->a) private(this->a) private(this->S7<S1>::a)87// CHECK: #pragma omp for simd private(this->a) private(this->a)88 89void foo() {}90int g_ind = 1;91template<class T, class N> T reduct(T* arr, N num) {92  N i;93  N ind;94  N myind;95  T sum = (T)0;96// CHECK: T sum = (T)0;97#pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr) ordered98// CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) aligned(arr) ordered99  for (i = 0; i < num; ++i) {100    myind = ind;101    T cur = arr[myind];102    ind += g_ind;103    sum += cur;104  }105}106 107template<class T> struct S {108  S(const T &a)109    :m_a(a)110  {}111  T result(T *v) const {112    T res;113    T val;114    T lin = 0;115// CHECK: T res;116// CHECK: T val;117// CHECK: T lin = 0;118#ifdef OMP52119    #pragma omp for simd private(val)  safelen(7) linear(lin : step(-5)) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res, val, lin) order(reproducible:concurrent)120#elif OMP51121    #pragma omp for simd private(val)  safelen(7) linear(lin : -5) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res, val, lin) order(reproducible:concurrent)122#elif OMP5123    #pragma omp for simd private(val)  safelen(7) linear(lin : -5) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res, val, lin) order(concurrent)124#else125    #pragma omp for simd private(val)  safelen(7) linear(lin : -5) lastprivate(res) simdlen(5) allocate(res)126#endif // OMP51127// OMP52-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res,val,lin) order(reproducible: concurrent)128// OMP51-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res,val,lin) order(reproducible: concurrent)129// OMP50-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) allocate(res) if(res) nontemporal(res,val,lin) order(concurrent)130// OMP45-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) allocate(res)131    for (T i = 7; i < m_a; ++i) {132      val = v[i-7] + m_a;133      res = val;134      lin -= 5;135    }136    const T clen = 3;137// CHECK: T clen = 3;138    #pragma omp for simd safelen(clen-1) simdlen(clen-1)139// CHECK-NEXT: #pragma omp for simd safelen(clen - 1) simdlen(clen - 1)140    for(T i = clen+2; i < 20; ++i) {141// CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {142      v[i] = v[v-clen] + 1;143// CHECK-NEXT: v[i] = v[v - clen] + 1;144    }145// CHECK-NEXT: }146    return res;147  }148  ~S()149  {}150  T m_a;151};152 153template<int LEN> struct S2 {154  static void func(int n, float *a, float *b, float *c) {155    int k1 = 0, k2 = 0;156#pragma omp for simd allocate(k1) safelen(LEN) linear(k1,k2:LEN) aligned(a:LEN) simdlen(LEN)157    for(int i = 0; i < n; i++) {158      c[i] = a[i] + b[i];159      c[k1] = a[k1] + b[k1];160      c[k2] = a[k2] + b[k2];161      k1 = k1 + LEN;162      k2 = k2 + LEN;163    }164  }165};166 167// S2<4>::func is called below in main.168// CHECK: template<> struct S2<4> {169// CHECK-NEXT: static void func(int n, float *a, float *b, float *c)     {170// CHECK-NEXT:   int k1 = 0, k2 = 0;171// CHECK-NEXT: #pragma omp for simd allocate(k1) safelen(4) linear(k1,k2: step(4)) aligned(a: 4) simdlen(4)172// CHECK-NEXT:   for (int i = 0; i < n; i++) {173// CHECK-NEXT:     c[i] = a[i] + b[i];174// CHECK-NEXT:     c[k1] = a[k1] + b[k1];175// CHECK-NEXT:     c[k2] = a[k2] + b[k2];176// CHECK-NEXT:     k1 = k1 + 4;177// CHECK-NEXT:     k2 = k2 + 4;178// CHECK-NEXT:   }179// CHECK-NEXT: }180 181int main (int argc, char **argv) {182  int b = argc, c, d, e, f, g;183  int k1=0,k2=0;184  static int *a;185// CHECK: static int *a;186#pragma omp for simd ordered187// CHECK-NEXT: #pragma omp for simd ordered188  for (int i=0; i < 2; ++i)*a=2;189// CHECK-NEXT: for (int i = 0; i < 2; ++i)190// CHECK-NEXT: *a = 2;191#pragma omp  parallel192#pragma omp for simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) ,firstprivate( g )193  for (int i = 0; i < 10; ++i)194  for (int j = 0; j < 10; ++j) {foo(); k1 += 8; k2 += 8;}195// CHECK-NEXT: #pragma omp parallel196// CHECK-NEXT: #pragma omp for simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) firstprivate(g)197// CHECK-NEXT: for (int i = 0; i < 10; ++i)198// CHECK-NEXT: for (int j = 0; j < 10; ++j) {199// CHECK-NEXT: foo();200// CHECK-NEXT: k1 += 8;201// CHECK-NEXT: k2 += 8;202// CHECK-NEXT: }203  for (int i = 0; i < 10; ++i)foo();204// CHECK-NEXT: for (int i = 0; i < 10; ++i)205// CHECK-NEXT: foo();206  const int CLEN = 4;207// CHECK-NEXT: const int CLEN = 4;208#ifdef OMP5209  #pragma omp for simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) simdlen(CLEN) if(simd:a)210#else211  #pragma omp for simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) simdlen(CLEN)212#endif213// OMP52-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN)214// OMP51-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN)215// OMP50-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN) if(simd: a)216// OMP45-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN)217  for (int i = 0; i < 10; ++i)foo();218// CHECK-NEXT: for (int i = 0; i < 10; ++i)219// CHECK-NEXT: foo();220 221  float arr[16];222  S2<4>::func(0,arr,arr,arr);223  return (0);224}225 226#endif227