[gcc r11-9606] openmp: Make finalize_task_copyfn order reproduceable [PR104517]
Jakub Jelinek
jakub@gcc.gnu.org
Sat Feb 19 08:03:07 GMT 2022
https://gcc.gnu.org/g:14f0b450f7976f824428f0d35b4e7e6dc162f708
commit r11-9606-g14f0b450f7976f824428f0d35b4e7e6dc162f708
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Feb 15 10:22:30 2022 +0100
openmp: Make finalize_task_copyfn order reproduceable [PR104517]
The following testcase fails -fcompare-debug, because finalize_task_copyfn
was invoked from splay tree destruction, whose order can in some cases
depend on -g/-g0. The fix is to queue the task stmts that need copyfn
in a vector and run finalize_task_copyfn on elements of that vector.
2022-02-15 Jakub Jelinek <jakub@redhat.com>
PR debug/104517
* omp-low.c (task_cpyfns): New variable.
(delete_omp_context): Don't call finalize_task_copyfn from here.
(create_task_copyfn): Push task_stmt into task_cpyfns.
(execute_lower_omp): Call finalize_task_copyfn here on entries from
task_cpyfns vector and release the vector.
* gcc.dg/gomp/pr104517.c: New test.
(cherry picked from commit 6a0d6e7ca9b9e338e82572db79c26168684a7441)
Diff:
---
gcc/omp-low.c | 9 ++++--
gcc/testsuite/gcc.dg/gomp/pr104517.c | 53 ++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 3b39b55f2d9..962cf886710 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -187,6 +187,7 @@ static int target_nesting_level;
static bitmap task_shared_vars;
static bitmap global_nonaddressable_vars;
static vec<omp_context *> taskreg_contexts;
+static vec<gomp_task *> task_cpyfns;
static void scan_omp (gimple_seq *, omp_context *);
static tree scan_omp_1_op (tree *, int *, void *);
@@ -1061,9 +1062,6 @@ delete_omp_context (splay_tree_value value)
DECL_ABSTRACT_ORIGIN (t) = NULL;
}
- if (is_task_ctx (ctx))
- finalize_task_copyfn (as_a <gomp_task *> (ctx->stmt));
-
if (ctx->task_reduction_map)
{
ctx->task_reductions.release ();
@@ -11306,6 +11304,7 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx)
size_t looptempno = 0;
child_fn = gimple_omp_task_copy_fn (task_stmt);
+ task_cpyfns.safe_push (task_stmt);
child_cfun = DECL_STRUCT_FUNCTION (child_fn);
gcc_assert (child_cfun->cfg == NULL);
DECL_SAVED_TREE (child_fn) = alloc_stmt_list ();
@@ -13630,6 +13629,10 @@ execute_lower_omp (void)
&& (TREE_CODE (TREE_TYPE (DECL_ARGUMENTS (current_function_decl)))
== POINTER_TYPE))
remove_member_access_dummy_vars (DECL_INITIAL (current_function_decl));
+
+ for (auto task_stmt : task_cpyfns)
+ finalize_task_copyfn (task_stmt);
+ task_cpyfns.release ();
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr104517.c b/gcc/testsuite/gcc.dg/gomp/pr104517.c
new file mode 100644
index 00000000000..133e5c36d95
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr104517.c
@@ -0,0 +1,53 @@
+/* PR debug/104517 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fcompare-debug -fopenmp -fno-tree-ter -save-temps" } */
+
+enum {
+ omp_default_mem_alloc,
+ omp_large_cap_mem_alloc,
+ omp_const_mem_alloc,
+ omp_high_bw_mem_alloc
+} omp_allocator_handle_t;
+
+int t, bar_nte, bar_tl, bar_i3, bar_dd;
+
+#pragma omp threadprivate(t)
+#pragma omp declare target
+int f, l, ll, r, r2;
+#pragma omp end declare target
+
+void
+bar (int *idp, int s, int nth, int g, int nta, int fi, int pp, int *q,
+ int ntm)
+{
+ int p = 0, i2 = 0, i1 = 0, m = 0, d = 0;
+
+#pragma omp target parallel for \
+ device(p) firstprivate (f) allocate (f)
+ for (int i = 0; i < 4; i++)
+ ll++;
+
+#pragma omp target parallel for \
+ device(d) map (m) \
+ if (target: p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \
+ if (parallel: i2) reduction(+:r) num_threads (nth) linear (ll) \
+ schedule(static) collapse(1) nowait depend(inout: d) allocate (f)
+ for (int i = 0; i < 4; i++)
+ ll++;
+
+#pragma omp taskloop simd firstprivate(f) lastprivate(s) grainsize(g) \
+ collapse(1) untied if (i1) final(fi) mergeable nogroup \
+ priority(pp) linear(ll) aligned(q) allocate(f)
+ for (int i = 0; i < 4; i++)
+ ll++;
+
+#pragma omp taskloop simd firstprivate(f) lastprivate(s) num_tasks(nta) \
+ collapse(1) if (i1) final(fi) priority(pp) safelen(8) simdlen(4) \
+ linear(ll) aligned(q) nontemporal(ntm) order(concurrent) allocate(f)
+ for (int i = 0; i < 4; i++)
+ ll++;
+
+#pragma omp parallel master firstprivate(f) shared(nth) proc_bind(spread) \
+ copyin(t) allocate(f)
+ ;
+}
More information about the Gcc-cvs
mailing list