From: Jakub Jelinek Date: Sun, 2 Dec 2018 12:48:42 +0000 (+0100) Subject: omp-low.c (check_omp_nesting_restrictions): Allow cancel or cancellation point with... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=daa8c1d763c951d2242e1842be80b179f63ebad2;p=gcc.git omp-low.c (check_omp_nesting_restrictions): Allow cancel or cancellation point with taskgroup clause inside of taskloop. * omp-low.c (check_omp_nesting_restrictions): Allow cancel or cancellation point with taskgroup clause inside of taskloop. Consider a taskloop construct without nogroup clause as implicit taskgroup for diagnostics if cancel/cancellation point with taskgroup clause is closely nested inside of taskgroup region. * c-c++-common/gomp/cancel-1.c (f2): Add various taskloop related tests. * testsuite/libgomp.c-c++-common/cancel-taskgroup-4.c: New test. From-SVN: r266722 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e80e1ddd1ac..a13d8a52ee8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2018-12-02 Jakub Jelinek + * omp-low.c (check_omp_nesting_restrictions): Allow cancel or + cancellation point with taskgroup clause inside of taskloop. Consider + a taskloop construct without nogroup clause as implicit taskgroup for + diagnostics if cancel/cancellation point with taskgroup clause is + closely nested inside of taskgroup region. + PR sanitizer/88291 * asan.c (asan_clear_shadow): Move assert that len is multiple of 4 to the start of the function. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index ca78d7abe26..b406ce781f6 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2744,7 +2744,10 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) kind = "sections"; break; case 8: - if (gimple_code (ctx->stmt) != GIMPLE_OMP_TASK) + if (!is_task_ctx (ctx) + && (!is_taskloop_ctx (ctx) + || ctx->outer == NULL + || !is_task_ctx (ctx->outer))) bad = "#pragma omp task"; else { @@ -2767,6 +2770,17 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) "nested inside of % region", construct); return false; + case GIMPLE_OMP_TASK: + if (gimple_omp_task_taskloop_p (octx->stmt) + && octx->outer + && is_taskloop_ctx (octx->outer)) + { + tree clauses + = gimple_omp_for_clauses (octx->outer->stmt); + if (!omp_find_clause (clauses, OMP_CLAUSE_NOGROUP)) + break; + } + continue; default: continue; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 916cb5579c7..89dc430c1dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-12-02 Jakub Jelinek + * c-c++-common/gomp/cancel-1.c (f2): Add various taskloop related + tests. + PR sanitizer/88291 * c-c++-common/asan/pr88291.c: New test. diff --git a/gcc/testsuite/c-c++-common/gomp/cancel-1.c b/gcc/testsuite/c-c++-common/gomp/cancel-1.c index d26fcf1e226..03aedeb0822 100644 --- a/gcc/testsuite/c-c++-common/gomp/cancel-1.c +++ b/gcc/testsuite/c-c++-common/gomp/cancel-1.c @@ -95,6 +95,40 @@ f2 (void) #pragma omp cancellation point sections /* { dg-error "not closely nested inside" } */ #pragma omp cancellation point taskgroup } + #pragma omp taskloop + for (i = 0; i < 10; i++) + { + #pragma omp cancel parallel /* { dg-error "not closely nested inside" } */ + #pragma omp cancel for /* { dg-error "not closely nested inside" } */ + #pragma omp cancel sections /* { dg-error "not closely nested inside" } */ + #pragma omp cancel taskgroup + #pragma omp cancellation point parallel /* { dg-error "not closely nested inside" } */ + #pragma omp cancellation point for /* { dg-error "not closely nested inside" } */ + #pragma omp cancellation point sections /* { dg-error "not closely nested inside" } */ + #pragma omp cancellation point taskgroup + #pragma omp task + { + #pragma omp cancellation point taskgroup + #pragma omp cancel taskgroup + } + } + #pragma omp taskloop nogroup + for (i = 0; i < 10; i++) + { + #pragma omp cancel parallel /* { dg-error "not closely nested inside" } */ + #pragma omp cancel for /* { dg-error "not closely nested inside" } */ + #pragma omp cancel sections /* { dg-error "not closely nested inside" } */ + #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + #pragma omp cancellation point parallel /* { dg-error "not closely nested inside" } */ + #pragma omp cancellation point for /* { dg-error "not closely nested inside" } */ + #pragma omp cancellation point sections /* { dg-error "not closely nested inside" } */ + #pragma omp cancellation point taskgroup/* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + #pragma omp task + { + #pragma omp cancellation point taskgroup/* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + } + } #pragma omp taskgroup { #pragma omp task @@ -105,6 +139,17 @@ f2 (void) #pragma omp cancel taskgroup } } + #pragma omp taskloop nogroup + for (i = 0; i < 10; i++) + { + #pragma omp task + { + #pragma omp cancellation point taskgroup + #pragma omp cancel taskgroup + } + #pragma omp cancellation point taskgroup + #pragma omp cancel taskgroup + } } #pragma omp taskgroup { @@ -115,6 +160,18 @@ f2 (void) #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ } + #pragma omp taskloop + for (i = 0; i < 10; i++) + { + #pragma omp cancel taskgroup + #pragma omp cancellation point taskgroup + } + #pragma omp taskloop nogroup + for (i = 0; i < 10; i++) + { + #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + } } #pragma omp target { @@ -144,6 +201,45 @@ f2 (void) } } } + #pragma omp taskloop + for (i = 0; i < 10; i++) + { + #pragma omp parallel + { + #pragma omp task + { + #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + } + } + #pragma omp target + { + #pragma omp task + { + #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + } + } + #pragma omp target + #pragma omp teams + #pragma omp distribute + for (j = 0; j < 10; j++) + { + #pragma omp task + { + #pragma omp cancel taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + #pragma omp cancellation point taskgroup /* { dg-error "construct not closely nested inside of .taskgroup. region" } */ + } + } + #pragma omp target data map(i) + { + #pragma omp task + { + #pragma omp cancel taskgroup + #pragma omp cancellation point taskgroup + } + } + } #pragma omp for for (i = 0; i < 10; i++) { diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index d095a196fb6..9a6d9a3dd06 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,7 @@ +2018-12-02 Jakub Jelinek + + * testsuite/libgomp.c-c++-common/cancel-taskgroup-4.c: New test. + 2018-11-30 Cesar Philippidis PR libgomp/88288 diff --git a/libgomp/testsuite/libgomp.c-c++-common/cancel-taskgroup-4.c b/libgomp/testsuite/libgomp.c-c++-common/cancel-taskgroup-4.c new file mode 100644 index 00000000000..341bfb84ea8 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/cancel-taskgroup-4.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_CANCELLATION "true" } */ + +#include +#include +#include + +int +main () +{ + int i; + #pragma omp parallel + { + int c = 0; + #pragma omp barrier + #pragma omp master taskloop num_tasks (25) firstprivate (c) + for (i = 0; i < 50; i++) + { + if (c && omp_get_cancellation ()) + abort (); + #pragma omp cancellation point taskgroup + usleep (30); + if (i > 10) + c = 1; + #pragma omp cancel taskgroup if (i > 10) + if (i > 10 && omp_get_cancellation ()) + abort (); + } + usleep (10); + } + return 0; +}