public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libgomp: Fix up target-31.c test [PR106045]
@ 2022-06-21 15:59 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-06-21 15:59 UTC (permalink / raw)
  To: gcc-patches

Hi!

The i variable is used inside of the parallel in:
      #pragma omp simd safelen(32) private (v)
      for (i = 0; i < 64; i++)
        {
          v = 3 * i;
          ll[i] = u1 + v * u2[0] + u2[1] + x + y[0] + y[1] + v + h[0] + u3[i];
        }
where i is predetermined linear (so while inside of the body
it is safe, private per SIMD lane var) the final value is written to
the shared variable, and in:
      for (i = 0; i < 64; i++)
        if (ll[i] != u1 + 3 * i * u2[0] + u2[1] + x + y[0] + y[1] + 3 * i + 13 + 14 + i)
          #pragma omp atomic write
            err = 1;
which is a normal loop and so it isn't in any way privatized there.
So we have a data race, fixed by adding private (i) clause to the
parallel.

Tested on x86_64-linux, committed to trunk.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>
	    Paul Iannetta  <piannetta@kalrayinc.com>

	PR libgomp/106045
	* testsuite/libgomp.c/target-31.c: Add private (i) clause.

--- libgomp/testsuite/libgomp.c/target-31.c.jj
+++ libgomp/testsuite/libgomp.c/target-31.c
@@ -76,7 +76,7 @@ main ()
       m[1] += 3 * b;
     }
     use (&a, &b, &c, &d, e, f, g, h);
-    #pragma omp parallel firstprivate (u1, u2)
+    #pragma omp parallel firstprivate (u1, u2) private (i)
     {
       int w = omp_get_thread_num ();
       int x = 19;


	Jakub


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-21 15:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 15:59 [committed] libgomp: Fix up target-31.c test [PR106045] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).