[0/8] OpenMP: Implement metadirective support

Message ID 20240106185257.126445-1-sandra@codesourcery.com
Headers
Series OpenMP: Implement metadirective support |

Message

Sandra Loosemore Jan. 6, 2024, 6:52 p.m. UTC
  This patch set adds support for metadirectives and dynamic selectors
in metadirectives.  To give credit where it's due, this is primarily
Kwok's work, originally posted 2+ years ago (and WIP for some time
before that):

https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586600.html

There's also currently an improved version of those patches on the
OG13 branch, along with several followup bug fixes contributed by
others.

My contributions have been collecting, rebasing, and refactoring all
the patches, adding the missing attribute syntax and template support
to the C++ front end, fixing more bugs, adding documentation, and
making some improvements to the internal engineering aspect of the
code.

Although the original patches were posted long ago, I suspect it is
now too late in the release cycle for this feature to make it into GCC
14, although it would certainly make users happy if it could be
squeezed in.  Another concern is that I'm facing some short-term
disruptions in my ability to continue work on this and I need to at
least publish the current patches so they don't get lost in the
shuffle.  Plus, if this patch set doesn't make it into GCC 14, it will
still be useful as a better starting point for OG14 than the patch set
currently on OG13.

In terms of what is still missing:

- Dynamic context selectors are currently supported only by
  metadirective and not declare variant.
- The C and C++ front ends attempt to do early resolution of
  metadirectives at parse time, but the Fortran front end does not do
  that yet.
- IIUC the construct selector set is supposed to allow you to specify
  the name of any OpenMP construct, but it only recognizes a small subset.
- Needs more test cases.  (Everything always needs more test cases.)
- Other unimplemented features beyond what was specified in OpenMP 5.1???

BTW, I'm aware that there are some open Bugzilla issues relating to
the OG13 implementation of metadirectives, at least PRs 112779,
107067, and 106730, although I haven't investigated or worked on any
of those directly.  I do know that at least items (a) and (h) from PR
112779 have been fixed in this patch set, though.

Anyway, I think it would be reasonable to do the missing features and
bug fixes and follow-up patches rather than continuing to sit on the
entire patch set until it's complete and perfect in every way.  :-)

-Sandra


Kwok Cheung Yeung (7):
  OpenMP: metadirective tree data structures and front-end interfaces
  OpenMP: middle-end support for metadirectives
  libgomp: runtime support for target_device selector
  OpenMP: C front end support for metadirectives
  OpenMP: C++ front-end support for metadirectives
  OpenMP: common c/c++ testcases for metadirectives
  OpenMP: Fortran front-end support for metadirectives.

