1 // 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 9 typedef void **omp_allocator_handle_t; 10 extern const omp_allocator_handle_t omp_default_mem_alloc; 11 extern const omp_allocator_handle_t omp_large_cap_mem_alloc; 12 extern const omp_allocator_handle_t omp_const_mem_alloc; 13 extern const omp_allocator_handle_t omp_high_bw_mem_alloc; 14 extern const omp_allocator_handle_t omp_low_lat_mem_alloc; 15 extern const omp_allocator_handle_t omp_cgroup_mem_alloc; 16 extern const omp_allocator_handle_t omp_pteam_mem_alloc; 17 extern 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, 27 struct St{ 28 int a; 29 }; 30 31 struct St1{ 32 int a; 33 static int b; 34 #pragma omp allocate(b) allocator(omp_default_mem_alloc) 35 } d; 36 37 int 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 42 template <class T> 43 struct ST { 44 static T m; 45 #pragma omp allocate(m) allocator(omp_low_lat_mem_alloc) 46 }; 47 48 template <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 55 namespace ns{ 56 int a; 57 } 58 #pragma omp allocate(ns::a) allocator(omp_pteam_mem_alloc) 59 60 // CHECK-LABEL: @main 61 int main () { 62 // CHECK: alloca double, 63 static int a; 64 #pragma omp allocate(a) allocator(omp_thread_mem_alloc) 65 a=2; 66 double b = 3; 67 #pragma omp allocate(b) allocator(omp_default_mem_alloc) 68 return (foo<int>()); 69 } 70 71 // CHECK: define {{.*}}i32 @{{.+}}foo{{.+}}() 72 // CHECK: alloca i32, 73 74 extern template int ST<int>::m; 75 #pragma omp end declare target 76 #endif 77