Hi! On 2021-09-20T13:46:03+0100, Julian Brown <jul...@codesourcery.com> wrote: > On Fri, 17 Sep 2021 16:26:50 +0200 > Thomas Schwinge <tho...@codesourcery.com> wrote: > >> > @@ -1449,8 +1634,120 @@ oacc_do_neutering (void) >> >> > + addr_range ar >> > + = first_fit_range (conflicts, size, align, &worker_shm_bounds); >> > + >> > + splay_tree_delete (conflicts); >> > + >> > + if (ar.invalid ()) >> > + { >> > + unsigned HOST_WIDE_INT base; >> > + base = bounds_lo + random () % 512; >> > + base = (base + align - 1) & ~(align - 1); >> > + if (base + size > bounds_hi) >> > + error_at (UNKNOWN_LOCATION, "shared-memory region overflow"); >> >> My dice doesn't have 512 faces -- what am I to read into the >> expression 'random () % 512' here? (Surely this must offend the >> folks of <https://reproducible-builds.org/>.) ;-)
Also <https://gcc.gnu.org/PR102408> "[OpenACC] omp-oacc-neuter-broadcast.cc: random() not available on all platforms"... > For this one -- the randomness shouldn't be necessary for the > correctness of the patch (i.e. it could just be "base = bounds_lo", or > indeed folded into the line after). > > The "ar.invalid ()" case happens when we fail to allocate a block of > memory in LDS space for broadcasting a particular set of variables, > and trigger a fall-back path in the broadcasting code that adds extra > barriers around the broadcast in question. I imagine I was thinking > that adding randomness could mean we can "get lucky" sometimes and > avoid needing those barriers in some cases, but in fact I don't think > that was implemented, so the randomness is useless. (Or it could just > have been leftover debug code... oops). Pushed to master branch commit e87789f197e47259c94349821d3446f7d959e08f "Evaluate 'random ()' to '0' in 'pass_omp_oacc_neuter_broadcast'", see attached. Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
>From e87789f197e47259c94349821d3446f7d959e08f Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tho...@codesourcery.com> Date: Tue, 21 Sep 2021 08:54:49 +0200 Subject: [PATCH] Evaluate 'random ()' to '0' in 'pass_omp_oacc_neuter_broadcast' Julian Brown, <http://mid.mail-archive.com/20210920134603.16459021@squid.athome>: | [...] the randomness shouldn't be necessary for the | correctness of the patch (i.e. it could just be "base = bounds_lo", or | indeed folded into the line after). | | The "ar.invalid ()" case happens when we fail to allocate a block of | memory in LDS space for broadcasting a particular set of variables, | and trigger a fall-back path in the broadcasting code that adds extra | barriers around the broadcast in question. I imagine I was thinking | that adding randomness could mean we can "get lucky" sometimes and | avoid needing those barriers in some cases, but in fact I don't think | that was implemented, so the randomness is useless. (Or it could just | have been leftover debug code... oops). gcc/ PR other/102408 * omp-oacc-neuter-broadcast.cc (oacc_do_neutering): Evaluate 'random ()' to '0'. --- gcc/omp-oacc-neuter-broadcast.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gcc/omp-oacc-neuter-broadcast.cc b/gcc/omp-oacc-neuter-broadcast.cc index aa5990ed7a1..e43338f3abf 100644 --- a/gcc/omp-oacc-neuter-broadcast.cc +++ b/gcc/omp-oacc-neuter-broadcast.cc @@ -1782,9 +1782,8 @@ oacc_do_neutering (unsigned HOST_WIDE_INT bounds_lo, if (ar.invalid ()) { - unsigned HOST_WIDE_INT base; - base = bounds_lo + random () % 512; - base = (base + align - 1) & ~(align - 1); + unsigned HOST_WIDE_INT base + = (bounds_lo + align - 1) & ~(align - 1); if (base + size > bounds_hi) error_at (UNKNOWN_LOCATION, "shared-memory region overflow"); std::pair<unsigned HOST_WIDE_INT, bool> base_inrng -- 2.33.0