Sandra Loosemore (1):
  OpenMP: Update documentation of metadirective implementation status.

 gcc/Makefile.in                               |   2 +-
 gcc/builtin-types.def                         |   2 +
 gcc/c-family/c-common.h                       |   4 +-
 gcc/c-family/c-gimplify.cc                    |  27 +
 gcc/c-family/c-omp.cc                         |  60 +-
 gcc/c-family/c-pragma.cc                      |   1 +
 gcc/c-family/c-pragma.h                       |   1 +
 gcc/c/c-parser.cc                             | 493 ++++++++++++++-
 gcc/cgraph.h                                  |   3 +
 gcc/cgraphclones.cc                           |   1 +
 gcc/cp/decl.cc                                |   2 +-
 gcc/cp/parser.cc                              | 526 +++++++++++++++-
 gcc/cp/parser.h                               |   7 +
 gcc/cp/pt.cc                                  | 118 ++++
 gcc/doc/generic.texi                          |  32 +
 gcc/fortran/decl.cc                           |  29 +
 gcc/fortran/dump-parse-tree.cc                |  21 +
 gcc/fortran/gfortran.h                        |  24 +-
 gcc/fortran/io.cc                             |   2 +-
 gcc/fortran/match.h                           |   2 +
 gcc/fortran/openmp.cc                         | 265 +++++++-
 gcc/fortran/parse.cc                          | 571 +++++++++++-------
 gcc/fortran/parse.h                           |   8 +-
 gcc/fortran/resolve.cc                        |   6 +
 gcc/fortran/st.cc                             |   4 +
 gcc/fortran/symbol.cc                         |  25 +-
 gcc/fortran/trans-decl.cc                     |   5 +-
 gcc/fortran/trans-openmp.cc                   | 243 +++++---
 gcc/fortran/trans-stmt.h                      |   1 +
 gcc/fortran/trans.cc                          |   1 +
 gcc/fortran/types.def                         |   2 +
 gcc/gimple-low.cc                             |  36 ++
 gcc/gimple-pretty-print.cc                    |  64 ++
 gcc/gimple-streamer-in.cc                     |  10 +
 gcc/gimple-streamer-out.cc                    |   6 +
 gcc/gimple-walk.cc                            |  28 +
 gcc/gimple.cc                                 |  35 ++
 gcc/gimple.def                                |   7 +
 gcc/gimple.h                                  | 100 ++-
 gcc/gimplify.cc                               | 184 ++++++
 gcc/gsstruct.def                              |   2 +
 gcc/lto-cgraph.cc                             |   2 +
 gcc/omp-builtins.def                          |   3 +
 gcc/omp-expand.cc                             |  30 +
 gcc/omp-general.cc                            | 359 ++++++++++-
 gcc/omp-general.h                             |  32 +-
 gcc/omp-low.cc                                |  80 +++
 gcc/omp-offload.cc                            | 105 +++-
 gcc/omp-simd-clone.cc                         |   1 +
 .../c-c++-common/gomp/metadirective-1.c       |  52 ++
 .../c-c++-common/gomp/metadirective-2.c       |  74 +++
 .../c-c++-common/gomp/metadirective-3.c       |  31 +
 .../c-c++-common/gomp/metadirective-4.c       |  40 ++
 .../c-c++-common/gomp/metadirective-5.c       |  24 +
 .../c-c++-common/gomp/metadirective-6.c       |  31 +
 .../c-c++-common/gomp/metadirective-7.c       |  31 +
 .../c-c++-common/gomp/metadirective-8.c       |  16 +
 .../gomp/metadirective-construct.c            | 177 ++++++
 .../c-c++-common/gomp/metadirective-device.c  | 147 +++++
 .../gomp/metadirective-no-score.c             |  95 +++
 .../gomp/metadirective-target-device.c        | 147 +++++
 .../g++.dg/gomp/attrs-metadirective-1.C       |  40 ++
 .../g++.dg/gomp/attrs-metadirective-2.C       |  74 +++
 .../g++.dg/gomp/attrs-metadirective-3.C       |  31 +
 .../g++.dg/gomp/attrs-metadirective-4.C       |  41 ++
 .../g++.dg/gomp/attrs-metadirective-5.C       |  24 +
 .../g++.dg/gomp/attrs-metadirective-6.C       |  31 +
 .../g++.dg/gomp/attrs-metadirective-7.C       |  31 +
 .../g++.dg/gomp/attrs-metadirective-8.C       |  16 +
 gcc/testsuite/gcc.dg/gomp/metadirective-1.c   |  15 +
 .../gfortran.dg/gomp/metadirective-1.f90      |  55 ++
 .../gfortran.dg/gomp/metadirective-10.f90     |  40 ++
 .../gfortran.dg/gomp/metadirective-11.f90     |  33 +
 .../gfortran.dg/gomp/metadirective-2.f90      |  62 ++
 .../gfortran.dg/gomp/metadirective-3.f90      |  34 ++
 .../gfortran.dg/gomp/metadirective-4.f90      |  39 ++
 .../gfortran.dg/gomp/metadirective-5.f90      |  30 +
 .../gfortran.dg/gomp/metadirective-6.f90      |  31 +
 .../gfortran.dg/gomp/metadirective-7.f90      |  36 ++
 .../gfortran.dg/gomp/metadirective-8.f90      |  22 +
 .../gfortran.dg/gomp/metadirective-9.f90      |  30 +
 .../gomp/metadirective-construct.f90          | 260 ++++++++
 .../gomp/metadirective-no-score.f90           | 122 ++++
 gcc/testsuite/gfortran.dg/gomp/pure-1.f90     |   7 +
 gcc/testsuite/gfortran.dg/gomp/pure-2.f90     |   8 -
 gcc/tree-cfg.cc                               |  24 +
 gcc/tree-inline.cc                            |  39 ++
 gcc/tree-pretty-print.cc                      |  36 +-
 gcc/tree-pretty-print.h                       |   2 +
 gcc/tree-ssa-operands.cc                      |  17 +
 gcc/tree.def                                  |   6 +
 gcc/tree.h                                    |   3 +
 include/cuda/cuda.h                           |   2 +
 libgomp/Makefile.am                           |   2 +-
 libgomp/Makefile.in                           |   5 +-
 libgomp/config/gcn/selector.c                 |  57 ++
 libgomp/config/linux/selector.c               |  43 ++
 libgomp/config/linux/x86/selector.c           | 325 ++++++++++
 libgomp/config/nvptx/selector.c               |  65 ++
 libgomp/libgomp-plugin.h                      |   2 +
 libgomp/libgomp.h                             |   1 +
 libgomp/libgomp.map                           |   1 +
 libgomp/libgomp.texi                          |  15 +-
 libgomp/libgomp_g.h                           |   8 +
 libgomp/oacc-host.c                           |  11 +
 libgomp/plugin/plugin-gcn.c                   |  14 +
 libgomp/plugin/plugin-nvptx.c                 |  45 ++
 libgomp/selector.c                            |  36 ++
 libgomp/target.c                              |  38 ++
 .../libgomp.c++/metadirective-template-1.C    |  37 ++
 .../libgomp.c++/metadirective-template-2.C    |  41 ++
 .../libgomp.c++/metadirective-template-3.C    |  41 ++
 .../libgomp.c-c++-common/metadirective-1.c    |  35 ++
 .../libgomp.c-c++-common/metadirective-2.c    |  41 ++
 .../libgomp.c-c++-common/metadirective-3.c    |  34 ++
 .../libgomp.c-c++-common/metadirective-4.c    |  52 ++
 .../libgomp.c-c++-common/metadirective-5.c    |  46 ++
 .../libgomp.fortran/metadirective-1.f90       |  61 ++
 .../libgomp.fortran/metadirective-2.f90       |  40 ++
 .../libgomp.fortran/metadirective-3.f90       |  29 +
 .../libgomp.fortran/metadirective-4.f90       |  46 ++
 .../libgomp.fortran/metadirective-5.f90       |  44 ++
 .../libgomp.fortran/metadirective-6.f90       |  58 ++
 123 files changed, 6528 insertions(+), 423 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-1.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-2.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-3.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-4.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-5.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-6.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-7.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-8.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-construct.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-device.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-no-score.c
 create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-target-device.c
 create mode 100644 gcc/testsuite/g++.dg/gomp/attrs-metadirective-1.C
 create mode 100644 gcc/testsuite/g++.dg/gomp/attrs-metadirective-2.C
 create mode 100644 gcc/testsuite/g++.dg/gomp/attrs-metadirective-3.C
 create mode 100644 gcc/testsuite/g++.dg/gomp/attrs-metadirective-4.C
 create mode 100644 gcc/testsuite/g++.dg/gomp/attrs-metadirective-5.C
 create mode 100644 gcc/testsuite/g++.dg/gomp/attrs-metadirective-6.C
 create mode 100644 gcc/testsuite/g++.dg/gomp/attrs-metadirective-7.C
 create mode 100644 gcc/testsuite/g++.dg/gomp/attrs-metadirective-8.C
 create mode 100644 gcc/testsuite/gcc.dg/gomp/metadirective-1.c
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-10.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-11.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-2.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-3.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-4.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-5.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-6.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-7.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-8.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-construct.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-no-score.f90
 create mode 100644 libgomp/config/gcn/selector.c
 create mode 100644 libgomp/config/linux/selector.c
 create mode 100644 libgomp/config/linux/x86/selector.c
 create mode 100644 libgomp/config/nvptx/selector.c
 create mode 100644 libgomp/selector.c
 create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-1.C
 create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-2.C
 create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-3.C
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-2.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-3.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-4.c
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-5.c
 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-1.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-2.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-3.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-4.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-5.f90
 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-6.f90