]> gcc.gnu.org Git - gcc.git/commit
openmp: Add begin declare target support
authorJakub Jelinek <jakub@redhat.com>
Tue, 4 Oct 2022 08:58:28 +0000 (10:58 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 4 Oct 2022 08:58:28 +0000 (10:58 +0200)
commit65d065bbad94e07a709be8d49a92de50f9e454dd
treed4f477ba6dc3e2a0e72c5d0c7b73793c69d47163
parent5ee8de3513b87858bc1c90ee2730a5889d484268
openmp: Add begin declare target support

The following patch adds support for the begin declare target construct,
which is another spelling for declare target construct without clauses
(where it needs paired end declare target), but unlike that one accepts
clauses.

This is an OpenMP 5.1 feature, implemented with 5.2 clarification because
in 5.1 we had a restriction in the declare target chapter shared by
declare target and begin declare target that if there are any clauses
specified at least one of them needs to be to or link.  But that
was of course meant just for declare target and not begin declare target,
because begin declare target doesn't even allow to/link/enter clauses.
In addition to that, the patch also makes device_type clause duplication
an error (as stated in 5.1) and similarly makes declare target with
just device_type clause an error rather than warning.

What this patch doesn't do is:
1) OpenMP 5.1 also added an indirect clause, we don't support that
   neither on declare target nor begin declare target
   and I couldn't find it in our features pages (neither libgomp.texi
   nor web)
2) I think device_type(nohost)/device_type(host) support can't work for
   variables (in 5.0 it only talked about procedures so this could be
   also thought as 5.1 feature that we should just add to the list
   and implement)
3) I don't see any use of the "omp declare target nohost" attribute, so
   I'm not sure if device_type(nohost) works at all

2022-10-04  Jakub Jelinek  <jakub@redhat.com>

gcc/c-family/
* c-omp.cc (c_omp_directives): Uncomment begin declare target
entry.
gcc/c/
* c-lang.h (struct c_omp_declare_target_attr): New type.
(current_omp_declare_target_attribute): Change type from
int to vec<c_omp_declare_target_attr, va_gc> *.
* c-parser.cc (c_parser_translation_unit): Adjust for that change.
If last pushed directive was begin declare target, use different
wording and simplify format strings for easier translations.
(c_parser_omp_clause_device_type): Uncomment
check_no_duplicate_clause call.
(c_parser_omp_declare_target): Adjust for the
current_omp_declare_target_attribute type change, push { -1 }.
Use error_at rather than warning_at for declare target with
only device_type clauses.
(OMP_BEGIN_DECLARE_TARGET_CLAUSE_MASK): Define.
(c_parser_omp_begin): Add begin declare target support.
(c_parser_omp_end): Adjust for the
current_omp_declare_target_attribute type change, adjust
diagnostics wording and simplify format strings for easier
translations.
* c-decl.cc (current_omp_declare_target_attribute): Change type from
int to vec<c_omp_declare_target_attr, va_gc> *.
(c_decl_attributes): Adjust for the
current_omp_declare_target_attribute type change.  If device_type
was present on begin declare target, add "omp declare target host"
and/or "omp declare target nohost" attributes.
gcc/cp/
* cp-tree.h (struct omp_declare_target_attr): Rename to ...
(cp_omp_declare_target_attr): ... this.  Add device_type member.
(omp_begin_assumes_data): Rename to ...
(cp_omp_begin_assumes_data): ... this.
(struct saved_scope): Change types of omp_declare_target_attribute
and omp_begin_assumes.
* parser.cc (cp_parser_omp_clause_device_type): Uncomment
check_no_duplicate_clause call.
(cp_parser_omp_all_clauses): Fix up pasto, c_name for OMP_CLAUSE_LINK
should be "link" rather than "to".
(cp_parser_omp_declare_target): Adjust for omp_declare_target_attr
to cp_omp_declare_target_attr changes, push -1 as device_type.  Use
error_at rather than warning_at for declare target with only
device_type clauses.
(OMP_BEGIN_DECLARE_TARGET_CLAUSE_MASK): Define.
(cp_parser_omp_begin): Add begin declare target support.  Adjust
for omp_begin_assumes_data to cp_omp_begin_assumes_data change.
(cp_parser_omp_end): Adjust for the
omp_declare_target_attr to cp_omp_declare_target_attr and
omp_begin_assumes_data to cp_omp_begin_assumes_data type changes,
adjust diagnostics wording and simplify format strings for easier
translations.
* semantics.cc (finish_translation_unit): Likewise.
* decl2.cc (cplus_decl_attributes): If device_type was present on
begin declare target, add "omp declare target host" and/or
"omp declare target nohost" attributes.
gcc/testsuite/
* c-c++-common/gomp/declare-target-4.c: Move tests that are now
rejected into declare-target-7.c.
* c-c++-common/gomp/declare-target-6.c: Adjust expected diagnostics.
* c-c++-common/gomp/declare-target-7.c: New test.
* c-c++-common/gomp/begin-declare-target-1.c: New test.
* c-c++-common/gomp/begin-declare-target-2.c: New test.
* c-c++-common/gomp/begin-declare-target-3.c: New test.
* c-c++-common/gomp/begin-declare-target-4.c: New test.
* g++.dg/gomp/attrs-9.C: Add begin declare target tests.
* g++.dg/gomp/attrs-18.C: New test.
libgomp/
* libgomp.texi (Support begin/end declare target syntax in C/C++):
Mark as implemented.

(cherry picked from commit b6d5d72bd0b71ac96a8b2ee537367c46107dcb73)
23 files changed:
gcc/c-family/ChangeLog.omp
gcc/c-family/c-omp.cc
gcc/c/ChangeLog.omp
gcc/c/c-decl.cc
gcc/c/c-lang.h
gcc/c/c-parser.cc
gcc/cp/ChangeLog.omp
gcc/cp/cp-tree.h
gcc/cp/decl2.cc
gcc/cp/parser.cc
gcc/cp/semantics.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/begin-declare-target-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/begin-declare-target-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/begin-declare-target-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/begin-declare-target-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/declare-target-4.c
gcc/testsuite/c-c++-common/gomp/declare-target-6.c
gcc/testsuite/c-c++-common/gomp/declare-target-7.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/attrs-18.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/attrs-9.C
libgomp/ChangeLog.omp
libgomp/libgomp.texi
This page took 0.081 seconds and 6 git commands to generate.