diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2015-09-15 12:52:43 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-09-15 12:52:43 +0000 |
| commit | 25e5b4465494ff106fec9b5623e9d74e6b242e79 (patch) | |
| tree | b9e0e6b8773322f22b9c385b4e1c4783a5f95717 /clang/test/OpenMP/cancellation_point_codegen.cpp | |
| parent | 7d4038dc5a0a6095324d3f1462fc4402a8a6eac3 (diff) | |
| download | bcm5719-llvm-25e5b4465494ff106fec9b5623e9d74e6b242e79.tar.gz bcm5719-llvm-25e5b4465494ff106fec9b5623e9d74e6b242e79.zip | |
[OPENMP] Emit __kmpc_cancel_barrier() and code for 'cancellation point' only if 'cancel' is found.
Patch improves codegen for OpenMP constructs. If the OpenMP region does not have internal 'cancel' construct, a call to 'void __kmpc_barrier()' runtime function is generated for all implicit/explicit barriers. If the region has inner 'cancel' directive, then
```
if (__kmpc_cancel_barrier())
exit from outer construct;
```
code is generated.
Also, the code for 'canellation point' directive is not generated if parent directive does not have 'cancel' directive.
llvm-svn: 247681
Diffstat (limited to 'clang/test/OpenMP/cancellation_point_codegen.cpp')
| -rw-r--r-- | clang/test/OpenMP/cancellation_point_codegen.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/clang/test/OpenMP/cancellation_point_codegen.cpp b/clang/test/OpenMP/cancellation_point_codegen.cpp index 453393082ce..ee557fd065d 100644 --- a/clang/test/OpenMP/cancellation_point_codegen.cpp +++ b/clang/test/OpenMP/cancellation_point_codegen.cpp @@ -11,12 +11,16 @@ int main (int argc, char **argv) { #pragma omp parallel { #pragma omp cancellation point parallel +#pragma omp cancel parallel argv[0][0] = argc; } // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( #pragma omp sections { + { #pragma omp cancellation point sections +#pragma omp cancel sections + } } // CHECK: call i32 @__kmpc_single( // CHECK-NOT: @__kmpc_cancellationpoint @@ -28,6 +32,7 @@ int main (int argc, char **argv) { #pragma omp section { #pragma omp cancellation point sections +#pragma omp cancel sections } } // CHECK: call void @__kmpc_for_static_init_4( @@ -51,6 +56,7 @@ int main (int argc, char **argv) { #pragma omp for for (int i = 0; i < argc; ++i) { #pragma omp cancellation point for +#pragma omp cancel for } // CHECK: call void @__kmpc_for_static_init_4( // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 2) @@ -66,9 +72,36 @@ for (int i = 0; i < argc; ++i) { #pragma omp task { #pragma omp cancellation point taskgroup +#pragma omp cancel taskgroup } // CHECK: call i8* @__kmpc_omp_task_alloc( // CHECK: call i32 @__kmpc_omp_task( +#pragma omp parallel sections +{ + { +#pragma omp cancellation point sections +#pragma omp cancel sections + } +} +// CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( +#pragma omp parallel sections +{ + { +#pragma omp cancellation point sections +#pragma omp cancel sections + } +#pragma omp section + { +#pragma omp cancellation point sections + } +} +// CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( +#pragma omp parallel for +for (int i = 0; i < argc; ++i) { +#pragma omp cancellation point for +#pragma omp cancel for +} +// CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( return argc; } @@ -92,4 +125,46 @@ for (int i = 0; i < argc; ++i) { // CHECK: [[RETURN]] // CHECK: ret i32 0 +// CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}}) +// CHECK: call i32 @__kmpc_single( +// CHECK-NOT: @__kmpc_cancellationpoint +// CHECK: call void @__kmpc_end_single( +// CHECK: call void @__kmpc_barrier(%ident_t* +// CHECK: ret void + +// CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}}) +// CHECK: call void @__kmpc_for_static_init_4( +// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 3) +// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 +// CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] +// CHECK: [[EXIT]] +// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* +// CHECK: br label +// CHECK: [[CONTINUE]] +// CHECK: br label +// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3) +// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 +// CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] +// CHECK: [[EXIT]] +// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* +// CHECK: br label +// CHECK: [[CONTINUE]] +// CHECK: br label +// CHECK: call void @__kmpc_for_static_fini( +// CHECK: ret void + +// CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}}, +// CHECK: call void @__kmpc_for_static_init_4( +// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 2) +// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0 +// CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]] +// CHECK: [[EXIT]] +// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t* +// CHECK: br label +// CHECK: [[CONTINUE]] +// CHECK: br label +// CHECK: call void @__kmpc_for_static_fini( +// CHECK: call void @__kmpc_barrier(%ident_t* +// CHECK: ret void + #endif |

