aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-08-08 08:39:02 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-08-08 08:39:02 +0200
commit8860d2706d9bd21da3885f980f313733fdc525d1 (patch)
tree2420aa40b9b451dd4e3b7251149b6c8a5f7ce9c1 /gcc
parent34f3ec07575f80964c9885874cb186ae3a913fcb (diff)
downloadgcc-8860d2706d9bd21da3885f980f313733fdc525d1.zip
gcc-8860d2706d9bd21da3885f980f313733fdc525d1.tar.gz
gcc-8860d2706d9bd21da3885f980f313733fdc525d1.tar.bz2
gimplify.c (omp_add_variable): Use GOVD_PRIVATE | GOVD_EXPLICIT for VLA helper variables on target data even if...
* gimplify.c (omp_add_variable): Use GOVD_PRIVATE | GOVD_EXPLICIT for VLA helper variables on target data even if not GOVD_FIRSTPRIVATE. (gimplify_scan_omp_clauses): For OMP_CLAUSE_USE_DEVICE_* use just GOVD_EXPLICIT flags. (gimplify_omp_workshare): For OMP_TARGET_DATA move all OMP_CLAUSE_USE_DEVICE_* clauses to the end of clauses chain. * omp-low.c (scan_sharing_clauses): For OMP_CLAUSE_USE_DEVICE_* call install_var_field with mask 11 instead of 3. (lower_omp_target): For OMP_CLAUSE_USE_DEVICE_* use pass (splay_tree_key) &DECL_UID (var) to build_sender_ref instead of var. gcc/c/ * c-typeck.c (c_finish_omp_clauses): For C_ORT_OMP OMP_CLAUSE_USE_DEVICE_* clauses use oacc_reduction_head bitmap instead of generic_head to track duplicates. gcc/cp/ * semantics.c (finish_omp_clauses): For C_ORT_OMP OMP_CLAUSE_USE_DEVICE_* clauses use oacc_reduction_head bitmap instead of generic_head to track duplicates. libgomp/ * target.c (gomp_map_vars_internal): For GOMP_MAP_USE_DEVICE_PTR perform the lookup in the first loop only if !not_found_cnt, otherwise perform lookups for it in the second loop guarded with if (not_found_cnt || has_firstprivate). * testsuite/libgomp.c/target-37.c: New test. * testsuite/libgomp.c++/target-22.C: New test. From-SVN: r274206
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-typeck.c15
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c15
-rw-r--r--gcc/gimplify.c32
-rw-r--r--gcc/omp-low.c17
7 files changed, 86 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 45050ed..00d8030 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2019-08-08 Jakub Jelinek <jakub@redhat.com>
+
+ * gimplify.c (omp_add_variable): Use GOVD_PRIVATE | GOVD_EXPLICIT
+ for VLA helper variables on target data even if not GOVD_FIRSTPRIVATE.
+ (gimplify_scan_omp_clauses): For OMP_CLAUSE_USE_DEVICE_* use just
+ GOVD_EXPLICIT flags.
+ (gimplify_omp_workshare): For OMP_TARGET_DATA move all
+ OMP_CLAUSE_USE_DEVICE_* clauses to the end of clauses chain.
+ * omp-low.c (scan_sharing_clauses): For OMP_CLAUSE_USE_DEVICE_*
+ call install_var_field with mask 11 instead of 3.
+ (lower_omp_target): For OMP_CLAUSE_USE_DEVICE_* use pass
+ (splay_tree_key) &DECL_UID (var) to build_sender_ref instead of var.
+
2019-08-07 Richard Sandiford <richard.sandiford@arm.com>
* config/aarch64/constraints.md (Z): Handle floating-point zeros too.
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 18c1ce0..4944696 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2019-08-08 Jakub Jelinek <jakub@redhat.com>
+
+ * c-typeck.c (c_finish_omp_clauses): For C_ORT_OMP
+ OMP_CLAUSE_USE_DEVICE_* clauses use oacc_reduction_head bitmap
+ instead of generic_head to track duplicates.
+
2019-08-07 Jakub Jelinek <jakub@redhat.com>
* c-parser.c (c_parser_omp_clause_name): Parse use_device_addr clause.
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index bda90fd..1d865aa 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -13680,7 +13680,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
/* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead. */
bitmap_initialize (&map_head, &bitmap_default_obstack);
bitmap_initialize (&map_field_head, &bitmap_default_obstack);
- /* If ort == C_ORT_OMP used as nontemporal_head instead. */
+ /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head
+ instead. */
bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack);
if (ort & C_ORT_ACC)
@@ -14072,13 +14073,19 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
- else if (ort == C_ORT_ACC
- && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ else if ((ort == C_ORT_ACC
+ && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ || (ort == C_ORT_OMP
+ && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
+ || (OMP_CLAUSE_CODE (c)
+ == OMP_CLAUSE_USE_DEVICE_ADDR))))
{
if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
{
error_at (OMP_CLAUSE_LOCATION (c),
- "%qD appears more than once in reduction clauses",
+ ort == C_ORT_ACC
+ ? "%qD appears more than once in reduction clauses"
+ : "%qD appears more than once in data clauses",
t);
remove = true;
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bae5147..f937bf5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-08-08 Jakub Jelinek <jakub@redhat.com>
+
+ * semantics.c (finish_omp_clauses): For C_ORT_OMP
+ OMP_CLAUSE_USE_DEVICE_* clauses use oacc_reduction_head bitmap
+ instead of generic_head to track duplicates.
+
2019-08-07 Marek Polacek <polacek@redhat.com>
PR c++/81429 - wrong parsing of constructor with C++11 attribute.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 8fe632f..9fd759c 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -6148,7 +6148,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
/* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead. */
bitmap_initialize (&map_head, &bitmap_default_obstack);
bitmap_initialize (&map_field_head, &bitmap_default_obstack);
- /* If ort == C_ORT_OMP used as nontemporal_head instead. */
+ /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head
+ instead. */
bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack);
if (ort & C_ORT_ACC)
@@ -6406,13 +6407,19 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
- else if (ort == C_ORT_ACC
- && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ else if ((ort == C_ORT_ACC
+ && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ || (ort == C_ORT_OMP
+ && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
+ || (OMP_CLAUSE_CODE (c)
+ == OMP_CLAUSE_USE_DEVICE_ADDR))))
{
if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
{
error_at (OMP_CLAUSE_LOCATION (c),
- "%qD appears more than once in reduction clauses",
+ ort == C_ORT_ACC
+ ? "%qD appears more than once in reduction clauses"
+ : "%qD appears more than once in data clauses",
t);
remove = true;
}
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 978df86..daa0b71 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6932,8 +6932,10 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags)
nflags = GOVD_MAP | GOVD_MAP_TO_ONLY | GOVD_EXPLICIT;
else if (flags & GOVD_PRIVATE)
nflags = GOVD_PRIVATE;
- else if ((ctx->region_type & (ORT_TARGET | ORT_TARGET_DATA)) != 0
- && (flags & GOVD_FIRSTPRIVATE))
+ else if (((ctx->region_type & (ORT_TARGET | ORT_TARGET_DATA)) != 0
+ && (flags & GOVD_FIRSTPRIVATE))
+ || (ctx->region_type == ORT_TARGET_DATA
+ && (flags & GOVD_DATA_SHARE_CLASS) == 0))
nflags = GOVD_PRIVATE | GOVD_EXPLICIT;
else
nflags = GOVD_FIRSTPRIVATE;
@@ -9016,6 +9018,9 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
case OMP_CLAUSE_USE_DEVICE_PTR:
case OMP_CLAUSE_USE_DEVICE_ADDR:
+ flags = GOVD_EXPLICIT;
+ goto do_add;
+
case OMP_CLAUSE_IS_DEVICE_PTR:
flags = GOVD_FIRSTPRIVATE | GOVD_EXPLICIT;
goto do_add;
@@ -12404,8 +12409,27 @@ gimplify_omp_workshare (tree *expr_p, gimple_seq *pre_p)
OMP_CLAUSES (expr));
break;
case OMP_TARGET_DATA:
- stmt = gimple_build_omp_target (body, GF_OMP_TARGET_KIND_DATA,
- OMP_CLAUSES (expr));
+ /* Put use_device_{ptr,addr} clauses last, as map clauses are supposed
+ to be evaluated before the use_device_{ptr,addr} clauses if they
+ refer to the same variables. */
+ {
+ tree use_device_clauses;
+ tree *pc, *uc = &use_device_clauses;
+ for (pc = &OMP_CLAUSES (expr); *pc; )
+ if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_USE_DEVICE_PTR
+ || OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_USE_DEVICE_ADDR)
+ {
+ *uc = *pc;
+ *pc = OMP_CLAUSE_CHAIN (*pc);
+ uc = &OMP_CLAUSE_CHAIN (*uc);
+ }
+ else
+ pc = &OMP_CLAUSE_CHAIN (*pc);
+ *uc = NULL_TREE;
+ *pc = use_device_clauses;
+ stmt = gimple_build_omp_target (body, GF_OMP_TARGET_KIND_DATA,
+ OMP_CLAUSES (expr));
+ }
break;
case OMP_TEAMS:
stmt = gimple_build_omp_teams (body, OMP_CLAUSES (expr));
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index ca8edde..444610b 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1243,9 +1243,9 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR
&& !omp_is_reference (decl))
|| TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
- install_var_field (decl, true, 3, ctx);
+ install_var_field (decl, true, 11, ctx);
else
- install_var_field (decl, false, 3, ctx);
+ install_var_field (decl, false, 11, ctx);
if (DECL_SIZE (decl)
&& TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
{
@@ -11857,11 +11857,16 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
case OMP_CLAUSE_IS_DEVICE_PTR:
ovar = OMP_CLAUSE_DECL (c);
var = lookup_decl_in_outer_ctx (ovar, ctx);
- x = build_sender_ref (ovar, ctx);
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IS_DEVICE_PTR)
- tkind = GOMP_MAP_USE_DEVICE_PTR;
+ {
+ tkind = GOMP_MAP_USE_DEVICE_PTR;
+ x = build_sender_ref ((splay_tree_key) &DECL_UID (ovar), ctx);
+ }
else
- tkind = GOMP_MAP_FIRSTPRIVATE_INT;
+ {
+ tkind = GOMP_MAP_FIRSTPRIVATE_INT;
+ x = build_sender_ref (ovar, ctx);
+ }
type = TREE_TYPE (ovar);
if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR
&& !omp_is_reference (ovar))
@@ -12032,7 +12037,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
case OMP_CLAUSE_IS_DEVICE_PTR:
var = OMP_CLAUSE_DECL (c);
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IS_DEVICE_PTR)
- x = build_sender_ref (var, ctx);
+ x = build_sender_ref ((splay_tree_key) &DECL_UID (var), ctx);
else
x = build_receiver_ref (var, false, ctx);
if (is_variable_sized (var))