Clang Project

clang_source_code/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
1// add -fopenmp-targets
2
3// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
4// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
5// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
6
7// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
8// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
9// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
10// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
11// expected-no-diagnostics
12#ifndef HEADER
13#define HEADER
14
15typedef __INTPTR_TYPE__ intptr_t;
16
17// CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
18// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
19// CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
20
21void foo();
22
23struct S {
24  intptr_t a, b, c;
25  S(intptr_t a) : a(a) {}
26  operator char() { return a; }
27  ~S() {}
28};
29
30template <typename T>
31T tmain() {
32#pragma omp target
33#pragma omp teams
34#pragma omp distribute parallel for simd proc_bind(master)
35  for(int i = 0; i < 1000; i++) {}
36  return T();
37}
38
39int main() {
40  // CHECK-LABEL: @main
41#pragma omp target
42#pragma omp teams
43#pragma omp distribute parallel for simd proc_bind(spread)
44  for(int i = 0; i < 1000; i++) {}
45#pragma omp target
46#pragma omp teams
47#pragma omp distribute parallel for simd proc_bind(close)
48  for(int i = 0; i < 1000; i++) {}
49  return tmain<int>();
50}
51
52// CHECK: call {{.*}}@__tgt_target_teams({{.+}})
53// CHECK: call void [[OFFL1:@.+]]()
54// CHECK: call {{.*}}@__tgt_target_teams({{.+}})
55// CHECK: call void [[OFFL2:@.+]]()
56// CHECK: [[CALL_RET:%.+]] = call{{.+}} i32 [[TMAIN:@.+]]()
57// CHECK: ret i32 [[CALL_RET]]
58
59// CHECK: define{{.+}} void [[OFFL1]](
60// CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}}* [[OMP_OUTLINED_1:@.+]] to {{.+}})
61
62// CHECK: define{{.+}} [[OMP_OUTLINED_1]](i32* {{.+}} [[GTID_IN:%.+]],
63// CHECK: [[GTID_ADDR:%.+]] = alloca i32*,
64// CHECK: store i32* [[GTID_IN]], i32** [[GTID_ADDR]],
65// CHECK: [[GTID_REF:%.+]] = load i32*, i32** [[GTID_ADDR]],
66// CHECK: [[GTID_VAL:%.+]] = load i32, i32* [[GTID_REF]],
67// CHECK: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID_VAL]], i32 4)
68// CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
69// CHECK: ret void
70
71// CHECK: define{{.+}} [[OFFL2]]()
72// CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}}* [[OMP_OUTLINED_1:@.+]] to {{.+}})
73
74// CHECK: define{{.+}} [[OMP_OUTLINED_1]](i32* {{.+}} [[GTID_IN:%.+]],
75// CHECK: [[GTID_ADDR:%.+]] = alloca i32*,
76// CHECK: store i32* [[GTID_IN]], i32** [[GTID_ADDR]],
77// CHECK: [[GTID_REF:%.+]] = load i32*, i32** [[GTID_ADDR]],
78// CHECK: [[GTID_VAL:%.+]] = load i32, i32* [[GTID_REF]],
79// CHECK: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID_VAL]], i32 3)
80// CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
81// CHECK: ret void
82
83// CHECK: define{{.+}} [[TMAIN]]()
84// CHECK: call {{.*}}@__tgt_target_teams({{.+}})
85// CHECK: call void [[OFFL3:@.+]]()
86
87// CHECK: define{{.+}} [[OFFL3]]()
88// CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}}* [[OMP_OUTLINED_3:@.+]] to {{.+}})
89
90// CHECK: define{{.+}} [[OMP_OUTLINED_3]](i32* {{.+}} [[GTID_IN:%.+]],
91// CHECK: [[GTID_ADDR:%.+]] = alloca i32*,
92// CHECK: store i32* [[GTID_IN]], i32** [[GTID_ADDR]],
93// CHECK: [[GTID_REF:%.+]] = load i32*, i32** [[GTID_ADDR]],
94// CHECK: [[GTID_VAL:%.+]] = load i32, i32* [[GTID_REF]],
95// CHECK: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID_VAL]], i32 2)
96// CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
97// CHECK: ret void
98#endif
99