public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Subject: [PATCH 0/3] OpenMP: Support imperfectly-nested loops
Date: Fri, 28 Apr 2023 17:22:51 -0600	[thread overview]
Message-ID: <20230428232254.628185-1-sandra@codesourcery.com> (raw)

OpenMP 5.0 removed the restriction that collapsed loops in "omp
for/do" and related constructs must be perfectly nested; it now allows
intervening code to appear before/after each nested loop level.  The
spec allows implementations considerable freedom in how many times this
intervening code is executed, and it seemed to me that the simplest
solution was to push it all into the loop body so that it is executed
on every logical iteration.  Implementing this in the respective front
ends means that no changes are required in the OMP_FOR representation
or in subsequent gimplification and lowering passes.

For C and C++, I refactored the OMP_FOR parsing code to use recursive
descent and parallel the revised syntax in the OpenMP spec for
canonical loop nest form.  In C this was relatively straightforward,
but in C++ the code that handles nested scopes for class iterators
gave me fits.  I ended up parsing the entire construct and then
reassembling the bits of code, and I tried to make this at least
better-documented than the code that was previously there.  In the
Fortran front end, I implemented the transformation during resolution.

This patch series has some overlap with Frederik Harwath's tile/unroll
patch set, but has been developed and tested independently of those changes.

https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614564.html

Depending on what order they are reviewed/committed in, we will of
course take care of merging and retesting them together.  Frederik has
already reviewed my patches and gave me some very helpful feedback,
and Tobias also has helped out, especially when I got stuck on some
unrelated bugs.

-Sandra


