From: Sandra Loosemore <sloosemore@baylibre.com>
To: gcc-patches@gcc.gnu.org
Cc: jakub@redhat.com, tburnus@baylibre.com
Subject: [PATCH 00/12] OpenMP: Metadirective support + "declare variant" improvements
Date: Sat, 4 May 2024 15:21:40 -0600 [thread overview]
Message-ID: <20240504212153.3561429-1-sloosemore@baylibre.com> (raw)
This series of patches is a revised and extended version of the metadirective
patches I previously posted in January:
https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642005.html
Those in turn were based on work by Kwok originally implemented on the
devel/omp/gcc-11 branch in 2021 and previously submitted for mainline 3+
years ago.
The current set comprises 12 parts. Parts 1-7 are fairly close to the
January patch set, but incorporating a number of bug fixes and
revisions for the review comments from Tobias. Part 3, in particular,
has a lot of changes to address both a buggy interface between the
compiler and libgomp, and Tobias's comments about bit-rotten target
support.
Parts 8-11 are new. Part 9 is a big patch that merges the dynamic selector
support to "declare variant", revises internal interfaces, and also fixes
PR114596 and other bugs relating to matching and scoring. The other pieces
are more self-contained fixes and improvements.
Part 12 is an updated patch for the implementation status table in the
libgomp manual.
As a general overview of what has changed here relative to the January patch
set:
* The dynamic selector support added for metadirective has been
integrated with declare variant; both directives now use common data
structures and scoring/sorting code. In particular, for calls to
"declare variant" functions that cannot be resolved during
gimplification, it now creates the same gimple structure used by
metadirective instead of using a magic placeholder symbol, and all
the support code used to track and process the placeholders has been
removed.
* Along the way, I found/fixed a serious bug in the resolution code in
the previously-posted metadirective patches; it was not saving
information about the OpenMP context needed to match/score construct
selectors during gimplification for use in late resolution, and
instead incorrectly calling the function dependent on being invoked
during gimplification during late resolution. It was also failing
to account for "declare simd"'s effect on scoring.
* I also found/fixed a serious bug in the existing mainline "declare
variant" scoring code that also affected the previous version of the
metadirective patches (PR 114596).
* Overall I tried to improve the software engineering aspect of the
scoring and matching code, making it better-documented and easier to
follow and correlate to the OpenMP specification.
* In the Fortran front end, I moved the filtering-out of metadirective
variants that can't possibly match from the parsing phase to the
translation phase, following Tobias's recommendation.
* I've updated the logic for when "declare target" adds a target
construct selector to the OpenMP context to follow recent versions
of the spec (the implementation now on mainline was for the language
in the 5.0 spec).
* For both metadirective and declare variant, when the gimplifier
processes metadirectives/calls that can't be resolved at that time,
it now filters out the variants that can't possibly match instead of
preserving all of them for late resolution, which might produce
better optimization opportunities. (The front ends already do this
once at parse time, but additional info is available during
gimplification that may allow additional variants to be discarded.)
* I fixed some bit-rot in the libgomp support for the target_device
selector, and adjusted the interface between the compiler and libgomp
to correctly handle selectors with multiple properties (previously it
was only handling the first one).
* I also added a diagnostic for requirement from the spec that
kind(any) cannot be used with any other properties. It turns out
there were multiple testcases that incorrectly did this.
In terms of what remains to be done:
* There is one test regression in libgomp, declare-variant-1.f90 hangs
during execution at -O0 only. I looked at this briefly but didn't make
any progress on debugging it.
* I haven't solved the issues discussed in issue PR113904 about the
scoping of expressions in "declare variant" dynamic selectors. For
C and C++, I have a good idea of how to implement the provisions in
the spec that allow references to argument variables of the variant
function. For now it diagnoses this with a "sorry"; meanwhile it
*does* parse the argument variables in the correct scope, and
correctly handles other symbols in scope, including class members
and "this" in C++. For Fortran, I'm unsure of the semantics, and
for "declare variant" it currently rejects non-constant expressions
in dynamic selectors.
I think both of those issues could be addressed with follow-up
patches. This is already a large and complicated patch set, and I
hope that by submitting it for review early in stage 1 it will be
possible to get at least some parts of it committed in a timely manner
and reduce the burden of maintaining these patches out of tree.
-Sandra
Sandra Loosemore (12):
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.
OpenMP: Reject other properties with kind(any)
OpenMP: Extend dynamic selector support to declare variant
OpenMP: Remove dead code from declare variant reimplementation
OpenMP: Update "declare target"/OpenMP context interaction
OpenMP: Update documentation of metadirective implementation status.
gcc/Makefile.in | 2 +-
gcc/builtin-types.def | 2 +
gcc/c-family/c-attribs.cc | 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-decl.cc | 8 +-
gcc/c/c-parser.cc | 473 +++-
gcc/cgraph.cc | 2 -
gcc/cgraph.h | 12 +-
gcc/cgraphclones.cc | 2 +-
gcc/cp/cp-tree.h | 2 +
gcc/cp/decl.cc | 2 +-
gcc/cp/decl2.cc | 9 +-
gcc/cp/parser.cc | 526 ++++-
gcc/cp/parser.h | 7 +
gcc/cp/pt.cc | 120 +
gcc/cp/semantics.cc | 3 +-
gcc/doc/generic.texi | 32 +
gcc/doc/gimple.texi | 6 +
gcc/fortran/decl.cc | 29 +
gcc/fortran/dump-parse-tree.cc | 21 +
gcc/fortran/gfortran.h | 20 +-
gcc/fortran/io.cc | 2 +-
gcc/fortran/match.h | 2 +
gcc/fortran/openmp.cc | 294 ++-
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 | 238 +-
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 | 13 +
gcc/gimple-streamer-out.cc | 10 +
gcc/gimple-walk.cc | 28 +
gcc/gimple.cc | 36 +
gcc/gimple.def | 8 +
gcc/gimple.h | 122 +-
gcc/gimplify.cc | 574 +++--
gcc/gimplify.h | 2 +-
gcc/gsstruct.def | 2 +
gcc/ipa-free-lang-data.cc | 2 +-
gcc/ipa.cc | 3 -
gcc/lto-cgraph.cc | 12 +-
gcc/lto-streamer-out.cc | 3 +-
gcc/lto-streamer.h | 6 -
gcc/lto/lto-partition.cc | 5 +-
gcc/omp-builtins.def | 3 +
gcc/omp-expand.cc | 32 +-
gcc/omp-general.cc | 2033 +++++++++--------
gcc/omp-general.h | 50 +-
gcc/omp-low.cc | 83 +
gcc/omp-offload.cc | 117 +-
gcc/omp-simd-clone.cc | 3 +-
gcc/passes.cc | 3 +-
gcc/symtab.cc | 2 +-
.../gomp/declare-target-indirect-2.c | 10 +-
.../c-c++-common/gomp/declare-variant-10.c | 4 +-
.../c-c++-common/gomp/declare-variant-12.c | 14 +-
.../c-c++-common/gomp/declare-variant-13.c | 6 +-
.../c-c++-common/gomp/declare-variant-2.c | 4 +-
.../c-c++-common/gomp/declare-variant-3.c | 10 +-
.../c-c++-common/gomp/declare-variant-8.c | 4 +-
.../c-c++-common/gomp/declare-variant-9.c | 4 +-
.../c-c++-common/gomp/declare-variant-any.c | 10 +
.../gomp/declare-variant-arg-exprs.c | 29 +
.../gomp/declare-variant-dynamic-1.c | 26 +
.../gomp/declare-variant-dynamic-2.c | 30 +
.../c-c++-common/gomp/metadirective-1.c | 52 +
.../c-c++-common/gomp/metadirective-2.c | 74 +
.../c-c++-common/gomp/metadirective-3.c | 21 +
.../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 ++
.../c-c++-common/gomp/reverse-offload-1.c | 2 +-
.../g++.dg/gomp/attrs-metadirective-1.C | 40 +
.../g++.dg/gomp/attrs-metadirective-2.C | 74 +
.../g++.dg/gomp/attrs-metadirective-3.C | 19 +
.../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 +
.../g++.dg/gomp/declare-variant-class-1.C | 32 +
.../g++.dg/gomp/declare-variant-class-2.C | 37 +
gcc/testsuite/gcc.dg/gomp/metadirective-1.c | 15 +
.../gfortran.dg/gomp/declare-variant-10.f90 | 4 +-
.../gfortran.dg/gomp/declare-variant-12.f90 | 14 +-
.../gfortran.dg/gomp/declare-variant-13.f90 | 28 +-
.../gfortran.dg/gomp/declare-variant-3.f90 | 12 +-
.../gfortran.dg/gomp/declare-variant-8.f90 | 12 +-
.../gfortran.dg/gomp/declare-variant-9.f90 | 2 +-
.../gfortran.dg/gomp/declare-variant-any.f90 | 28 +
.../gfortran.dg/gomp/metadirective-1.f90 | 73 +
.../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 | 24 +
.../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 | 45 +-
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 | 102 +
libgomp/config/linux/selector.c | 65 +
libgomp/config/linux/x86/selector.c | 406 ++++
libgomp/config/nvptx/selector.c | 77 +
libgomp/libgomp-plugin.h | 2 +
libgomp/libgomp.h | 1 +
libgomp/libgomp.map | 5 +
libgomp/libgomp.texi | 39 +-
libgomp/libgomp_g.h | 8 +
libgomp/oacc-host.c | 11 +
libgomp/plugin/plugin-gcn.c | 52 +
libgomp/plugin/plugin-nvptx.c | 82 +
libgomp/selector.c | 64 +
libgomp/target.c | 40 +
.../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 +
160 files changed, 8115 insertions(+), 1655 deletions(-)
create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-any.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-arg-exprs.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-dynamic-1.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-dynamic-2.c
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/g++.dg/gomp/declare-variant-class-1.C
create mode 100644 gcc/testsuite/g++.dg/gomp/declare-variant-class-2.C
create mode 100644 gcc/testsuite/gcc.dg/gomp/metadirective-1.c
create mode 100644 gcc/testsuite/gfortran.dg/gomp/declare-variant-any.f90
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
--
2.25.1
next reply other threads:[~2024-05-04 21:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-04 21:21 Sandra Loosemore [this message]
2024-05-04 21:21 ` [PATCH 01/12] OpenMP: metadirective tree data structures and front-end interfaces Sandra Loosemore
2024-05-04 21:21 ` [PATCH 02/12] OpenMP: middle-end support for metadirectives Sandra Loosemore
2024-05-04 21:21 ` [PATCH 03/12] libgomp: runtime support for target_device selector Sandra Loosemore
2024-05-04 21:21 ` [PATCH 04/12] OpenMP: C front end support for metadirectives Sandra Loosemore
2024-05-04 21:21 ` [PATCH 05/12] OpenMP: C++ front-end " Sandra Loosemore
2024-05-04 21:21 ` [PATCH 06/12] OpenMP: common c/c++ testcases " Sandra Loosemore
2024-05-04 21:21 ` [PATCH 07/12] OpenMP: Fortran front-end support " Sandra Loosemore
2024-05-04 21:21 ` [PATCH 08/12] OpenMP: Reject other properties with kind(any) Sandra Loosemore
2024-05-04 21:21 ` [PATCH 09/12] OpenMP: Extend dynamic selector support to declare variant Sandra Loosemore
2024-05-04 21:21 ` [PATCH 10/12] OpenMP: Remove dead code from declare variant reimplementation Sandra Loosemore
2024-05-04 21:21 ` [PATCH 11/12] OpenMP: Update "declare target"/OpenMP context interaction Sandra Loosemore
2024-05-04 21:21 ` [PATCH 12/12] OpenMP: Update documentation of metadirective implementation status 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=20240504212153.3561429-1-sloosemore@baylibre.com \
--to=sloosemore@baylibre.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=tburnus@baylibre.com \
/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).