2019-03-22 03:35:27 +08:00
|
|
|
// 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
|
2019-05-21 23:11:58 +08:00
|
|
|
// 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 - -disable-llvm-optzns | FileCheck %s
|
2019-03-22 03:35:27 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
|
|
|
|
|
|
|
#pragma omp declare target
|
|
|
|
typedef void **omp_allocator_handle_t;
|
|
|
|
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-DAG: @{{.+}}St1{{.+}}b{{.+}} = external global i32,
|
2019-11-22 00:30:43 +08:00
|
|
|
// CHECK-DAG: @a ={{ hidden | }}global i32 0,
|
|
|
|
// CHECK-DAG: @b ={{ hidden | }}addrspace(4) global i32 0,
|
|
|
|
// CHECK-DAG: @c ={{ hidden | }}global i32 0,
|
|
|
|
// CHECK-DAG: @d ={{ hidden | }}global %struct.St1 zeroinitializer,
|
|
|
|
// CHECK-DAG: @{{.+}}ns{{.+}}a{{.+}} ={{ hidden | }}addrspace(3) global i32 0,
|
2019-03-22 03:35:27 +08:00
|
|
|
// CHECK-DAG: @{{.+}}main{{.+}}a{{.*}} = internal global i32 0,
|
|
|
|
// CHECK-DAG: @{{.+}}ST{{.+}}m{{.+}} = external global i32,
|
2019-04-09 00:53:57 +08:00
|
|
|
// CHECK-DAG: @bar_c = internal global i32 0,
|
|
|
|
// CHECK-DAG: @bar_b = internal addrspace(3) global double 0.000000e+00,
|
2019-03-22 03:35:27 +08:00
|
|
|
struct St{
|
|
|
|
int a;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct St1{
|
|
|
|
int a;
|
|
|
|
static int b;
|
|
|
|
#pragma omp allocate(b) allocator(omp_default_mem_alloc)
|
|
|
|
} d;
|
|
|
|
|
|
|
|
int a, b, c;
|
|
|
|
#pragma omp allocate(a) allocator(omp_large_cap_mem_alloc)
|
|
|
|
#pragma omp allocate(b) allocator(omp_const_mem_alloc)
|
|
|
|
#pragma omp allocate(d, c) allocator(omp_high_bw_mem_alloc)
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
struct ST {
|
|
|
|
static T m;
|
|
|
|
#pragma omp allocate(m) allocator(omp_low_lat_mem_alloc)
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> T foo() {
|
|
|
|
T v;
|
|
|
|
#pragma omp allocate(v) allocator(omp_cgroup_mem_alloc)
|
|
|
|
v = ST<T>::m;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ns{
|
|
|
|
int a;
|
|
|
|
}
|
|
|
|
#pragma omp allocate(ns::a) allocator(omp_pteam_mem_alloc)
|
|
|
|
|
2019-03-22 04:36:16 +08:00
|
|
|
// CHECK-LABEL: @main
|
2019-03-22 03:35:27 +08:00
|
|
|
int main () {
|
2019-03-22 04:36:16 +08:00
|
|
|
// CHECK: alloca double,
|
2019-03-22 03:35:27 +08:00
|
|
|
static int a;
|
|
|
|
#pragma omp allocate(a) allocator(omp_thread_mem_alloc)
|
|
|
|
a=2;
|
|
|
|
double b = 3;
|
2019-04-09 00:53:57 +08:00
|
|
|
float c;
|
2019-03-22 22:41:39 +08:00
|
|
|
#pragma omp allocate(b) allocator(omp_default_mem_alloc)
|
2019-04-09 00:53:57 +08:00
|
|
|
#pragma omp allocate(c) allocator(omp_cgroup_mem_alloc)
|
2019-03-22 03:35:27 +08:00
|
|
|
return (foo<int>());
|
|
|
|
}
|
|
|
|
|
2019-03-22 04:36:16 +08:00
|
|
|
// CHECK: define {{.*}}i32 @{{.+}}foo{{.+}}()
|
2019-04-09 00:53:57 +08:00
|
|
|
// CHECK-NOT: alloca i32,
|
2019-03-22 04:36:16 +08:00
|
|
|
|
2019-03-22 03:35:27 +08:00
|
|
|
extern template int ST<int>::m;
|
2019-04-09 00:53:57 +08:00
|
|
|
|
|
|
|
void baz(float &);
|
|
|
|
|
2019-11-22 00:30:43 +08:00
|
|
|
// CHECK: define{{ hidden | }}void @{{.+}}bar{{.+}}()
|
2019-04-09 00:53:57 +08:00
|
|
|
void bar() {
|
|
|
|
// CHECK: alloca float,
|
|
|
|
float bar_a;
|
|
|
|
// CHECK: alloca double,
|
|
|
|
double bar_b;
|
|
|
|
int bar_c;
|
|
|
|
#pragma omp allocate(bar_c) allocator(omp_cgroup_mem_alloc)
|
|
|
|
// CHECK: call void [[OUTLINED:@.+]](i32* %{{.+}}, i32* %{{.+}})
|
|
|
|
#pragma omp parallel private(bar_a, bar_b) allocate(omp_thread_mem_alloc \
|
|
|
|
: bar_a) allocate(omp_pteam_mem_alloc \
|
|
|
|
: bar_b)
|
|
|
|
{
|
|
|
|
bar_b = bar_a;
|
|
|
|
baz(bar_a);
|
|
|
|
}
|
|
|
|
// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}})
|
|
|
|
// CHECK-NOT: alloca double,
|
|
|
|
// CHECK: alloca float,
|
|
|
|
// CHECK-NOT: alloca double,
|
|
|
|
// CHECK: load float, float* %
|
|
|
|
// CHECK: store double {{.+}}, double addrspace(3)* @bar_b,
|
|
|
|
}
|
|
|
|
|
2019-03-22 03:35:27 +08:00
|
|
|
#pragma omp end declare target
|
|
|
|
#endif
|