]> gcc.gnu.org Git - gcc.git/commit
OpenMP 5.0: Improve OpenMP target support for C++ (includes PR92120 v3)
authorChung-Lin Tang <cltang@codesourcery.com>
Thu, 27 May 2021 11:53:45 +0000 (19:53 +0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Sat, 29 May 2021 21:00:19 +0000 (05:00 +0800)
commit97e3d5cb120245ca7785bb2c3359d39f8098cbf4
tree49c6743ed638aabc7c6d2c6e987a3472fa79397c
parentc86171a265a2f501213eef027ecb7b93ac1b742f
OpenMP 5.0: Improve OpenMP target support for C++ (includes PR92120 v3)

This patch is a merge of:
https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570886.html

To summarize, this patch set is an improvement for OpenMP target support for
C++, including for inside non-static members, lambda objects, and struct
member deref access expressions. The corresponding modifications for the C
front-end are also included.

This patch supercedes the prior versions of my PR92120 patch
(implicit C++ map(this[:1])), so dubbing this "v3" of patch for that PR.

Prior versions of the PR92120 patch was implemented by recording uses of
'this' in the parser, and then use the recorded uses during "finish" to
create the implicit maps.

When working on supporting lambda objects, this required using a tree-walk
style processing of the OMP_TARGET body, so in only made sense to merge the
entire 'this' processing together with it, so a large part of the parser
changes were dropped, with the main processing in semantics.c now.

Other parser changes to support '->' in map clauses are also with this patch.

gcc/cp/ChangeLog:

* cp-tree.h (finish_omp_target): New declaration.
(finish_omp_target_clauses): Likewise.
* parser.c (cp_parser_omp_clause_map): Adjust call to
cp_parser_omp_var_list_no_open to set 'allow_deref' argument to true.
(cp_parser_omp_target): Factor out code, adjust into calls to new
function finish_omp_target.
* pt.c (tsubst_expr): Add call to finish_omp_target_clauses for
OMP_TARGET case.
* semantics.c (handle_omp_array_sections_1): Add handling to create
'this->member' from 'member' FIELD_DECL.
(handle_omp_array_sections): Likewise.
(finish_omp_clauses): Likewise. Adjust to allow 'this[]' in OpenMP
map clauses. Handle 'A->member' case in map clauses.
(struct omp_target_walk_data): New struct for walking over
target-directive tree body.
(finish_omp_target_clauses_r): New function for tree walk.
(finish_omp_target_clauses): New function.
(finish_omp_target): New function.

gcc/c/ChangeLog:

* c-parser.c (c_parser_omp_clause_map): Set 'allow_deref' argument in
call to c_parser_omp_variable_list to 'true'.
* c-typeck.c (handle_omp_array_sections_1): Add strip of MEM_REF in
array base handling.
(c_finish_omp_clauses): Handle 'A->member' case in map clauses.

gcc/ChangeLog:

* gimplify.c ("tree-hash-traits.h"): Add include.
(gimplify_scan_omp_clauses): Change struct_map_to_clause to type
hash_map<tree_operand, tree> *. Adjust struct map handling to handle
cases of *A and A->B expressions. Under !DECL_P case of
GOMP_CLAUSE_MAP handling, add STRIP_NOPS for indir_p case, add to
struct_deref_set for map(*ptr_to_struct) cases. Add MEM_REF case when
handling component_ref_p case. Add unshare_expr and gimplification
when created GOMP_MAP_STRUCT is not a DECL. Add code to add
firstprivate pointer for *pointer-to-struct case.
(gimplify_adjust_omp_clauses): Move GOMP_MAP_STRUCT removal code for
exit data directives code to earlier position.
* omp-low.c (lower_omp_target):
Handle GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION, and
GOMP_MAP_POINTER_TO_ZERO_LENGTH_ARRAY_SECTION map kinds.
* tree-pretty-print.c (dump_omp_clause): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/gomp/target-3.c: New testcase.
* g++.dg/gomp/target-3.C: New testcase.
* g++.dg/gomp/target-lambda-1.C: New testcase.
* g++.dg/gomp/target-this-1.C: New testcase.
* g++.dg/gomp/target-this-2.C: New testcase.
* g++.dg/gomp/target-this-3.C: New testcase.
* g++.dg/gomp/target-this-4.C: New testcase.
* g++.dg/gomp/target-this-5.C: New testcase.
* g++.dg/gomp/this-2.C: Adjust testcase.

include/ChangeLog:

* gomp-constants.h (enum gomp_map_kind):
Add GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION, and
GOMP_MAP_POINTER_TO_ZERO_LENGTH_ARRAY_SECTION map kinds.
(GOMP_MAP_POINTER_P):
Include GOMP_MAP_POINTER_TO_ZERO_LENGTH_ARRAY_SECTION.

libgomp/ChangeLog:

* libgomp.h (gomp_attach_pointer): Add bool parameter.
* oacc-mem.c (acc_attach_async): Update call to gomp_attach_pointer.
(goacc_enter_data_internal): Likewise.
* target.c (gomp_map_vars_existing): Update assert condition to
include GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION.
(gomp_map_pointer): Add 'bool allow_zero_length_array_sections'
parameter, add support for mapping a pointer with NULL target.
(gomp_attach_pointer): Add 'bool allow_zero_length_array_sections'
parameter, add support for attaching a pointer with NULL target.
(gomp_map_vars_internal): Update calls to gomp_map_pointer and
gomp_attach_pointer, add handling for
GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION, and
GOMP_MAP_POINTER_TO_ZERO_LENGTH_ARRAY_SECTION cases.
* testsuite/libgomp.c++/target-23.C: New testcase.
* testsuite/libgomp.c++/target-lambda-1.C: New testcase.
* testsuite/libgomp.c++/target-this-1.C: New testcase.
* testsuite/libgomp.c++/target-this-2.C: New testcase.
* testsuite/libgomp.c++/target-this-3.C: New testcase.
* testsuite/libgomp.c++/target-this-4.C: New testcase.
* testsuite/libgomp.c++/target-this-5.C: New testcase.
29 files changed:
gcc/c/c-parser.c
gcc/c/c-typeck.c
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/gimplify.c
gcc/omp-low.c
gcc/testsuite/g++.dg/gomp/target-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/target-lambda-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/target-this-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/target-this-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/target-this-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/target-this-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/target-this-5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/this-2.C
gcc/testsuite/gcc.dg/gomp/target-3.c [new file with mode: 0644]
gcc/tree-pretty-print.c
include/gomp-constants.h
libgomp/libgomp.h
libgomp/oacc-mem.c
libgomp/target.c
libgomp/testsuite/libgomp.c++/target-23.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-lambda-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-this-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-this-2.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-this-3.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-this-4.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-this-5.C [new file with mode: 0644]
This page took 0.069083 seconds and 6 git commands to generate.