2018-XX-YY Cesar Philippidis gcc/ * omp-offload.c (inform_oacc_loop): New function. (execute_oacc_device_lower): Use it to display loop parallelism. gcc/testsuite/ * c-c++-common/goacc/note-parallelism.c: New test. * gfortran.dg/goacc/note-parallelism.f90: New test. (cherry picked from gomp-4_0-branch r245683, and gcc/testsuite/ parts of r245770) use MSG_OPTIMIZED_LOCATIONS instead of MSG_NOTE --- gcc/omp-offload.c | 27 ++++++++ .../c-c++-common/goacc/note-parallelism.c | 61 ++++++++++++++++++ .../gfortran.dg/goacc/note-parallelism.f90 | 62 +++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/goacc/note-parallelism.c create mode 100644 gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90 diff --git a/gcc/omp-offload.c b/gcc/omp-offload.c index 0abf0283c9e..3582dda3d1a 100644 --- a/gcc/omp-offload.c +++ b/gcc/omp-offload.c @@ -866,6 +866,31 @@ debug_oacc_loop (oacc_loop *loop) dump_oacc_loop (stderr, loop, 0); } +/* Provide diagnostics on OpenACC loops LOOP, its siblings and its + children. */ + +static void +inform_oacc_loop (oacc_loop *loop) +{ + const char *seq = loop->mask == 0 ? " seq" : ""; + const char *gang = loop->mask & GOMP_DIM_MASK (GOMP_DIM_GANG) + ? " gang" : ""; + const char *worker = loop->mask & GOMP_DIM_MASK (GOMP_DIM_WORKER) + ? " worker" : ""; + const char *vector = loop->mask & GOMP_DIM_MASK (GOMP_DIM_VECTOR) + ? " vector" : ""; + dump_location_t loc = dump_location_t::from_location_t (loop->loc); + + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + "Detected parallelism \n", seq, gang, + worker, vector); + + if (loop->child) + inform_oacc_loop (loop->child); + if (loop->sibling) + inform_oacc_loop (loop->sibling); +} + /* DFS walk of basic blocks BB onwards, creating OpenACC loop structures as we go. By construction these loops are properly nested. */ @@ -1533,6 +1558,8 @@ execute_oacc_device_lower () dump_oacc_loop (dump_file, loops, 0); fprintf (dump_file, "\n"); } + if (dump_enabled_p () && loops->child) + inform_oacc_loop (loops->child); /* Offloaded targets may introduce new basic blocks, which require dominance information to update SSA. */ diff --git a/gcc/testsuite/c-c++-common/goacc/note-parallelism.c b/gcc/testsuite/c-c++-common/goacc/note-parallelism.c new file mode 100644 index 00000000000..2e50d86cd23 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/note-parallelism.c @@ -0,0 +1,61 @@ +/* Test the output of -fopt-info-note-omp. */ + +/* { dg-additional-options "-fopt-info-note-optimized" } */ + +int +main () +{ + int x, y, z; + +#pragma acc parallel loop seq /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop gang /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop worker /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop vector /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop gang vector /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop gang worker /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop worker vector /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop gang worker vector /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) + ; + +#pragma acc parallel loop /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) +#pragma acc loop /* { dg-message "note: Detected parallelism " } */ + for (y = 0; y < 10; y++) + ; + +#pragma acc parallel loop gang /* { dg-message "note: Detected parallelism " } */ + for (x = 0; x < 10; x++) +#pragma acc loop worker /* { dg-message "note: Detected parallelism " } */ + for (y = 0; y < 10; y++) +#pragma acc loop vector /* { dg-message "note: Detected parallelism " } */ + for (z = 0; z < 10; z++) + ; + + return 0; +} diff --git a/gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90 b/gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90 new file mode 100644 index 00000000000..2029abfa939 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90 @@ -0,0 +1,62 @@ +! Test the output of -fopt-info-note-omp. + +! { dg-additional-options "-fopt-info-note-optimized" } + +program test + implicit none + + integer x, y, z + + !$acc parallel loop seq ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop gang ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop worker ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop vector ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop gang vector ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop gang worker ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop worker vector ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop gang worker vector ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + end do + + !$acc parallel loop ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + !$acc loop ! { dg-message "note: Detected parallelism " } + do y = 1, 10 + end do + end do + + !$acc parallel loop gang ! { dg-message "note: Detected parallelism " } + do x = 1, 10 + !$acc loop worker ! { dg-message "note: Detected parallelism " } + do y = 1, 10 + !$acc loop vector ! { dg-message "note: Detected parallelism " } + do z = 1, 10 + end do + end do + end do +end program test -- 2.17.1