1 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
2 // RUN: -fsyntax-only -verify %s
4 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
5 // RUN: -ast-print %s | FileCheck %s
7 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
8 // RUN: -emit-pch -o %t %s
10 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \
11 // RUN: -include-pch %t -ast-print %s | FileCheck %s
13 // expected-no-diagnostics
18 typedef void **omp_allocator_handle_t
;
19 extern const omp_allocator_handle_t omp_null_allocator
;
20 extern const omp_allocator_handle_t omp_default_mem_alloc
;
21 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
22 extern const omp_allocator_handle_t omp_const_mem_alloc
;
23 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
24 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
25 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
26 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
27 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
29 //CHECK: template <typename T, int C, int D> void templ_foo(T t) {
31 //CHECK: #pragma omp target parallel loop device(D) collapse(C) reduction(+: z) lastprivate(j) bind(thread) num_threads(C + 2)
32 //CHECK: for (T i = 0; i < t; ++i)
33 //CHECK: for (j = 0; j < t; ++j)
37 //CHECK: template<> void templ_foo<int, 2, 0>(int t) {
39 //CHECK: #pragma omp target parallel loop device(0) collapse(2) reduction(+: z) lastprivate(j) bind(thread) num_threads(2 + 2)
40 //CHECK: for (int i = 0; i < t; ++i)
41 //CHECK: for (j = 0; j < t; ++j)
44 template <typename T
, int C
, int D
>
48 #pragma omp target parallel loop device(D) collapse(C) reduction(+:z) lastprivate(j) bind(thread) num_threads(C+2)
49 for (T i
= 0; i
<t
; ++i
)
55 //CHECK: void test() {
57 constexpr int N
= 100;
61 //CHECK: #pragma omp target parallel loop map(tofrom: MTX)
62 #pragma omp target parallel loop map(MTX)
63 for (auto j
= 0; j
< N
; ++j
) {
68 //CHECK: #pragma omp target parallel loop collapse(2) private(z) lastprivate(j) order(concurrent) reduction(+: z1) bind(parallel)
69 #pragma omp target parallel loop collapse(2) private(z) lastprivate(j) \
70 order(concurrent) reduction(+:z1) bind(parallel)
71 for (auto i
= 0; i
< N
; ++i
) {
72 for (j
= 0; j
< N
; ++j
) {
79 //CHECK: #pragma omp target parallel loop bind(thread) num_threads(16) default(none)
80 #pragma omp target parallel loop bind(thread) num_threads(16) default(none)
81 for (auto i
= 0; i
< N
; ++i
) { }
85 //CHECK: #pragma omp target parallel loop private(zzz) uses_allocators(omp_default_mem_alloc) allocate(omp_default_mem_alloc: zzz) if(1) device(0) proc_bind(close) map(tofrom: pr)
86 #pragma omp target parallel loop private(zzz) uses_allocators(omp_default_mem_alloc) allocate(omp_default_mem_alloc:zzz) if(1) device(0) proc_bind(close) map(tofrom:pr)
87 for (int i
=0; i
<1000; ++i
) {
95 //CHECK: #pragma omp target parallel loop bind(thread) private(pr) firstprivate(fpr) shared(s) allocate(k) reduction(+: k)
96 #pragma omp target parallel loop bind(thread) private(pr) firstprivate(fpr) \
97 shared(s) allocate(k) reduction(+:k)
98 for (auto i
= 0; i
< N
; ++i
) {
103 //CHECK: #pragma omp target parallel loop map(tofrom: y) depend(out : y)
104 #pragma omp target parallel loop map(tofrom:y) depend(out:y)
105 for (int i
=0; i
<10; ++i
) {
110 //CHECK: void nobindingfunc() {
113 //CHECK: #pragma omp target parallel loop
114 #pragma omp target parallel loop
115 for (int i
=0; i
<10; ++i
) { }
120 templ_foo
<int,2,0>(8);