Skip to content

Commit 0e8d4d5

Browse files
committed
[OpenMP] New Clang tests for 'taskgraph' directive
This patch adds two simple tests for parsing/serialization/deserialization and codegen for the OpenMP 'taskgraph' directive (for the current record-and-replay based implementation).
1 parent 1837237 commit 0e8d4d5

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
2+
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3+
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
4+
// expected-no-diagnostics
5+
6+
#ifndef HEADER
7+
#define HEADER
8+
9+
int main() {
10+
int x = 0, y = 0;
11+
12+
#pragma omp taskgraph
13+
// CHECK: #pragma omp taskgraph
14+
{
15+
#pragma omp task depend(in: x) depend(out: y)
16+
// CHECK: #pragma omp task depend(in : x) depend(out : y)
17+
{
18+
y = x;
19+
}
20+
#pragma omp task depend(inout: x, y)
21+
// CHECK: #pragma omp task depend(inout : x,y)
22+
{
23+
x++;
24+
y++;
25+
}
26+
}
27+
28+
return 0;
29+
}
30+
31+
#endif
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --functions "main" --replace-value-regex "[0-9][0-9][0-9]+" --prefix-filecheck-ir-name _
2+
3+
// FIXME: The hash used to identify taskgraph regions (the fourth argument of
4+
// __kmpc_taskgraph) is unstable between the two compiler invocations below,
5+
// and furthermore is a little hard to identify with update_cc_test_checks.py.
6+
// The above works for now, but it's not ideal.
7+
8+
// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
9+
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
10+
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
11+
// expected-no-diagnostics
12+
13+
#ifndef HEADER
14+
#define HEADER
15+
16+
// CHECK-LABEL: @main(
17+
// CHECK-NEXT: entry:
18+
// CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
19+
// CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
20+
// CHECK-NEXT: [[Y:%.*]] = alloca i32, align 4
21+
// CHECK-NEXT: [[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 8
22+
// CHECK-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
23+
// CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4
24+
// CHECK-NEXT: store i32 0, ptr [[X]], align 4
25+
// CHECK-NEXT: store i32 0, ptr [[Y]], align 4
26+
// CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw [[STRUCT_ANON]], ptr [[AGG_CAPTURED]], i32 0, i32 0
27+
// CHECK-NEXT: store ptr [[X]], ptr [[TMP1]], align 8
28+
// CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw [[STRUCT_ANON]], ptr [[AGG_CAPTURED]], i32 0, i32 1
29+
// CHECK-NEXT: store ptr [[Y]], ptr [[TMP2]], align 8
30+
// CHECK-NEXT: call void @__kmpc_taskgraph(ptr @[[GLOB1]], i32 [[TMP0]], i32 0, i32 {{[0-9][0-9][0-9]+}}, ptr @taskgraph.omp_outlined., ptr [[AGG_CAPTURED]])
31+
// CHECK-NEXT: ret i32 0
32+
//
33+
int main() {
34+
int x = 0, y = 0;
35+
36+
#pragma omp taskgraph
37+
{
38+
#pragma omp task depend(in: x) depend(out: y)
39+
{
40+
y = x;
41+
}
42+
#pragma omp task depend(inout: x, y)
43+
{
44+
x++;
45+
y++;
46+
}
47+
}
48+
49+
return 0;
50+
}
51+
52+
#endif

0 commit comments

Comments
 (0)