llvm-project
148 строк · 3.3 Кб
1// RUN: %clang_cc1 -fopenmp -emit-pch -o %t.a %s
2// RUN: %clang_cc1 -fopenmp -include-pch %t.a %s -ast-print -o - | FileCheck %s
3
4// CHECK: #pragma clang loop vectorize_width(4)
5// CHECK: #pragma clang loop interleave_count(8)
6// CHECK: #pragma clang loop unroll_count(16){{$}}
7// CHECK: #pragma clang loop vectorize(enable)
8// CHECK: #pragma clang loop interleave(disable)
9// CHECK: #pragma clang loop unroll(disable)
10// CHECK: #pragma clang loop distribute(enable)
11// CHECK: #pragma clang loop vectorize(disable)
12// CHECK: #pragma clang loop interleave(enable)
13// CHECK: #pragma clang loop unroll(full)
14// CHECK: #pragma clang loop distribute(disable)
15// FIXME: "#pragma unroll (enable)" is invalid and is not the input source.
16// CHECK: #pragma unroll (enable){{$}}
17// CHECK: #pragma unroll (32){{$}}
18// CHECK: #pragma nounroll{{$}}
19// CHECK: #pragma clang loop vectorize_width(V)
20// CHECK: #pragma clang loop interleave_count(I)
21// CHECK: #pragma omp simd
22// CHECK: #pragma omp for
23// CHECK: #pragma omp distribute
24
25#ifndef HEADER26#define HEADER27
28class pragma_test {29public:30inline void run1(int *List, int Length) {31int i = 0;32#pragma clang loop vectorize_width(4)33#pragma clang loop interleave_count(8)34#pragma clang loop unroll_count(16)35while (i < Length) {36List[i] = i;37i++;38}39}40
41inline void run2(int *List, int Length) {42int i = 0;43#pragma clang loop vectorize(enable)44#pragma clang loop interleave(disable)45#pragma clang loop unroll(disable)46#pragma clang loop distribute(enable)47while (i - 1 < Length) {48List[i] = i;49i++;50}51}52
53inline void run3(int *List, int Length) {54int i = 0;55#pragma clang loop vectorize(disable)56#pragma clang loop interleave(enable)57#pragma clang loop unroll(full)58#pragma clang loop distribute(disable)59while (i - 3 < Length) {60List[i] = i;61i++;62}63}64
65inline void run4(int *List, int Length) {66int i = 0;67#pragma unroll68while (i - 3 < Length) {69List[i] = i;70i++;71}72}73
74inline void run5(int *List, int Length) {75int i = 0;76#pragma unroll 3277while (i - 3 < Length) {78List[i] = i;79i++;80}81}82
83inline void run6(int *List, int Length) {84int i = 0;85#pragma nounroll86while (i - 3 < Length) {87List[i] = i;88i++;89}90}91
92template <int V, int I>93inline void run7(int *List, int Length) {94#pragma clang loop vectorize_width(V)95#pragma clang loop interleave_count(I)96for (int i = 0; i < Length; i++) {97List[i] = i;98}99}100
101inline void run8(int *List, int Length) {102int i = 0;103#pragma omp loop bind(thread)104for (int i = 0; i < Length; i++) {105List[i] = i;106}107}108
109inline void run9(int *List, int Length) {110int i = 0;111#pragma omp loop bind(parallel)112for (int i = 0; i < Length; i++) {113List[i] = i;114}115}116
117inline void run10(int *List, int Length) {118int i = 0;119int j = 0;120#pragma omp teams121for (int i = 0; i < Length; i++) {122#pragma omp loop bind(teams)123for (int j = 0; j < Length; j++) {124List[i] = i+j;125}126}127}128
129};130#else131void test() {132int List[100];133
134pragma_test pt;135
136pt.run1(List, 100);137pt.run2(List, 100);138pt.run3(List, 100);139pt.run4(List, 100);140pt.run5(List, 100);141pt.run6(List, 100);142pt.run7<2, 4>(List, 100);143pt.run8(List, 100);144pt.run9(List, 100);145pt.run10(List, 100);146}
147
148#endif149