blob: e9b9509334e7191045548777cbead9d459e3642c [file] [log] [blame]
Alexey Bataevc5687252019-03-21 19:35:27 +00001// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin10.6.0 -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc -o %t-host.bc %s
2// RUN: %clang_cc1 -verify -fopenmp -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s
3// expected-no-diagnostics
4
5#ifndef HEADER
6#define HEADER
7
8#pragma omp declare target
9typedef void **omp_allocator_handle_t;
10extern const omp_allocator_handle_t omp_default_mem_alloc;
11extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
12extern const omp_allocator_handle_t omp_const_mem_alloc;
13extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
14extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
15extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
16extern const omp_allocator_handle_t omp_pteam_mem_alloc;
17extern const omp_allocator_handle_t omp_thread_mem_alloc;
18
19// CHECK-DAG: @{{.+}}St1{{.+}}b{{.+}} = external global i32,
20// CHECK-DAG: @a = global i32 0,
21// CHECK-DAG: @b = addrspace(4) global i32 0,
22// CHECK-DAG: @c = global i32 0,
23// CHECK-DAG: @d = global %struct.St1 zeroinitializer,
24// CHECK-DAG: @{{.+}}ns{{.+}}a{{.+}} = addrspace(3) global i32 0,
25// CHECK-DAG: @{{.+}}main{{.+}}a{{.*}} = internal global i32 0,
26// CHECK-DAG: @{{.+}}ST{{.+}}m{{.+}} = external global i32,
27struct St{
28 int a;
29};
30
31struct St1{
32 int a;
33 static int b;
34#pragma omp allocate(b) allocator(omp_default_mem_alloc)
35} d;
36
37int a, b, c;
38#pragma omp allocate(a) allocator(omp_large_cap_mem_alloc)
39#pragma omp allocate(b) allocator(omp_const_mem_alloc)
40#pragma omp allocate(d, c) allocator(omp_high_bw_mem_alloc)
41
42template <class T>
43struct ST {
44 static T m;
45 #pragma omp allocate(m) allocator(omp_low_lat_mem_alloc)
46};
47
48template <class T> T foo() {
49 T v;
50 #pragma omp allocate(v) allocator(omp_cgroup_mem_alloc)
51 v = ST<T>::m;
52 return v;
53}
54
55namespace ns{
56 int a;
57}
58#pragma omp allocate(ns::a) allocator(omp_pteam_mem_alloc)
59
60int main () {
61 static int a;
62#pragma omp allocate(a) allocator(omp_thread_mem_alloc)
63 a=2;
64 double b = 3;
65#pragma omp allocate(b)
66 return (foo<int>());
67}
68
69extern template int ST<int>::m;
70#pragma omp end declare target
71#endif