blob: 53bac3ced96b33e349e9e3b9cb9856845e041201 [file] [log] [blame]
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +00001// Test device data sharing codegen.
2///==========================================================================///
3
4// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
5// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CK1
6
7// expected-no-diagnostics
8
9#ifndef HEADER
10#define HEADER
11
12void test_ds(){
13 #pragma omp target
14 {
15 int a = 10;
16 #pragma omp parallel
17 {
18 a = 1000;
19 }
20 }
21}
22
23/// ========= In the worker function ========= ///
24
Gheorghe-Teodor Berceab4c74c62017-12-12 21:38:43 +000025// CK1: define internal void @__omp_offloading_{{.*}}test_ds{{.*}}worker() [[ATTR1:#.*]] {
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +000026// CK1: [[SHAREDARGS:%.+]] = alloca i8**
Jonas Hahnfeldfa059ba2017-12-27 10:39:56 +000027// CK1: call i1 @__kmpc_kernel_parallel(i8** %work_fn, i8*** [[SHAREDARGS]], i16 1)
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +000028// CK1: [[SHARGSTMP:%.+]] = load i8**, i8*** [[SHAREDARGS]]
Jonas Hahnfeldcfd162d2017-11-21 16:49:11 +000029// CK1: call void @__omp_outlined___wrapper{{.*}}({{.*}}, i8** [[SHARGSTMP]])
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +000030
31/// ========= In the kernel function ========= ///
32
Gheorghe-Teodor Berceab4c74c62017-12-12 21:38:43 +000033// CK1: {{.*}}define void @__omp_offloading{{.*}}test_ds{{.*}}() [[ATTR2:#.*]] {
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +000034// CK1: [[SHAREDARGS1:%.+]] = alloca i8**
Jonas Hahnfeldfa059ba2017-12-27 10:39:56 +000035// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i8*** [[SHAREDARGS1]], i32 1, i16 1)
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +000036// CK1: [[SHARGSTMP1:%.+]] = load i8**, i8*** [[SHAREDARGS1]]
37// CK1: [[SHARGSTMP2:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP1]]
38// CK1: [[SHAREDVAR:%.+]] = bitcast i32* {{.*}} to i8*
39// CK1: store i8* [[SHAREDVAR]], i8** [[SHARGSTMP2]]
40
41/// ========= In the data sharing wrapper function ========= ///
42
Gheorghe-Teodor Berceab4c74c62017-12-12 21:38:43 +000043// CK1: {{.*}}define internal void @__omp_outlined___wrapper({{.*}}i8**) [[ATTR1]] {
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +000044// CK1: [[SHAREDARGS2:%.+]] = alloca i8**
45// CK1: store i8** %2, i8*** [[SHAREDARGS2]]
46// CK1: [[SHARGSTMP3:%.+]] = load i8**, i8*** [[SHAREDARGS2]]
47// CK1: [[SHARGSTMP4:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP3]]
48// CK1: [[SHARGSTMP5:%.+]] = bitcast i8** [[SHARGSTMP4]] to i32**
49// CK1: [[SHARGSTMP6:%.+]] = load i32*, i32** [[SHARGSTMP5]]
50// CK1: call void @__omp_outlined__({{.*}}, i32* [[SHARGSTMP6]])
51
Gheorghe-Teodor Berceab4c74c62017-12-12 21:38:43 +000052/// ========= Attributes ========= ///
53
54// CK1-NOT: attributes [[ATTR1]] = { {{.*}}"has-nvptx-shared-depot"{{.*}} }
55// CK1: attributes [[ATTR2]] = { {{.*}}"has-nvptx-shared-depot"{{.*}} }
56
Jonas Hahnfeldcfd162d2017-11-21 16:49:11 +000057#endif