On Mon, Nov 28, 2011 at 10:12:09AM +1030, Alan Modra wrote:
> --- libgomp/config/linux/bar.c        (revision 181718)
> +++ libgomp/config/linux/bar.c        (working copy)
> @@ -36,18 +36,15 @@ gomp_barrier_wait_end (gomp_barrier_t *b
>    if (__builtin_expect ((state & 1) != 0, 0))
>      {
>        /* Next time we'll be awaiting TOTAL threads again.  */
> -      bar->awaited = bar->total;
> -      atomic_write_barrier ();
> -      bar->generation += 4;
> +      __atomic_store_4 (&bar->awaited, bar->total, MEMMODEL_RELEASE);
> +      __atomic_add_fetch (&bar->generation, 4, MEMMODEL_ACQ_REL);
>        futex_wake ((int *) &bar->generation, INT_MAX);
>      }

The above is unfortunate, bar->generation should be only modified from a
single thread at this point, but the __atomic_add_fetch will enforce there
an atomic instruction on it rather than just some kind of barrier.

        Jakub

Reply via email to