1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
// RUN: -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
// RUN: -ast-print %s | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
// RUN: -emit-pch -o %t %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \
// RUN: -include-pch %t -ast-print %s | FileCheck %s
// expected-no-diagnostics
#ifndef HEADER
#define HEADER
typedef void **omp_allocator_handle_t;
extern const omp_allocator_handle_t omp_null_allocator;
extern const omp_allocator_handle_t omp_default_mem_alloc;
extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
extern const omp_allocator_handle_t omp_const_mem_alloc;
extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
extern const omp_allocator_handle_t omp_pteam_mem_alloc;
extern const omp_allocator_handle_t omp_thread_mem_alloc;
//CHECK: template <typename T, int C> void templ_foo(T t) {
//CHECK: T j, z;
//CHECK: #pragma omp parallel loop collapse(C) reduction(+: z) lastprivate(j) bind(thread)
//CHECK: for (T i = 0; i < t; ++i)
//CHECK: for (j = 0; j < t; ++j)
//CHECK: z += i + j;
//CHECK: }
//CHECK: template<> void templ_foo<int, 2>(int t) {
//CHECK: int j, z;
//CHECK: #pragma omp parallel loop collapse(2) reduction(+: z) lastprivate(j) bind(thread)
//CHECK: for (int i = 0; i < t; ++i)
//CHECK: for (j = 0; j < t; ++j)
//CHECK: z += i + j;
//CHECK: }
template <typename T, int C>
void templ_foo(T t) {
T j,z;
#pragma omp parallel loop collapse(C) reduction(+:z) lastprivate(j) bind(thread)
for (T i = 0; i<t; ++i)
for (j = 0; j<t; ++j)
z += i+j;
}
//CHECK: void test() {
void test() {
constexpr int N = 100;
float MTX[N][N];
int aaa[1000];
//CHECK: #pragma omp target teams distribute parallel for map(tofrom: MTX)
//CHECK: #pragma omp parallel loop
#pragma omp target teams distribute parallel for map(MTX)
for (auto i = 0; i < N; ++i) {
#pragma omp parallel loop
for (auto j = 0; j < N; ++j) {
MTX[i][j] = 0;
}
}
//CHECK: #pragma omp target teams
//CHECK: #pragma omp parallel loop
#pragma omp target teams
for (int i=0; i<1000; ++i) {
#pragma omp parallel loop
for (int j=0; j<100; j++) {
aaa[i] += i + j;
}
}
int j, z, z1, z2 = 1, z3 = 2;
//CHECK: #pragma omp parallel loop collapse(2) private(z) lastprivate(j) order(concurrent) firstprivate(z2) num_threads(4) if(1) allocate(omp_default_mem_alloc: z2) shared(z3) reduction(+: z1) bind(parallel) proc_bind(primary)
#pragma omp parallel loop collapse(2) private(z) lastprivate(j) \
order(concurrent) firstprivate(z2) num_threads(4) if(1) \
allocate(omp_default_mem_alloc:z2) shared(z3) \
reduction(+:z1) bind(parallel) proc_bind(primary)
for (auto i = 0; i < N; ++i) {
for (j = 0; j < N; ++j) {
z = i+j;
MTX[i][j] = z;
z1 += z;
}
}
//CHECK: #pragma omp target teams
//CHECK: #pragma omp parallel loop bind(teams)
#pragma omp target teams
#pragma omp parallel loop bind(teams)
for (auto i = 0; i < N; ++i) { }
//CHECK: #pragma omp target
//CHECK: #pragma omp teams
//CHECK: #pragma omp parallel loop bind(teams)
#pragma omp target
#pragma omp teams
#pragma omp parallel loop bind(teams)
for (auto i = 0; i < N; ++i) { }
}
//CHECK: void nobindingfunc() {
void nobindingfunc()
{
//CHECK: #pragma omp parallel loop
#pragma omp parallel loop
for (int i=0; i<10; ++i) { }
}
void bar()
{
templ_foo<int,2>(8);
}
#endif // HEADER
|