diff options
Diffstat (limited to 'libgomp/testsuite/libgomp.c/cancel-parallel-3.c')
-rw-r--r-- | libgomp/testsuite/libgomp.c/cancel-parallel-3.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/cancel-parallel-3.c b/libgomp/testsuite/libgomp.c/cancel-parallel-3.c new file mode 100644 index 00000000000..7ceaed18467 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/cancel-parallel-3.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_CANCELLATION "true" } */ + +#include <omp.h> +#include <unistd.h> + +static inline void +do_some_work (void) +{ + asm volatile ("" : : : "memory"); +} + +int +main () +{ + omp_set_dynamic (0); + omp_set_schedule (omp_sched_static, 1); + #pragma omp parallel num_threads (16) + { + int i, j; + do_some_work (); + #pragma omp barrier + if (omp_get_thread_num () == 1) + { + sleep (2); + #pragma omp cancellation point parallel + } + for (j = 3; j <= 16; j++) + #pragma omp for schedule (runtime) nowait + for (i = 0; i < j; i++) + do_some_work (); + if (omp_get_thread_num () == 0) + { + sleep (1); + #pragma omp cancel parallel + } + } + return 0; +} |