Sandra Loosemore (3):
  OpenMP: C support for imperfectly-nested loops
  OpenMP: C++ support for imperfectly-nested loops
  OpenMP: Fortran support for imperfectly-nested loops

 gcc/c/c-parser.cc                             |  692 ++++++----
 gcc/cp/cp-tree.h                              |    2 +-
 gcc/cp/parser.cc                              | 1180 ++++++++++++-----
 gcc/cp/parser.h                               |    3 +
 gcc/cp/pt.cc                                  |    3 +-
 gcc/cp/semantics.cc                           |   80 +-
 gcc/fortran/openmp.cc                         |  590 +++++++--
 gcc/omp-api.h                                 |   32 +
 gcc/omp-general.cc                            |  134 ++
 gcc/omp-general.h                             |    1 +
 gcc/omp-low.cc                                |  129 --
 gcc/testsuite/c-c++-common/goacc/collapse-1.c |   14 +-
 gcc/testsuite/c-c++-common/goacc/tile-2.c     |    4 +-
 gcc/testsuite/c-c++-common/gomp/imperfect1.c  |   40 +
 gcc/testsuite/c-c++-common/gomp/imperfect2.c  |   36 +
 gcc/testsuite/c-c++-common/gomp/imperfect3.c  |   35 +
 gcc/testsuite/c-c++-common/gomp/imperfect4.c  |   35 +
 gcc/testsuite/c-c++-common/gomp/imperfect5.c  |   59 +
 gcc/testsuite/g++.dg/gomp/pr41967.C           |    2 +-
 gcc/testsuite/gcc.dg/gomp/collapse-1.c        |   10 +-
 gcc/testsuite/gfortran.dg/gomp/collapse1.f90  |    6 +-
 gcc/testsuite/gfortran.dg/gomp/collapse2.f90  |   10 +-
 gcc/testsuite/gfortran.dg/gomp/imperfect1.f90 |   39 +
 gcc/testsuite/gfortran.dg/gomp/imperfect2.f90 |   56 +
 gcc/testsuite/gfortran.dg/gomp/imperfect3.f90 |   29 +
 gcc/testsuite/gfortran.dg/gomp/imperfect4.f90 |   36 +
 gcc/testsuite/gfortran.dg/gomp/imperfect5.f90 |   67 +
 .../testsuite/libgomp.c++/imperfect-class-1.C |  169 +++
 .../testsuite/libgomp.c++/imperfect-class-2.C |  167 +++
 .../testsuite/libgomp.c++/imperfect-class-3.C |  167 +++
 .../libgomp.c++/imperfect-destructor.C        |  135 ++
 .../libgomp.c++/imperfect-template-1.C        |  172 +++
 .../libgomp.c++/imperfect-template-2.C        |  170 +++
 .../libgomp.c++/imperfect-template-3.C        |  170 +++
 .../libgomp.c-c++-common/imperfect1.c         |   76 ++
 .../libgomp.c-c++-common/imperfect2.c         |  114 ++
 .../libgomp.c-c++-common/imperfect3.c         |  119 ++
 .../libgomp.c-c++-common/imperfect4.c         |  117 ++
 .../libgomp.c-c++-common/imperfect5.c         |   49 +
 .../libgomp.c-c++-common/imperfect6.c         |  115 ++
 .../libgomp.c-c++-common/offload-imperfect1.c |   81 ++
 .../libgomp.c-c++-common/offload-imperfect2.c |  122 ++
 .../libgomp.c-c++-common/offload-imperfect3.c |  125 ++
 .../libgomp.c-c++-common/offload-imperfect4.c |  122 ++
 .../libgomp.fortran/imperfect-destructor.f90  |  142 ++
 .../testsuite/libgomp.fortran/imperfect1.f90  |   67 +
 .../testsuite/libgomp.fortran/imperfect2.f90  |  102 ++
 .../testsuite/libgomp.fortran/imperfect3.f90  |  110 ++
 .../testsuite/libgomp.fortran/imperfect4.f90  |  121 ++
 .../libgomp.fortran/offload-imperfect1.f90    |   72 +
 .../libgomp.fortran/offload-imperfect2.f90    |  110 ++
 .../libgomp.fortran/offload-imperfect3.f90    |  116 ++
 .../libgomp.fortran/offload-imperfect4.f90    |  126 ++
 53 files changed, 5588 insertions(+), 892 deletions(-)
 create mode 100644 gcc/omp-api.h
 create mode 100644 gcc/testsuite/c-c++-common/gomp/imperfect1.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/imperfect2.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/imperfect3.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/imperfect4.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/imperfect5.c
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/imperfect1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/imperfect2.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/imperfect3.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/imperfect4.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/imperfect5.f90
 create mode 100644 libgomp/testsuite/libgomp.c++/imperfect-class-1.C
 create mode 100644 libgomp/testsuite/libgomp.c++/imperfect-class-2.C
 create mode 100644 libgomp/testsuite/libgomp.c++/imperfect-class-3.C
 create mode 100644 libgomp/testsuite/libgomp.c++/imperfect-destructor.C
 create mode 100644 libgomp/testsuite/libgomp.c++/imperfect-template-1.C
 create mode 100644 libgomp/testsuite/libgomp.c++/imperfect-template-2.C
 create mode 100644 libgomp/testsuite/libgomp.c++/imperfect-template-3.C
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/imperfect1.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/imperfect2.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/imperfect3.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/imperfect4.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/imperfect5.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/imperfect6.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/offload-imperfect1.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/offload-imperfect2.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/offload-imperfect3.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/offload-imperfect4.c
 create mode 100644 libgomp/testsuite/libgomp.fortran/imperfect-destructor.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/imperfect1.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/imperfect2.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/imperfect3.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/imperfect4.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/offload-imperfect1.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/offload-imperfect2.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/offload-imperfect3.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/offload-imperfect4.f90

-- 
2.31.1


             reply	other threads:[~2023-04-28 23:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 23:22 Sandra Loosemore [this message]
2023-04-28 23:22 ` [PATCH 1/3] OpenMP: C support for " Sandra Loosemore
2023-05-25 10:00   ` Jakub Jelinek
2023-06-14 22:41     ` Sandra Loosemore
2023-04-28 23:22 ` [PATCH 2/3] OpenMP: C++ " Sandra Loosemore
2023-05-25 10:19   ` Jakub Jelinek
2023-04-28 23:22 ` [PATCH 3/3] OpenMP: Fortran " Sandra Loosemore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230428232254.628185-1-sandra@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).